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 Performance

Rating
7 votes
Favoured:
0
Current Version
1.2
Last Release Date
2011-09-08
Compatible With
  • Nagios 3.x
  • Nagios 4.x
  • Nagios XI
Twitter Handle
skywalka
License
GPL
Hits
160746
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!
Nagios plugin to check CPU performance statistics.

This script has been tested on the following Linux and Unix platforms:
RHEL 4, RHEL 5, RHEL 6, CentOS 4, CentOS 5, CentOS 6, SUSE, Ubuntu, Debian, AIX 5, AIX 6, FreeBSD 7, Solaris 8, Solaris 9 and Solaris 10.

The script is used to obtain key CPU performance statistics by executing the sar command;
eg. user, system, iowait, steal, nice, idle

The Nagios Threshold test is based on CPU idle percentage only, this is NOT CPU used.

Note for AIX Servers :-
The percentage of 'idle' CPU is calculated by dividing 'physc' by 'Maximum Capacity' where:
* physc indicates the number of physical processors consumed by the logical processor
* Maximum Capacity is the maximum number of processing units this LPAR was defined to ever have.

Support has been added for Nagios Plugin Performance Data for integration with Splunk, NagiosGrapher, PNP4Nagios,
opcp, NagioStat, PerfParse, fifo-rrd, rrd-graph, etc

USAGE: ./check_cpu_perf.sh {warning} {critical}

Example: ./check_cpu_perf.sh 20 10
OK: CPU Idle = 84.10% | CpuUser=12.99; CpuNice=0.00; CpuSystem=2.90; CpuIowait=0.01; CpuSteal=0.00; CpuIdle=84.10:20:10

Note: the option exists to NOT test for a threshold. Specifying 0 (zero) for both warning and critical will always return an exit code of 0.
Reviews (4)
./check_cpu_perf.sh: line 200: [: -lt: unary operator expected

WHen ever we get this, i just login to the server & run sar, then the data populates & the service checks gets OK.

Is there any resolution for this bug ?
bySimona Miroiu, February 6, 2014
Added package format for Amazon Linux & it works like a charm !
Not sure what I am doing wrong but I took this scrpit and running it without changing anything from command like and i am getting this error and its not returning any values

nagios@cubic:~> ./check_CPU_Perf.sh 20 10
./check_CPU_Perf.sh: line 200: [: -lt: unary operator expected
./check_CPU_Perf.sh: line 204: [: -lt: unary operator expected
OK: i686
nagios@cubic:~>

While sar is executable and can be executed by user nagios
nagios@cubic:~> sar -u
Linux 2.4.19-64GB-SMP (cubic) 05/13/2013

12:00:00 AM CPU %user %nice %system %idle
12:10:00 AM all 3.15 0.00 0.97 95.88
12:20:00 AM all 4.15 0.04 1.11 94.70
12:30:00 AM all 3.69 0.00 0.97 95.34
12:40:00 AM all 3.22 0.00 0.87 95.91
12:50:00 AM all 3.16 0.00 0.90 95.94
01:00:00 AM all 2.95 0.00 0.88 96.17
01:10:00 AM all 7.66 1.98 3.88 86.48
01:20:00 AM all 3.91 0.00 1.14 94.95
01:30:00 AM all 2.84 0.00 0.89 96.27
01:40:00 AM all 2.98 0.00 0.86 96.16
01:50:00 AM all 2.98 0.00 0.96 96.06
02:00:00 AM all 2.91 0.00 0.89 96.20
02:10:00 AM all 2.66 0.00 0.86 96.48
02:20:00 AM all 2.73 0.00 0.83 96.44
02:30:00 AM all 2.99 0.00 1.13 95.88
02:40:00 AM all 1.96 0.00 0.72 97.32
02:50:00 AM all 2.21 0.00 0.74 97.04
03:00:00 AM all 2.81 0.00 0.83 96.36
03:10:00 AM all 3.02 0.00 0.89 96.09
03:20:00 AM all 2.71 0.00 0.79 96.50
03:30:00 AM all 2.97 0.00 0.87 96.16
03:40:00 AM all 2.41 0.00 0.76 96.83
03:50:00 AM all 2.31 0.00 0.72 96.97
04:00:00 AM all 2.18 0.00 0.71 97.11
04:10:00 AM all 2.20 0.00 0.73 97.07
04:20:00 AM all 1.97 0.00 0.71 97.31
04:30:00 AM all 2.61 0.00 0.85 96.53
04:40:00 AM all 2.23 0.00 0.71 97.06
04:50:00 AM all 2.11 0.00 0.69 97.20
05:00:00 AM all 2.46 0.00 0.81 96.73
05:10:00 AM all 2.30 0.00 0.73 96.98
05:20:00 AM all 2.09 0.00 0.69 97.22
05:30:00 AM all 2.39 0.00 0.78 96.83
05:40:00 AM all 2.28 0.00 0.74 96.98
05:50:01 AM all 2.17 0.00 0.71 97.12
06:00:01 AM all 1.99 0.00 0.69 97.32
06:10:00 AM all 3.82 0.00 0.81 95.37
06:20:00 AM all 5.94 0.00 1.07 92.99
06:30:00 AM all 2.21 0.00 0.72 97.08
06:40:00 AM all 3.48 0.00 1.24 95.28
06:50:00 AM all 2.53 0.00 0.76 96.71
07:00:00 AM all 2.30 0.00 0.72 96.98
07:10:00 AM all 2.91 0.00 0.93 96.16
07:20:00 AM all 3.54 0.00 0.95 95.51
07:30:00 AM all 2.65 0.00 0.86 96.49
07:40:00 AM all 3.02 0.00 0.96 96.02
07:50:00 AM all 2.90 0.00 0.86 96.24
08:00:00 AM all 3.28 0.00 0.95 95.77
08:10:00 AM all 3.45 0.00 1.09 95.46
08:20:00 AM all 3.46 0.00 1.02 95.52
08:30:00 AM all 4.98 0.00 1.27 93.75

08:30:00 AM CPU %user %nice %system %idle
08:40:00 AM all 5.69 0.00 1.54 92.78
08:50:00 AM all 6.98 0.00 1.63 91.38
09:00:00 AM all 7.73 0.00 1.94 90.32
09:10:00 AM all 7.65 0.00 1.97 90.37
09:20:00 AM all 8.12 0.00 2.09 89.78
09:30:01 AM all 12.55 0.00 2.46 84.99
09:40:00 AM all 13.31 0.00 2.49 84.19
09:50:00 AM all 11.41 0.00 2.56 86.03
10:00:00 AM all 9.41 0.00 2.37 88.21
10:10:01 AM all 10.06 0.00 2.34 87.60
10:20:00 AM all 9.69 0.00 2.37 87.94
10:30:00 AM all 10.86 0.00 2.55 86.59
Average: all 4.21 0.03 1.17 94.59
nagios@cubic:~>
byMajed, July 17, 2011
great except that ot doesn't work on gentoo other than that garphs on pnp4nagios and produces output through nrpe.
Owner's reply

I'd be happy to have a crack at making it work on gentoo if you have a test box available :)