Commit a958b90d authored by NexAdn's avatar NexAdn
Browse files

Move ignore predicates to separate functions, ignore soft states

parent 33b6aeed
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment