Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

check_cpu.sh

Rating
5 votes
Favoured:
1
Hits
129173
Files:
FileDescription
check_cpu.shtext/plain
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
This shell script checks cpu utilization (user,system,iowait,idle in %) with iostat accepting seperate threshholds and returning the data in a format suitable for performance data processing
The script is based on the original script of Steve Bosek. I have modified it so it accepts different thresholds for user/system/iowait and prints output that can be automatically parsed by pnp performance data processing.
Reviews (5)
byaltmas5, May 31, 2018
It requires sysstat package for iostat
Hi
Is there any reason it print such a huge user percent of 5599%
nagios@cubic:~> ./chk_perf_cpu.sh -uw 70 -iw 95 -sw 85 -uc 80 -ic 98 -sc 95 -n 5
CPU CRITICAL : user=5599% system=10% iowait=88% idle=2% | cpu_user=5599%;70;80; cpu_sys=10%;85;95; cpu_iowait=88%;95;98; cpu_idle=2%;
nagios@cubic:~>
bygeuse, March 12, 2013
0 of 1 people found this review helpful
Good plugin. I use it on my job.

I found a little difference in my environment iostat results.

I'll try to explain it showing you modified lines:

1) idle parameter position:

CPU_IDLE=`echo $CPU_REPORT | cut -d ";" -f 7`

2) test for thresholds:

if [[ $CPU_IOWAIT > $IO_CPU_C || $CPU_USER > $U_CPU_C || $CPU_SYSTEM > $S_CPU_C ]];
then
echo "CPU CRITICAL : user=${CPU_USER}% system=${CPU_SYSTEM}% iowait=${CPU_IOWAIT}% idle=${CPU_IDLE}% | cpu_user=${CPU_USER}%;${U_CPU_W};${U_CPU_C}; cpu_sys=${CPU_SYSTEM}%;${S_CPU_W};${S_CPU_C}; cpu_iowait=${CPU_IOWAIT}%;${IO_CPU_W};${IO_CPU_C}; cpu_idle=${CPU_IDLE}%;"
exit $STATE_CRITICAL
fi

...and obviously for WARNING test.

P.S.
I use zLinux servers in OS/390 environment.
my uname is:
2.6.18-194.el5 #1 SMP Tue Mar 16 22:05:06 EDT 2010 s390x s390x s390x GNU/Linux

Hope it helps.
Paolo
byamitmund, August 2, 2012
1 of 1 people found this review helpful
The script is really good.

Just few updated needed:

as the new version is using vmstat and not iostat, so it would be nice to check vmstat:

here is my modification:

#IOSTAT=/usr/bin/iostat
VMSTAT=/usr/bin/vmstat

and the check:

# if [ ! -x $IOSTAT ]; then
if [ ! -x $VMSTAT ]; then
# echo "UNKNOWN: iostat not found or is not executable by the nagios user."
echo "UNKNOWN: vmstat not found or is not executable by the nagios user."
exit $STATE_UNKNOWN
fi
byMajed, July 17, 2011
2 of 2 people found this review helpful
works remotely through nrpe. can be graphed with pnp4nagios, does execute from command line ./check_cpu.sh but doesn't work locally when defined in nagios services and commands says (timeout) that's at least on gentoo.