Hi Icinga team.
I’m looking on a solution for a “scenario” check which actually refers to other checks defined by a custom check attribute. Some of our monitoring probe providers put a “meaning” in the check output and we want to add a capability to define a match()
condition so that the calculated scenario can take this intro consideration. Not easy to explain, so let me show some code:
oPtrServiceCurrent = get_host(cSAddressHost)
if (oPtrServiceCurrent) {
/*if a STATE condition is defined in aSetCondMatrixEntry[3], then we compare against oPtrServiceCurrent.state*/
/* create closure function that has access to aSetCondMatrixEntry */
fFilterFunction = function(x) use(aSetCondMatrixEntry) { x == aSetCondMatrixEntry[3] }
if (aStateWord.filter(fFilterFunction).len() > 0) {
lIsCondMet=(aStateWord[oPtrServiceCurrent.state] == aSetCondMatrixEntry[3] && oPtrServiceCurrent.last_state_change < get_time() - number(aSetCondMatrixEntry[4])*60)
} else {
/*we check match against plugin oPtrServiceCurrent.output*/
lIsCondMet=( match(aSetCondMatrixEntry[3],oPtrServiceCurrent.output) && oPtrServiceCurrent.last_state_change < get_time() - number(aSetCondMatrixEntry[4])*60)
}
The code works well for state-compare but looks like as if oPtrServiceCurrent.output
is not a valid access:
Exception occurred while checking 'TEST!netm-scenario-SCO.xms_logscan2.check_monitoring': Error: Invalid field access (for value of type 'Service'): 'output'
Location: in /etc/icinga2/conf.d/icinga/servicegroups/common/services.conf: 260:46-260:70
/etc/icinga2/conf.d/icinga/servicegroups/common/services.conf(258): } else {
/etc/icinga2/conf.d/icinga/servicegroups/common/services.conf(259): /*we check match against plugin oPtrServiceCurrent.output*/
/etc/icinga2/conf.d/icinga/servicegroups/common/services.conf(260): lIsCondMet=( match(aSetCondMatrixEntry[3],oPtrServiceCurrent.output) && oPtrServiceCurrent.last_state_change < get_time() - number(aSetCondMatrixEntry[4])*60)
^^^^^^^^^^^^^^^^^^^^^^^^^
For sure it would be better to have independent checks per each scenario condition but we cannot get this from external check providers in acceptable time/effort so any Icinga DSL solution would be the saviour
Any idea ?
Best regards
Michael