bash - Nagios Output Formatting -
short version:
is there better way of writing check below?
./check_snmp -h x.x.x.x -o oidstring -c public | awk '{print $4}' | sed 's/.$/.&/' | sed -e 's/$/ kb/'
long version:
i have nagios service check outputs 3 digit number:
./check_snmp -h x.x.x.x -o oidstring -c public snmp ok - 711 | iso.oidstring=711
this have done format liking , give accurate value:
./check_snmp -h x.x.x.x -o oidstring -c public | awk '{print $4}' | sed 's/.$/.&/' | sed -e 's/$/ kb/' 71.1 kb
the output perfect , can run command within centos environment without issue, when attempting implement check within nagios, service not return , value , instead (no output on stdout).
strangely, can perform service test check within nagios successfully, page displays host , service values 1 gives (no output on stdout).
i think nagios doesn't way i'm attempting format output, @ least on web side of things.
is there 'neater' way of writing check above?
thanks in advance.
you can using either single sed (uses dash anchor):
... | sed 's/^.*- \([0-9]*\)\([0-9]\) .*$/\1.\2 kb/'
or single awk:
... | awk '{printf "%s kb\n", $4/10}'
Comments
Post a Comment