monitor cpu utilization

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
rahuliq
Posts: 16
Joined: Thu Mar 14, 2013 11:34 am

monitor cpu utilization

Post by rahuliq »

Hi

Is it possible to monitor CPU utilization with nagios.

Regards
Rahul
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: monitor cpu utilization

Post by slansing »

Yes it is, on what device are you looking to monitor CPU Utilization on? A Windows server, Linux server...etc?
rahuliq
Posts: 16
Joined: Thu Mar 14, 2013 11:34 am

Re: monitor cpu utilization

Post by rahuliq »

Linux server
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: monitor cpu utilization

Post by slansing »

You can definitely do this, the easiest way would be through NRPE. Please take a look at these pieces of documentation:

Overview: http://nagios.sourceforge.net/docs/nrpe/NRPE.pdf

This document will walk you through how to install NRPE on the Linux remote host, and how to set up a service configuration, and check command to check this host for it's CPU load. If you need additional guidance let us know!
rahuliq
Posts: 16
Joined: Thu Mar 14, 2013 11:34 am

Re: monitor cpu utilization

Post by rahuliq »

I have already setup nagios,nrpe and I'm monitoring the cpu load.

What I need to monitor is the %CPU utilization and also be able to graph it using something like pnp4nagios, nagiosgraph or cacti.

Regards
Rahul
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: monitor cpu utilization

Post by slansing »

Have you taken a look at integrating this plugin with your NRPE setup?:

http://exchange.nagios.org/directory/Pl ... ts/details

This provides a number of useful stats other than the standard Linux Load collection. You would simply place this plugin on the remote host, set up a command definition in the NRPE.cfg file on that server, and then call that command from the Nagios server using check_nrpe.
rahuliq
Posts: 16
Joined: Thu Mar 14, 2013 11:34 am

Re: monitor cpu utilization

Post by rahuliq »

I get the error NRPE: Unable to read output on the nagios web console

I placed the plugin in the folder /usr/local/nagios/libexec/
I placed the below command def in nrpe.cfg
command[check_cpu_utilization]=/usr/local/nagios/libexec/check_linux_stats.pl -C -w 90 -c 100 -s 5

Are there any perl modules that need to be installed
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: monitor cpu utilization

Post by slansing »

You may want to place $ARG1$ and $ARG2$ for example, in the -w and -c sections of the remote server's command definition to save some time if you decide to change the warning and critical values in the future, though, as you have it defined now, how are you calling the plugin from Nagios? From the command line? It is recommended to first test it from the command line and then add it into your configuration files to make sure it works before the final configuration steps.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: monitor cpu utilization

Post by lmiltchev »

I placed the plugin in the folder /usr/local/nagios/libexec/
I placed the below command def in nrpe.cfg
command[check_cpu_utilization]=/usr/local/nagios/libexec/check_linux_stats.pl -C -w 90 -c 100 -s 5

Are there any perl modules that need to be installed
Just to clarify - you placed the plugin and defined the command on the remote server, correct?

Try running it locally to make sure it works (before you even try using it with NRPE):

Code: Select all

./check_linux_stats.pl -C
You will have to install Sys-Statistics-Linux perl module prior to using it:

Code: Select all

yum install perl-Sys-Statistics-Linux -y
Be sure to check out our Knowledgebase for helpful articles and solutions!
rahuliq
Posts: 16
Joined: Thu Mar 14, 2013 11:34 am

Re: monitor cpu utilization

Post by rahuliq »

Thank you Guys

Worked after doing #yum install perl-Sys-Statistics-Linux -y

Also made a small change in the script check_linux_stats.pl

my $perfdata .= "|"
."user=$cpu->{user}% "
."system=$cpu->{system}% "
."iowait=$cpu->{iowait}% "
."InUse=$cpu_used%;$o_warning;$o_critical";

print "CPU $status : InUse $cpu_used% $perfdata";

so that it will return cpu used as opposed to %idle
Locked