CPU Usage and Load

check_cpu.sh

Description:

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

Current Version

Last Release Date

June 15, 2009

Compatible With


Project Files
Project Notes
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) Add a Review
Really useful
by altmas5, May 31, 2018

It requires sysstat package for iostat



User% seems to be bit off
by jabbasi, May 31, 2013

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:~>



plugin does not match some iostat results in OS/390 zLinux
by geuse, March 31, 2013

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



Few updated needed on the new version
by amitmund, August 31, 2012

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



almost great
by Majed, July 31, 2011

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.



Add a Review

You must be logged in to submit a review.

Thank you for your review!

Your review has been submitted and is pending approval.

Recommend

To:


From:


Thank you for your recommendation!

Your recommendation has been sent.

Project Stats
Rating
4.2 (5)
Favorites
1
Views
129,234