NRPE: Command ‘check_cpu_stats’ not defined

If setting up an NRPE CPU check within Opsview Monitor and you see a check_cpu_stats error, this would indicate you are using an old agent version. Simply updating the agent would likely resolve the issue. However if this is not an option for you, try the following.

First you’ll need to get hold of the check_cpu_stats plugin. You can do this by pulling /usr/local/nagios/libexec/check_cpu_stats from an existing Opsview Monitor version 5.x instance or simply download it here:

$ wget https://pikedom.com/wp-content/uploads/2019/11/check_cpu_stats.pl

Either copy it to the server directly or use something like scp to move it:

$ scp -p -P1022 check_cpu_stats.pl [email protected]:/var/tmp/check_cpu_stats

Then on the server (you want to monitor), copy the file to /usr/local/nagios/libexec/:

andy@host1:~$ sudo cp -v /var/tmp/check_cpu_stats /usr/local/nagios/libexec/
`/var/tmp/check_cpu_stats' -> `/usr/local/nagios/libexec/check_cpu_stats'

Change the owning user to nagios:

andy@host1:~$ sudo chown -v nagios:nagios /usr/local/nagios/libexec/check_cpu_stats   
changed ownership of `/usr/local/nagios/libexec/check_cpu_stats' to nagios:nagios

And make sure the execution bit has been set:

andy@host1:~$ sudo chmod -v u+x /usr/local/nagios/libexec/check_cpu_stats
mode of `/usr/local/nagios/libexec/check_cpu_stats' changed to 0744 (rwxr--r--)

You need to make the agent aware of the plugin by editing the nrpe local configuration file:

andy@host1:~$ sudo vim /usr/local/nagios/etc/nrpe_local/opsera.cfg

Append the following line at the end of the file and save.

check_command[check_cpu_stats] = /usr/local/nagios/libexec/check_cpu_stats $ARG1$

Lastly, you will need to restart the agent:

andy@host1:~$ sudo /etc/init.d/opsview-agent restart              
Stopping opsview-agent opsview-agent
Starting opsview-agent opsview-agent

You can confirm that worked with the below command:

andy@host1:~$ /usr/local/nagios/libexec/check_nrpe -H localhost -c check_cpu_stats
OK: utilization:0.4%,iowait:0.0%,irq:0.0%,nice:0.0%,softirq:0.0%,steal:0.0%,system:0.1%,user:0.3%|'iowait'=0.01%;;;0;100 'irq'=0.00%;;;0;100 'nice'=0.00%;;;0;100 'softirq'=0.00%;;;0;100 'steal'=0.02%;;;0;100 'system'=0.06%;;;0;100 'user'=0.30%;;;0;100 'utilization'=0.38%;;;0;100

Be the first to comment

Leave a Reply