Check cpu usage with %

Hello
I have a really issue , i have a rizing on CPU on my linux server, the problem is when using procs module he gets me the number of process but i want to know the average of CPU with % so i used the check_load module but he only gets me the load average and not the CPU average of my system
i have used the check_load module with that configuration

apply Service “System Load” {
check_command = “load”
command_endpoint = host.vars.client_endpoint
vars.notification[“mail”] = {
groups = [ “icingaadmins” ]
users = [“icingaadmin”]
}
enable_notifications = true
vars.notification_type = “email”
assign where host.vars.client_endpoint
}

my check_procs services is here:

apply Service “procs” {
import “generic-service”
check_command = “procs”
vars.procs_warning = “800”
vars.procs_critical = “900”
vars.procs_metric = “CPU”
command_endpoint = host.vars.client_endpoint
assign where host.vars.client_endpoint
vars.notification[“mail”] = {
groups = [ “icingaadmins” ]
users = [“icingaadmin”]
}
}

the result is the number of process and not the % of CPU ,
Please does anyone have answer of that ? what should i do to get the % of CPU to define the warning and critical number
Thanks

Hello , Any help please ???
does anyone faced the same issue !!
THanks

Hi,

this is not the correct check to monitor the cpu usage in percentage.
This check, checks if a running process consumes x % of the cpu.

check_procs -w 10 -c 20 --metric=CPU
Alert if CPU of any processes over 10% or 20%

Check the check_procs man page for future infos.

To monitor the cpu usage in percentage you need a “custom” script for that, as it’s not shipped with the monitoring-plugins.

Example: check_cpu_usage :: Icinga Exchange

PS: This forum works on the basis of people answering because they want to help and bumping is generally seen as rude.

Greetz

Hi ,
I have used the same things writing as you told me but the script is not working on my case
PS: I appologies if you see this bumping as a rude thing it was only an urgent way because i had an overflow of CPU .
Cordially

Hi,

you need to define a new CheckCommand yourself to be able to assign/execute the check.

Check the docs for more infos on howto setup one.
As example this is the definition for the check_procs command.

If you need help just ask and show us what you have done so far.

Greetz

Hello , I did what you’v told me but i always face this error even the perl nagio plugins are installed

Can't locate Monitoring/Plugin.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./check_cpu_usage line 41.
BEGIN failed--compilation aborted at ./check_cpu_usage line 41.

Any suggestion ?
Best Regard .

Hi,

i assume you are using debian/ubuntu? - you need the libmonitoring-plugin-perl package.

I tested the plugin and you also need to edit line 251 from

my $np = Nagios::Plugin->new(

to

my $np = Monitoring::Plugin->new(

Or you use the newest version from github: https://github.com/iamcheko/check_cpu_usage/blob/master/libexec/check_cpu_usage

Output with sudo /usr/lib/nagios/plugins/check_cpu_usage -d:

Linux CPU Usage OK - CPU (user=1.38) (system=0.16) (idle=98.38) (iowait=0.08) (steal=0.00), CPU0 (user=0.97) (system=0.32) (idle=98.71) (iowait=0.00) (steal=0.00), CPU1 (user=1.96) (system=0.33) (idle=97.71) (iowait=0.00) (steal=0.00), CPU2 (user=1.29) (system=0.00) (idle=98.39) (iowait=0.00) (steal=0.00), CPU3 (user=1.30) (system=0.00) (idle=98.70) (iowait=0.00) (steal=0.00) | cpu_user=1.37763371150729%;; cpu_nice=0%;; cpu_system=0.162074554294976%;; cpu_idle=98.3792544570502%;; cpu_iowait=0.0810372771474878%;; cpu_irq=0%;; cpu_softirq=0%;; cpu_steal=0%;; cpu_guest=0%;; cpu_guest_nice=0%;; cpu_nyd1=0%;; .....

This was just an example plugin to use, you can google for other plugins that fits your needs.

Greetz

I use check_cpu_stats on my machines and set thresholds accordingly. There might be several versions around, not sure which source is the official upstream (if there’s any).
But here’s one version on Github: