Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
rjmon
Posts: 106 Joined: Wed Dec 06, 2017 11:39 am
Post
by rjmon » Fri Jun 08, 2018 12:10 pm
This plugin is failing on RHEL 6.9
Code: Select all
$ bash -version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
./check_cpu_perf.sh: line 200: [: -lt: unary operator expected
./check_cpu_perf.sh: line 204: [: -lt: unary operator expected
Code: Select all
199 #Display CPU Performance with alert
200 if [ ${SARCPUIDLE} -lt $2 ]
201 then
202 echo "CRITICAL: $CPU"
203 exit 2
204 elif [ $SARCPUIDLE -lt $1 ]
205 then
206 echo "WARNING: $CPU"
207 exit 1
208 else
209 echo "OK: $CPU"
210 exit 0
211 fi
cdienger
Support Tech
Posts: 5045 Joined: Tue Feb 07, 2017 11:26 am
Post
by cdienger » Fri Jun 08, 2018 1:24 pm
One of the two variables in the if statement isn't set properly.From the output it looks like it's probably ${SARCPUIDLE}. You can use "set -xv" before and "set +xv" after this section to enable some debugging.
http://tldp.org/LDP/Bash-Beginners-Guid ... 02_03.html
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new
Privacy Policy .
rjmon
Posts: 106 Joined: Wed Dec 06, 2017 11:39 am
Post
by rjmon » Mon Jun 11, 2018 7:23 am
Here is the debug.. I think it is failing because of that log file is missing..
Code: Select all
$ ./check_cpu_perf.sh 20 10
Cannot open /var/log/sa/sa11: No such file or directory
if [ ${SARCPUIDLE} -lt $2 ]
then
echo "CRITICAL: $CPU"
exit 2
elif [ $SARCPUIDLE -lt $1 ]
then
echo "WARNING: $CPU"
exit 1
else
echo "OK: $CPU"
exit 0
fi
+ '[' -lt 10 ']'
./check_cpu_perf.sh: line 201: [: -lt: unary operator expected
+ '[' -lt 20 ']'
./check_cpu_perf.sh: line 205: [: -lt: unary operator expected
+ echo 'OK: CPU Idle = % | CpuUser=; CpuNice=; CpuSystem=; CpuIowait=; CpuSteal=; CpuIdle=:20:10'
OK: CPU Idle = % | CpuUser=; CpuNice=; CpuSystem=; CpuIowait=; CpuSteal=; CpuIdle=:20:10
+ exit 0
rjmon
Posts: 106 Joined: Wed Dec 06, 2017 11:39 am
Post
by rjmon » Mon Jun 11, 2018 8:39 am
Issue is resolved. This was due to sar service was not started after our recent patch.
tmcdonald
Posts: 9117 Joined: Mon Sep 23, 2013 8:40 am
Post
by tmcdonald » Mon Jun 11, 2018 9:34 am
Great to hear it! Did you have further (related) questions or are we good to lock this up?
Former Nagios employee
rjmon
Posts: 106 Joined: Wed Dec 06, 2017 11:39 am
Post
by rjmon » Mon Jun 11, 2018 9:53 am
Thanks. I am good you can close this.