Check threshold and filter keywords against attributes#412
Conversation
checkThresholdKeywordsAgainstAttributeNames -> this prints to log about keywords that are used in thresholds, but are not defined in check attributes. they are not fatal to the check, as thresholds can work on perfdata metric labels as well checkFilterKeywordsAgainstAttributeNames -> this does the same against filter now, afaik filters only work on attribute names, so using a wrong keyword means a user problem. this is fatal for the check call these two functions after parsing the arguments of a check, and before running it other fixes: switch to using ConditionList.GetListOfKeywords in CheckData.GetAllThresholdKeywords fix ConditionList.GetListOfKeywords adding empty keywords, group conditions have empty keywords
it was already being added to entry, but was not written in the check definition. it uses a default filter 'temperature != 0 and temperature != 1' and tests were failing since 'temperature' is not in attribute list
…ly perform them if chk.argsPassthrough is false this means security checks are done first, then semantic checks. also fixes some of the failing tests
|
Some examples: |
|
I like this, but maybe we can slightly adjust the output, e.g.: Same for ok/warning/ critical condition |
|
i guess this currently won't work with some checks, ex.:
I like the idea, but this potentially breaks some checks if we are not careful. Might be a good idea to add tests somehow, which test if there are elements in the dataList which are |
…amed attributes can be defined using regex. use these in conjunction with fixed attribute names when checking for keywords in the condition string add extra filter args to check_logfile 'column*' and check_wmi '.*'
check_drivesize: flags, letter, opts check_logfile: column (adjusted regex) check_memory: physical, swap, committed, virtual check_os_updates: old_version, repository, arch, prefix check_pdf: name
…-filter-keywords-against-attributes
|
Added a regex list called extraFilterAttributes to the checkData, which stores regexes. CheckFilterKeywordsAgainstAttributeNames now appends the attribute names and extraFilterAttributes to a regex list, and then checks the keywords against it. If it doesnt match any regex, it is considered extra. Then I used AI to discover unfixed, dynamically added attributes to the list. These are generally not documented, mostly because they are specific to a platform. It would be nice to document them, since we instruct user to run with --help, then they would be printed out. If they are specific to a platform, the description can mention it. The problem is, I am unsure if the AI pass added everything. check_drivesize: flags, letters, opts Also adjusted the output, shows the first wrong keyword like @lgmu wanted: |
add two sanity functions to check:
checkThresholdKeywordsAgainstAttributeNames -> this prints to log about keywords that are used in thresholds, but are not defined in check attributes. they are not fatal to the check, as thresholds can work on perfdata metric labels as well
checkFilterKeywordsAgainstAttributeNames -> this does the same against filter now, afaik filters only work on attribute names, so using a wrong keyword means a user problem. this is fatal for the check, prevents it from working and returns critical.
call these two functions after parsing the arguments of a check, after security check, and before running it. only called if chk.argsPassthrough is false
other fixes:
switch to using ConditionList.GetListOfKeywords in CheckData.GetAllThresholdKeywords. no need to use helper function when the ConditionList class has a member function, or whatever they are called in golang
fix ConditionList.GetListOfKeywords adding empty keywords, group conditions have empty keywords
add 'temperature' to the attribute list of check_temperature. it was already being added to entry, but was not written in the check definition, it uses a default filter 'temperature != 0 and temperature != 1' and tests were failing since 'temperature' is not in attribute list