You are here

Specifiying threshold values for check_cpu_stats on linux

2 posts / 0 new
Last post
sean cull
sean.cull's picture
Specifiying threshold values for check_cpu_stats on linux

I am trying to set critial and warning thesholds for check_cpu_stats. The test case is the Opesview appliance but I have also tried it on other CentOS boxes

The input string in the predefined check is

<code>-H $HOSTADDRESS$ -c check_cpu_stats -C '%NRPE_CERTIFICATES:1%' -k '%NRPE_CERTIFICATES:2%' -r '%NRPE_CERTIFICATES:3%' -y '%NRPE_CIPHERS:1%';</code>

The output is

<code>$ check_nrpe -H 'localhost' -c check_cpu_stats -C '' -k '' -r '' -y 'ADH-AES256-SHA:ADH-AES128-SHA' Output: OK: utilization:26.4%,guest:0.0%,guest_nice:0.0%,iowait:1.4%,irq:0.0%,nice:0.0%,softirq:0.3%,steal:0.0%,system:3.3%,user:21.5%|'guest'=0.00%;;;0;100 'guest_nice'=0.00%;;;0;100 'iowait'=1.38%;;;0;100 'irq'=0.00%;;;0;100 'nice'=0.00%;;;0;100 'softirq'=0.32%;;;0;100 'steal'=0.00%;;;0;100 'system'=3.26%;;;0;100 'user'=21.47%;;;0;100 'utilization'=26.43%;;;0;100 Errors: Return code: 0</code>

I have tried various combinations of -c but cannot get the correct syntax.
The script does seem to have some capability around thresholds

<code># Copyright 2015, Opsview Ltd
Joshua Griffiths &lt;

<code># Work out the exit code from the warning, critical and utilisation metric sub get_nagios_exit { my $value = shift; my $opts = shift; unless ($opts-&gt;{w} || $opts-&gt;{c}) { return 0; } if ($opts-&gt;{c} &amp;&amp; $value &gt; $opts-&gt;{c}) { return 2; } if ($opts-&gt;{w} &amp;&amp; $value &gt; $opts-&gt;{w}) { return 1; } return 0; }</code>

Ultimately I am trying to flag when the CPU utilization hits 100%

Can you advise on the required syntax please
Apologies for the formatting - con combination of text or html seems to work

jgriffiths's picture
check_cpu_stats via NRPE

Hi Sean,

The main issue I think you're having is with the arguments to 'check_nrpe' rather than 'check_cpu_stats'.

The warning/critical threshold values need to be passed from 'check_nrpe' using the '-a' flag.

You probably need to run something like this:

check_nrpe -H localhost -c check_cpu_stats -C '' -r '' -y 'ADH-AES256-SHA:ADH-AES128-SHA' -a "-c 90 -w 70"

The '-a' option at the end is the string which gets passed to the 'check_cpu_stats' command (so that's warning when CPU utilisation > 70 and critical when > 90).

So, in the service check configuration, you'd probably have something like this:

-H $HOSTADDRESS$ -c check_cpu_stats -C '%NRPE_CERTIFICATES:1%' -k '%NRPE_CERTIFICATES:2%' -r '%NRPE_CERTIFICATES:3%' -y '%NRPE_CIPHERS:1%' -a '-c 90 -w 70'

For the case you specifically mentioned (critical on 100% utilisation), you would want:

-H $HOSTADDRESS$ -c check_cpu_stats -C '%NRPE_CERTIFICATES:1%' -k '%NRPE_CERTIFICATES:2%' -r '%NRPE_CERTIFICATES:3%' -y '%NRPE_CIPHERS:1%' -a '-c 100'