Page 1 of 1

Top 3 processes consuming CPU

Posted: Wed Mar 06, 2019 2:41 am
by linearstack
How can we get the information of Top 3 Processes consuming CPU using wmi and snmp in NagiosXI??

Can we use any plugin or shell script to get this information?

Re: Top 3 processes consuming CPU

Posted: Wed Mar 06, 2019 3:22 pm
by cdienger
I'm not certain about snmp or vmi, but here is a powershell script:

https://exchange.nagios.org/directory/P ... 29/details

I think it will need to be slightly modified on line 33 to return top three:

Code: Select all

	$cpuhog = (get-process -computername $servername | sort-object CPU -descending | select-object -first 3)
and a shell script:

https://exchange.nagios.org/directory/P ... es/details

again needing a slight modification on line 201:

Code: Select all

COMMAND=`UNIX95= ps -e -o pcpu,comm,pid | sort -n -r | grep -v "%CPU" | head -3`
and 205:

TOPFIVE="Top 3 CPU Processes(cpu%,pname,pid):" ;

Re: Top 3 processes consuming CPU

Posted: Tue Mar 19, 2019 11:23 pm
by linearstack
Will this work as a plugin?

let's suppose, I save this script in Nagios host. Can we set some parameters using nagios GUI interface in a way that whenever we receive a Warning/Critical alert, this script will flick another alert stating the top5 processes consuming memory/ CPU.
????

Re: Top 3 processes consuming CPU

Posted: Wed Mar 20, 2019 11:33 am
by lmiltchev
Are you trying to monitor the "top 3" most CPU intensive processes on a remote machine (Windows, Linux, etc.) or on the Nagios XI server itself? Can you clarify?

With any 3rd party plugin (that is not included in XI by default), the process would be the same:

1. Test the plugin from the command line to make sure it works as expected
2.Define a command in Nagios XI
3. Add a service
4. Verify your service is working

For more information please review our official documentation on managing plugins in Nagios XI here:

https://assets.nagios.com/downloads/nag ... ios-XI.pdf