resmon
resmon copied to clipboard
Fix regexp check to match '^$'
I'd like to write check for nagios if a string result is empty, like
./check_resmon_metric -H myhost -M Core::SmfMaintenance -C services -m services -r '^$'
When curl shows this field is empty:
curl http://myhost:81/Core::SmfMaintenance/services
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/resmon.xsl"?><ResmonResults>
<ResmonResult module="Core::SmfMaintenance" service="services">
<last_runtime_seconds>0.089733</last_runtime_seconds>
<last_update>1338893241</last_update>
<metric name="count" type="i">0</metric>
<metric name="services" type="s"></metric>
</ResmonResult>
</ResmonResults>
the ./check_resmon_metric gives
./check_resmon_metric -H myhost -M Core::SmfMaintenance -C services -m services -r '^$'
Use of uninitialized value $value in pattern match (m//) at /etc/nagios3/CS.conf.d/check_resmon_metric line 378.
Use of uninitialized value $value in concatenation (.) or string at /etc/nagios3/CS.conf.d/check_resmon_metric line 383.
OK: resources -
and result in CRITICAL I propose to avoid false critical status check if $value is not defined and if so define as empty string, https://github.com/seriv/resmon/commit/cd3c2b0f1760c894075893ee7a6689eaa6fc2c6b