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


Remember Me

Directory Tree

0 votes
Current Version
Compatible With
  • Nagios 3.x
  • Nagios 4.x
check_cpu.pyPython script
check_nrpe_cpu_check_cpu.phppnp4nagios template file
Network Monitoring Software - Download Nagios XI
Log Management Software - Nagios Log Server - Download
Netflow Analysis Software - Nagios Network Analyzer - Download
Python script that returns overall and per-core utilization monitoring. Supports graphing in pnp4nagios
Overall and per-core processor utilization monitoring with graphing in pnp4nagios

Python 2.6 or newer
python-psutils library installed

./ -w/--warn -c/--crit
-w / --warn = int value for warning level (overall only)
-c / --crit = int value for critical level (overall only)

1 - Intended to better monitor per-core CPU utilization of modern multi-core processors.
2 - Single cpu core alert will only issue a WARNING as a single core saturation event typically only impacts the application that is causing the core saturation.
3 - Per core monitoring and alerting allows a Sys Admin to locate and resolve cpu resource issues that may not show in overall use or system load checks
4 - Works with pnp4nagios graphing and should create a graph for overall cpu use, and one for each cpu core for tracking historical data
5 - Has not been tested on Nagios systems without pnp4nagios but it should work fine
6 - Script will detect number of CPU cores, there should be no limit to number of cores. You will get a graph for overall and one for each core detected in pnp4nagios

Add the following line to your /etc/nagios/nrpe.cfg file near the other command entries. Be sure to confirm the path the cudacheck script.
command[check_cpu]=/usr/lib64/nagios/plugins/ -w 95 -c 99

To call the script in Nagios with check_nrpe add the following service to the appropriate Nagios file
define service{
use linux-service,service-pnp
hosts list,of,comma,seperated,hostnames,goes,here
service_description CPU Utilization
servicegroups CPU
check_command check_nrpe!check_cpu

If you have SELinux enabled you'll need to run chcon command to allow this script to be executed by the Nagios NRPE plugin. An example is included below. Be sure to confirm the path before issuing the command.
chcon -t nagios_unconfined_plugin_exec_t /usr/lib64/nagios/plugins/

::pnp4nagios Template::
This template requires PHP 5.4 or newer, CentOS is still on PHP 5.3 as of this update. You can follow the webtatic repo upgrade process. I completed the upgrade to 5.6 without issue using it. (

A big thanks to George Hansper who wrote a php template for a script of his own. I was able to trim and re-use his template and it works great.