Skip to content

Fix regexp check to match '^$' #12

@seriv

Description

@seriv

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, seriv@cd3c2b0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions