Page 1 of 1

Nagios plugin - check CPU performance : check_cpu_perf.sh

Posted: Mon Apr 27, 2015 11:36 pm
by perumalr
When the Server Timestamp goes 00:00:00, the plugin throws unknown alert - /usr/local/nagios/check_cpu_perf.sh: line 200: [: -lt: unary operator expected.

Did anyone out there faced this issue ? Any solution for this bug ?

Code: Select all

SARCPU=`/usr/bin/sar -P ALL|grep all|grep -v Average|tail -1`
…
…
SARCPUIDLE=`echo ${SARCPU}|awk '{print $8}'|awk -F. '{print $1}'`

++ awk -F. '{print $1}'
++ awk '{print $8}'
++ echo
+ SARCPUIDLE=
++ awk '{print "CPU Idle = " $8 "% | " "CpuUser=" $3 "; CpuNice=" $4 "; CpuSystem=" $5 "; CpuIowait=" $6 "; CpuSteal=" $7 "; CpuIdle=" $8""}'
++ echo
+ CPU='CPU Idle = % | CpuUser=; CpuNice=; CpuSystem=; CpuIowait=; CpuSteal=; CpuIdle='
+ '[' '' == false ']'
+ ALERT=true
+ '[' -lt 10 ']'
/usr/local/nagios/check_cpu_perf.sh: line 200: [: -lt: unary operator expected
+ '[' -lt 20 ']'
/usr/local/nagios/check_cpu_perf.sh: line 204: [: -lt: unary operator expected

Re: Nagios plugin - check CPU performance : check_cpu_perf.s

Posted: Tue Apr 28, 2015 11:15 am
by tmcdonald
Have you tried contacting the author? http://exchange.nagios.org/directory/Pl ... ce/details

We can certainly help troubleshoot, but I would suggest first reaching out to the author on Github for comment. Could be a simple fix that would take us a bit longer to find.