user7077195
user7077195

Reputation: 7

Nagios Monitoring check_cpu script

I really need a script for Nagios to monitor the cpu usage on the remote hosts I have this command but it does not work

# 'check_cpu' command definition 
# w = Warning level (if CPU % idle falls below this level - must be a percentage) 
# c = Critical level

define command{ 
command_name check_cpu 
command_line $USER1$/check_cpu -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p $USER3$ 
}


vi  /etc/nagios/nrpe.cfg
command[check_uptime]=/usr/local/nagios/libexec/check_uptime

Upvotes: 1

Views: 3188

Answers (1)

Nagios Support
Nagios Support

Reputation: 561

I'm a bit confused here. Your two commands are unrelated.

You need to check cpu on a remote host via NRPE? First, is NRPE installed on the remote host? Is check_nrpe plugin installed on the Nagios server?

I'm going to assume that you have NRPE loaded on the remote server (since you listed a check_uptime command in the NRPE configuration file). This means at the very least you'll need to use the check_nrpe command to grab the data you need.

On the remote host in /etc/nagios/nrpe.cfg there should be a few other commands hopefully, maybe something like:

command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200

If for some reason there isn't, you're going to need to do some reading. This is a good document to start with.

Then, on your Nagios server you can define a service using the check_nrpe like this:

define service {
    use generic-service
    host_name remotehost
    service_description CPU Load
    check_command check_nrpe!check_load
}

Now, to wrap all this up with a quick and hopefully comprehensive explanation of how NRPE works with Nagios:

  • You define a host as a remote host
  • You need your checks to run locally on that remote host, and instead of grabbing SNMP or using check_ssh you decide to use NRPE
  • You need a plugin that can tell the remote host what to do in a well formed and documented way
  • Enter check_nrpe: check_nrpe communicates via NRPE to the remote host (where it HAS to be installed)
  • There are some predefined commands on the remote host side (and you can add as many as you like!) commands like check_uptime, check_load
  • Now that you know the commands that are specified on the remote side, you use those commands as arguments to check_nrpe on the Nagios side

Hope this helped!

Upvotes: 1

Related Questions