Nagios Plugin to determine CPU load due to running process

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
kaushalshriyan
Posts: 119
Joined: Fri May 22, 2015 7:12 am

Nagios Plugin to determine CPU load due to running process

Post by kaushalshriyan »

Hi,

I usually get Current Load is WARNING Email,Slack and SMS Notification alerts. Is there a way to tell which linux process is causing cpu load for example -> WARNING - load average: 5.86, 5.68, 5.54

Is it httpd or backup or nginx or ..... process which is causing load. Any Nagios plugin which can provide this functionality.

Thanks in Advance.

Regards,

Kaushal
dwasswa

Re: Nagios Plugin to determine CPU load due to running proce

Post by dwasswa »

The check_procs command should help you achieve that...Please follow link below for more details..


https://nagios-plugins.org/doc/man/check_procs.html

Also see:
Usage:
check_procs -w <range> -c <range> [-m metric] [-s state] [-p ppid]
[-u user] [-r rss] [-z vsz] [-P %cpu] [-a argument-array]
[-C command] [-k] [-t timeout] [-v]

Options:
-h, --help
Print detailed help screen
-V, --version
Print version information
--extra-opts=[section][@file]
Read options from an ini file. See
https://www.nagios-plugins.org/doc/extra-opts.html
for usage and examples.
-w, --warning=RANGE
Generate warning state if metric is outside this range
-c, --critical=RANGE
Generate critical state if metric is outside this range
-m, --metric=TYPE
Check thresholds against metric. Valid types:
PROCS - number of processes (default)
VSZ - virtual memory size
RSS - resident set memory size
CPU - percentage CPU
ELAPSED - time elapsed in seconds
-t, --timeout=INTEGER
Seconds before plugin times out (default: 10)
-v, --verbose
Extra information. Up to 3 verbosity levels
-T, --traditional
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Nagios Plugin to determine CPU load due to running proce

Post by dwhitfield »

@Derick Wasswa is correct, but if you are asking if there is a plugin that can get total load and then if it's high check which processes are high, I am not aware of such a check. That said, the logic isn't particularly hard. You could just write a wrapper around check_load and check_procs, if you wanted a single check.
kaushalshriyan
Posts: 119
Joined: Fri May 22, 2015 7:12 am

Re: Nagios Plugin to determine CPU load due to running proce

Post by kaushalshriyan »

Hi Derick Wasswa,

Thanks for your reply and really appreciated for your guidance. I did ran the below command but it only tells 1 crit,1 warn out of 325 processes. But it does not indicate the process name
./check_procs -w 10 -c 20 --metric=CPU
CPU CRITICAL: 1 crit, 1 warn out of 325 processes | procs=325;;;0; procs_warn=1;;;0; procs_crit=1;;;0;
Please suggest further.

Regards,

Kaushal
dwasswa

Re: Nagios Plugin to determine CPU load due to running proce

Post by dwasswa »

Hi @ kaushalshriyan,

The linux command bellow will show you the top 10 processes that are consuming the most memory.
ps aux --sort=-%mem | awk 'NR<=10{print $0}'

ps and sort to get the process using the most memory....
ps -eo pmem,pcpu,rss,vsize,args | sort -k 1 -r | less


Try those and let me know if you have any other questions....
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Nagios Plugin to determine CPU load due to running proce

Post by tmcdonald »

Thanks for the assist, @Derick Wasswa! OP, let us know if you need further assistance.
Former Nagios employee
Locked