how to see CPU usage consumption of a particular service
how to see CPU usage consumption of a particular service
i have fireeye installed on all my linux machines and we monitore the service (xagt) on nagios with no issue. Recently we noticed this service uses alot of CPU which has caused some problems so i was wondering if there is a way to monitor the cpu used by this service and get an alert? We are already monitoring general CPU of course but it does not tell which service causes it to rise.
Re: how to see CPU usage consumption of a particular service
Hello @rnjie
Thanks for reaching out, to do this you want to create a plugin script, and here is an example to edit from:
Perry
Thanks for reaching out, to do this you want to create a plugin script, and here is an example to edit from:
Thanks,#!/bin/bash
used_cpu=`ps -C xagt -o %cpu`
case $used_cpu in
[1-84]*)
echo "OK - $used_cpu% CPU used."
exit 0
;;
[85]*)
echo "WARNING - $used_cpu% CPU used."
exit 1
;;
[86-100]*)
echo "CRITICAL - $used_cpu% CPU used."
exit 2
;;
*)
echo "UNKNOWN - $used_cpu% CPU used."
exit 3.............etc....
Perry
Re: how to see CPU usage consumption of a particular service
Hi
Here's some more information
You could create a custom plugin as a shell script, something like:
If the above script was called proc_cpu.sh you could get the cpu % used by mysqld by running
You would have to format the output so it matches the standard plugin output format.
Here are some docs on plugins:
https://assets.nagios.com/downloads/nag ... ugins.html
https://assets.nagios.com/downloads/nag ... inapi.html
Once you have the plugin created you can run it on a remote system using NCPA:
https://www.nagios.org/ncpa/help.php?v= ... the-plugin
https://support.nagios.com/kb/article/n ... a-722.html
Thanks
Here's some more information
You could create a custom plugin as a shell script, something like:
Code: Select all
#!/bin/sh
mypid=`pidof $1`
ps -p $mypid -o %cpuCode: Select all
./proc_cpu mysqldHere are some docs on plugins:
https://assets.nagios.com/downloads/nag ... ugins.html
https://assets.nagios.com/downloads/nag ... inapi.html
Once you have the plugin created you can run it on a remote system using NCPA:
https://www.nagios.org/ncpa/help.php?v= ... the-plugin
https://support.nagios.com/kb/article/n ... a-722.html
Thanks