Page 1 of 1

Nagios Plugin to determine CPU load due to running process

Posted: Tue Aug 29, 2017 2:52 am
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

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

Posted: Tue Aug 29, 2017 12:33 pm
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

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

Posted: Tue Aug 29, 2017 2:10 pm
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.

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

Posted: Thu Aug 31, 2017 1:22 am
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

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

Posted: Thu Aug 31, 2017 1:23 pm
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....

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

Posted: Thu Aug 31, 2017 3:29 pm
by tmcdonald
Thanks for the assist, @Derick Wasswa! OP, let us know if you need further assistance.