A check plugin for Nagios to monitor processes and their utilization of system resources.

https://github.com/thomasweaver/check_cpu_proc

This plugin takes in a process name and then uses the command ps to work out how much memory and cpu all the processes of that name are taking up in percentage. It will output performance data for CPU Usage Percentage, Memory Usage Percentage, VSZ, RSS and the number of processes of that name.

Options

Only the -p option is required all other options are optional.

-p allows you to specify the name of the process you want to monitor (REQUIRED)

-w specify a warning for CPU percentage utilization

-c specify a critical for CPU percentage utilization

-m specify a warning for Memory percentage utilization

-n specify a critical fro Memory percentage utilization

Examples

To monitor the apache processes and warn when the CPU uses over 20% and critical when over 30%

./check_cpu_proc.sh -p apache -w 20 -c 30

OK /usr/sbin/apache2 CPU: 0% MEM: 1.5% over 6 processes | proc=6 mem=1.5% cpu=0% rss=42116.0KB vsz=1274760.0KB

To monitor apache processes and warn when the CPU uses over 20% and critical when over 30% . Warn when memory is over 0.2% and Critical when memory is over 0.4%

./check_cpu_proc.sh -p apache -w 20 -c 30 -m 0.2 -n 0.4

CRITICAL /usr/sbin/apache2 CPU: 0% MEM: 1.5% over 6 processes | proc=6 mem=1.5% cpu=0% rss=42116.0KB vsz=1274760.0KB

To monitor nagios processes purely for performance data. i.e. no warning or criticals

./check_cpu_proc.sh -p nagios

OK /usr/lib/nagios/plugins/check_ping CPU: 0% MEM: 0% over 1 processes | proc=1 mem=0% cpu=0% rss=864.0KB vsz=12408.0KB

NOTE: this plugin doesn’t check whether the process is running and is purely for monitoring process utilization.

Nagios Graphs

Below is some examples of graphs created from the performance data output by the plugin:

The below graphs are of a apache process from a live system

Apache process vsz graph Apache process rss graph Apache number of processes graph Apache total amount of memory usage Apache total amount of CPU usage