Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Adrian Schollmeyer
icinga-ampel
Commits
a958b90d
Commit
a958b90d
authored
Sep 30, 2019
by
NexAdn
Browse files
Move ignore predicates to separate functions, ignore soft states
parent
33b6aeed
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main.cpp
View file @
a958b90d
...
...
@@ -18,10 +18,10 @@ namespace
{
constexpr
const
char
*
HOST_INFO_URL
=
"https://bigsister.fem.tu-ilmenau.de:5665/v1/objects/"
"hosts?attrs=acknowledgement&attrs=last_check_result&attrs=vars"
;
"hosts?attrs=acknowledgement&attrs=last_check_result&attrs=vars
&attrs=state_type
"
;
constexpr
const
char
*
SERVICE_INFO_URL
=
"https://bigsister.fem.tu-ilmenau.de:5665/v1/objects/"
"services?attrs=acknowledgement&attrs=last_check_result&attrs=vars"
;
"services?attrs=acknowledgement&attrs=last_check_result&attrs=vars
&attrs=state_type
"
;
constexpr
bool
SKIP_CERT_VERIFICATION
=
true
;
constexpr
int
RETURN_OK
=
0
;
...
...
@@ -74,15 +74,32 @@ inline void print_debug(std::string message)
{}
#endif
template
<
typename
T
>
inline
bool
is_acknowledged
(
T
object
)
{
return
object
[
"attrs"
][
"acknowledgement"
]
>
0
;
}
template
<
typename
T
>
inline
bool
ignored_by_config
(
T
object
)
{
return
object
[
"attrs"
][
"vars"
][
"ampel_disable"
]
!=
nullptr
&&
object
[
"attrs"
][
"vars"
][
"ampel_disable"
];
}
template
<
typename
T
>
inline
bool
is_in_soft_state
(
T
object
)
{
return
object
[
"attrs"
][
"state_type"
]
==
0
;
}
void
parse_result
(
health_data_map_t
&
output
,
const
std
::
string
&
raw_data
)
{
json
data
=
json
::
parse
(
raw_data
);
auto
results
=
data
[
"results"
];
for
(
auto
&
object
:
results
)
{
if
(
object
[
"attrs"
][
"acknowledgement"
]
>
0
||
(
object
[
"attrs"
][
"vars"
][
"ampel_disable"
]
!=
nullptr
&&
object
[
"attrs"
][
"vars"
][
"ampel_disable"
]))
{
if
(
is_in_soft_state
(
object
)
||
is_acknowledged
(
object
)
||
ignored_by_config
(
object
))
{
continue
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment