Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

-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
up vote 2 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

Just thought I would put my two cents in I am using Nagios Core 4.08 and in my commands.cfg file I used it like this:

# comment: `check_uptime` this is to check system up time on linux boxes

define command {
    command_name check_uptime
    command_line $USER1$/check_uptime

Then in the host1.cfg I did the following:

# comment: Check uptime of the server

define service{
    use                             local-service
    host_name                       host1
    service_description             Uptime
    check_command                   check_uptime

And the result was this:

OK  06-23-2015 07:52:48 0d 0h 4m 19s    1/4 Uptime OK: 7 day(s) 23 hour(s) 5 minute(s) 

So with just a simple addition it worked for me. Hope this helps everyone. I apologize I don't know how to format this.

share|improve this answer

Your Answer


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.