Page 1 of 1

check_nrpe with check_cpu_stats always returns OK on Linux

Posted: Thu Jul 17, 2014 2:49 pm
by brudnick
We are using the check_nrpe plugin to monitor our linux servers. no matter what arguments I put in for check_cpu_stats, it returns CPU STATISTICS OK.

sample command:
# /usr/local/nagios/libexec/check_nrpe -H serverName -t 30 -c check_cpu_stats -a '-w 85 -c 95'
example output
CPU STATISTICS OK: user=13.64% system=1.21% iowait=0.10% idle=85.05% | user=13.64% system=1.21% iowait=0.10%;85;95 idle=85.05%

So I tried with low thresholds like warn at 1% and critical at 2% and it returns OK.
# /usr/local/nagios/libexec/check_nrpe -H serverName -t 30 -c check_cpu_stats -a '-w 1 -c 2'
CPU STATISTICS OK: user=14.30% system=1.41% iowait=0.10% idle=84.19% | user=14.30% system=1.41% iowait=0.10%;1;2 idle=84.19%

I tried adding in % sign to see if that changed anything, it did not.
# /usr/local/nagios/libexec/check_nrpe -H serverName -t 30 -c check_cpu_stats -a '-w 1% -c 2%'
CPU STATISTICS OK: user=13.64% system=1.52% iowait=0.00% idle=84.85% | user=13.64% system=1.52% iowait=0.00%;1%;2% idle=84.85%

What is the proper syntax for this to actually get warnings?

NRPE agent on host machine is: NRPE v2.14

Nagios XI Version : 2014R1.2
NagiosServer 2.6.32-358.2.1.el6.x86_64 x86_64
CentOS release 6.5 (Final)
Gnome is not installed
Apache Information
PHP Version: 5.3.3
Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0
Server Name: NagiosServer
Server Address: x.x.x.x
Server Port: 80

Re: check_nrpe with check_cpu_stats always returns OK on Lin

Posted: Thu Jul 17, 2014 3:36 pm
by lmiltchev
What is the version of the plugin? Can you run the following command on the remote box from the CLI (plugins directory) and show us the output?

Code: Select all

./check_cpu_stats.sh -h

Re: check_nrpe with check_cpu_stats always returns OK on Lin

Posted: Thu Jul 17, 2014 4:25 pm
by brudnick
# CPU Utilization Statistics plugin for Nagios
#
# Written by : Steve Bosek ([email protected])
# Release : 1.3
# Creation date : 8 September 2007
# Revision date : 18 October 2007
# Package : DTB Nagios Plugin
# Description : Nagios plugin (script) to check cpu utilization statistics.
# This script has been designed and written on Unix plateform (Linux, Aix),
# requiring iostat as external program. The locations of these can easily
# be changed by editing the variables $IOSTAT at the top of the script.
# The script is used to query 4 of the key cpu statistics (user,system,iowait,idle)
# at the same time. Note though that there is only one set of warning
# and critical values for iowait percent.
#
# Usage : ./check_cpu_stats.sh [-w <warn>] [-c <crit]

Re: check_nrpe with check_cpu_stats always returns OK on Lin

Posted: Thu Jul 17, 2014 4:32 pm
by brudnick
Here are attempts i just tried with a machine that has iowait above 10% seeing that it only accounts for iowait as per the comments on the command

# /usr/local/nagios/libexec/check_nrpe -H serverName -t 30 -c check_cpu_stats -a '-w 1% -c 2%'
CPU STATISTICS OK: user=36.53% system=1.89% iowait=19.20% idle=42.38% | user=36.53% system=1.89% iowait=19.20%;1%;2% idle=42.38%

# /usr/local/nagios/libexec/check_nrpe -H serverName -t 30 -c check_cpu_stats -a '-w 1 -c 2'
CPU STATISTICS OK: user=39.15% system=2.50% iowait=21.87% idle=36.48% | user=39.15% system=2.50% iowait=21.87%;1;2 idle=36.48%

# /usr/local/nagios/libexec/check_nrpe -H serverName -t 30 -c check_cpu_stats -a '-w 98% -c 99%'
CPU STATISTICS OK: user=36.42% system=2.82% iowait=22.70% idle=38.06% | user=36.42% system=2.82% iowait=22.70%;98%;99% idle=38.06%

# /usr/local/nagios/libexec/check_nrpe -H serverName -t 30 -c check_cpu_stats -a '-w 98 -c 99'
CPU STATISTICS OK: user=47.16% system=3.44% iowait=18.81% idle=30.60% | user=47.16% system=3.44% iowait=18.81%;98;99 idle=30.60%

Re: check_nrpe with check_cpu_stats always returns OK on Lin

Posted: Thu Jul 17, 2014 4:43 pm
by abrist
Could you run the check from the cli without any threshold args? I am curious if there are any errors in the check:

Code: Select all

./check_cpu_stats.sh

Re: check_nrpe with check_cpu_stats always returns OK on Lin

Posted: Fri Jul 18, 2014 3:33 pm
by brudnick
]# /usr/local/nagios/libexec/check_nrpe -H serverName -t 30 -c check_cpu_stats
CPU STATISTICS OK: user=18.25% system=1.77% iowait=13.72% idle=66.26% | user=18.25% system=1.77% iowait=13.72%;30;100 idle=66.26%

Re: check_nrpe with check_cpu_stats always returns OK on Lin

Posted: Fri Jul 18, 2014 9:02 pm
by Box293
brudnick wrote:# CPU Utilization Statistics plugin for Nagios
#
# Written by : Steve Bosek ([email protected])
# Release : 1.3
Version 2.3.6 of this plugin is available on the Nagios Exchange:
http://exchange.nagios.org/directory/Pl ... sh/details

NOTE: The warning and critical arguments have changed:

Code: Select all

check_cpu_stats.sh Revision 2.3.6 - CPU Utilization check script for Nagios

Usage: check_cpu_stats.sh -w -c (-i -n)

  -w  Warning threshold in % for warn_user,warn_system,warn_iowait CPU (default : 70,40,30)
  Exit with WARNING status if cpu exceeds warn_n
  -c  Critical threshold in % for crit_user,crit_system,crit_iowait CPU (default : 90,60,40)
Example:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H 10.25.13.1 -c check_cpu_stats -a '-w 70,40,30 -c 90,60,40'
CPU STATISTICS OK : user=23.96% system=20.83%, iowait=0.00%, idle=55.21%, nice=0.00%, steal=0.00% | CpuUser=23.96%;70;90;0; CpuSystem=20.83%;40;60;0; CpuIowait=0.00%;30;40;0; CpuIdle=55.21%;0;0;0; CpuNice=0.00%;0;0;0; CpuSteal=0.00%;0;0;0;
Also, I tested this on CentOS and I needed to install ksh first.
yum install ksh