Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Hoping you guys might be able to spot what i'm missing here. I'm not able to get a simple check_uptime plugin to work in Nagios.

When I invoke help for the plugin using:

/usr/local/nagios/libexec/check_uptime -h

the result is:

 usage: /usr/local/nagios/libexec/check_uptime [-c OPTION]

This script checks uptime and optionally verifies if the uptime
is below MINIMUM or above MAXIMUM uptime treshholds

OPTIONS:
-h Help
-c CRITICAL MIN uptime (minutes)
-w WARNING MIN uptime (minutes)
-C CRITICAL MAX uptime (minutes)
-W WARNING MAX uptime (minutes)
-V Version

So I tried to implement this plugin on both the nagios linux server and a linux client. I basically want the plugin to run on the remote machine named machine1 in the format

check_uptime -w 15 -c 30

The plugin executes fine on both the server and the client. The plugin also exists on both of them under /usr/local/nagios/libexec/check_uptime.

Here are my settings:

On the server:

I appended the following to /usr/local/nagios/etc/objects/commands.cfg

# 'check_uptime' command definition for linux hosts
define command{
        command_name    check_uptime
        command_line    $USER1$/check_uptime -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$
}

I appended the following to /usr/local/nagios/etc/objects/hosts/machine1.cfg:

 define service{
        use                             generic-service
        host_name                       machine1
        service_description             Uptime
        check_command                   check_uptime
}

On the machine1:

I'm appending this to /usr/local/nagios/etc/nrpe.cfg:

command[check_uptime]=/usr/local/nagios/libexec/check_uptime -w 15 -c 30

Then I'm testing the configuration on the server by running:

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

And I'm getting 0 warnings and 0 errors, yet in the Nagios console the service shows up as unknown.

alt text

What am I missing?

Thanks guys!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Nver mind. I figured it out.

Looks like I have to invoke check_nrpe in /usr/local/nagios/etc/objects/hosts/machine1.cfg as follows:

    define service{
        use                             generic-service
        host_name                       machine1
        service_description             Uptime
        check_command                   check_nrpe!check_uptime
}

Edit: It also looks that the check_uptime command should not be invoked with the -H $HOSTADDRESS$ parameter in commands.cfg on the server end. Once that is removed, it will work on the server.

Hope this helps somebody else.

share|improve this answer
    
For completeness: If you are using nrpe, and want to check something on a remote server that is not published over a port (i.e. number of procs, uptime, host time, load, etc) you will ALWAYS have to use "check_nrpe -H $HOSTADDRESS -p <nrpe port> -c <check_command> -a $ARG1 $ARG2 ..." (or some variation like "check_nrpe -H $HOSTADDRESS -p <nrpe port> -c $ARG1 -a $ARG2 ..."). <check_command> must be defined on the remote host nrpe config file. –  Torian Nov 30 '10 at 1:45
    
Thanks Torian. Let me see if I understand you correctly and have all the steps down. I have already defined <check_command> on the host's nrpe.cfg file. –  Bourne Nov 30 '10 at 17:55
    
Do you need to define that on the server's command.cfg at all as follows? ---> # 'check_uptime' command definition for linux hosts define command{ command_name check_uptime command_line $USER1$/check_uptime -H $HOSTADDRESS$ -p 12489 -w 15 -c 30 } I want to be able to use this to check uptime on the server as well and I can't get it to work even though it works on the client. –  Bourne Nov 30 '10 at 18:12
    
Basically, I'm confused about whether you define the specifics with the command itself on the server or whether that is done on the client and the server contains just a generic syntax for the command. –  Bourne Nov 30 '10 at 18:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.