-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
icinga, cluster: add option to limit perfdata #8403
base: master
Are you sure you want to change the base?
Conversation
5a176a7
to
c46a30c
Compare
|
c46a30c
to
2ce1287
Compare
@cla-bot check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#8124 mentions a few more checks than what is done is this PR:
"icinga", "cluster", "custer-zone" and "ido"
Did you omit cluster-zone
because it only emits 7 perfdata values? Seems low enough that I think it would be absolutely necessary to filter here. @dgoetz Would there be a particular need for filters on that check?
ido
could be fine to omit as it's effectively deprecated, but the icingadb
check also emits lots of perfdata, so there might very well be the desire to filter here as well.
In general, would it make to sense to provide the ability to filter perfdata values as an option for all check commands? That would avoid that we have to hand pick the internal checks we want to implement this for and that would sound equally useful for external checks as well. Quick cross-reference that just came to my mind: implementing something like the suggestion in #6937 (comment) should allow this and would solve other issues as well.
if (!filter.IsObject()) { | ||
return; | ||
} | ||
|
||
auto filterArray (dynamic_pointer_cast<Array>((Object::Ptr)filter)); | ||
|
||
if (!filterArray) { | ||
return; | ||
} | ||
|
||
auto filterStrings (filterArray->ToSet<String>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid configuration shouldn't be ignored silently like the first two ifs do (except in the filter == Empty
case, but that's valid config). Without having tested this, this also looks to be inconsistent: with (in DSL syntax) filter = 42
it would be ignored whereas I thing filter = [[42]]
would throw an exception as [42]
can't be casted to String
.
for (decltype(perfdata->GetLength()) i = 0; i < perfdata->GetLength(); ++i) { | ||
auto item (perfdata->Get(i)); | ||
|
||
if (!item.IsObject()) { | ||
continue; | ||
} | ||
|
||
auto itemPerfdataValue (dynamic_pointer_cast<PerfdataValue>((Object::Ptr)item)); | ||
|
||
if (!itemPerfdataValue) { | ||
continue; | ||
} | ||
|
||
auto label (itemPerfdataValue->GetLabel()); | ||
|
||
for (auto& pattern : filterStrings) { | ||
if (Utility::Match(pattern, label)) { | ||
// continue 2; | ||
goto NextItem; | ||
} | ||
} | ||
|
||
perfdata->Remove(i--); | ||
|
||
NextItem:; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a good place to use std::remove_if
. That would avoid the need for goto
here and also has linear complexity (though questionably if anyone would notice a difference here).
@lippserd What do you think? Custom vars (as-is, |
FYI I personally prefer to close this and -depending on customers' needs- either do nothing at all or let the users do this by themselves via this feature as Julian described: #6937 (comment) |
The feature you refer to is not implemented iirc. |
This one here is neither merged. I prefer one feature you can use twice rather than two features. |
fixes #8124