Nagios 3.5.1 - check_uptime plugin

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.
Locked
Mcw33
Posts: 4
Joined: Mon Jun 22, 2015 9:40 pm

Nagios 3.5.1 - check_uptime plugin

Post by Mcw33 »

Having a bit of trouble with this plugin check_uptime http://nagios-plugins.org/doc/man/check_uptime.html

I'm able to run the command manually from the nagios server and return a value


useraccount@nagios:/usr/local/nagios/etc/objects/company$ /usr/local/nagios/libexec/check_nrpe -H 192.168.2.117 -c check_uptime
OK: uptime: 4d 02:31h, boot: 2015-Jun-19 00:07:50 (UTC)|'uptime'=354702s;172800;86400

But when trying to add this into a host.cfg file I'm getting a (No output returned from plugin).

I can also see when manually running the above command I can see from the nscp log "nrpe Accepting connection from: 192.168.11.222, count=1" on the windows host which then gives me the above result a second after, but when trying to force a recheck from nagios web interface this doesn't occur on the command window.

host.cfg
define service{
use generic-service
host_name Test_Machine1
service_description check_uptime
check_command check_nrpe!check_uptime -H 192.168.2.117 days 3 5
}

command.cfg
# 'check_uptime' command definition for linux hosts
define command{
command_name check_uptime
command_line $USER1$/check_uptime -o $ARG1$ -w $ARG2$ -c $ARG3$
}

What I ultimately want is check_uptime -o days -w 70 -c 90

Any Idea's?
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Nagios 3.5.1 - check_uptime plugin

Post by jdalrymple »

Mcw33 wrote:host.cfg
define service{
use generic-service
host_name Test_Machine1
service_description check_uptime
check_command check_nrpe!check_uptime -H 192.168.2.117 days 3 5
}

command.cfg
# 'check_uptime' command definition for linux hosts
define command{
command_name check_uptime
command_line $USER1$/check_uptime -o $ARG1$ -w $ARG2$ -c $ARG3$
}
In the above service definition you're running the command check_nrpe, not check_uptime. While this is proper, we cannot troubleshoot without seeing your check_nrpe command definition. Based upon what you have though, it should look something like this:

Code: Select all

define command {
       command_name                             check_nrpe
       command_line                             $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

define service {
       .....
       check_commnad                            check_nrpe!check_uptime
       .....
}
If you have arguments enabled you can pass your thresholds as such:

Code: Select all

define service {
       .....
       check_commnad                            check_nrpe!check_uptime -u days -w 70 -c 90
       .....
}
Otherwise you'll have to handle it in nrpe.cfg.
Mcw33
Posts: 4
Joined: Mon Jun 22, 2015 9:40 pm

Re: Nagios 3.5.1 - check_uptime plugin

Post by Mcw33 »

Hi, Thanks for the reply.

This is the only "nrpe.cfg file I can find "check_nrpe.cfg" what modifications wouldn I need to make here? Located in /etc/nagios-plugins/config


# this command runs a program $ARG1$ with arguments $ARG2$
define command {
command_name check_nrpe
command_line /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$
}

# this command runs a program $ARG1$ with no arguments
define command {
command_name check_nrpe_1arg
command_line /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios 3.5.1 - check_uptime plugin

Post by abrist »

Well, you will need to edit the nrpe.cfg file on the remote nrpe host, add the command there, and then call it through check_nrpe from the nagios server. The following steps assume that nrpe and the nagios-plugins package are installed on the remote host with defualt ./configure options.
On the remote host, edit:

Code: Select all

/usr/local/nagios/etc/nrpe.cfg
Add:

Code: Select all

command[check_uptime]=/usr/local/nagios/libexec/check_uptime  $ARG1$ 
Also, verify that nrpe is configured to support arguments:

Code: Select all

dont_blame_nrpe=1
Save out and restart nrpe:

Code: Select all

service xinetd restart
Or:

Code: Select all

service nrpe restart
Now, we need to check the command and service check definitions on the nagios box:

Code: Select all

host.cfg
define service{
use generic-service
host_name Test_Machine1
service_description check_uptime
check_command check_uptime!-u days -w 70 -c 90
}

command.cfg
# 'check_uptime' command definition for linux hosts
define command{
command_name check_uptime
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_uptime -a $ARG1$
}
Does this make sense?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Mcw33
Posts: 4
Joined: Mon Jun 22, 2015 9:40 pm

Re: Nagios 3.5.1 - check_uptime plugin

Post by Mcw33 »

Hi sorry been a bit busy with other work things.

It's made sense and I've made the changes advised, one thing I have found is there is no nrpe.cfg file on the remote host, I wasn't the one to setup this nagios box so I don't know why.
I've tried a quick google to see what I need to do to setup this but haven't come across whats needed. I've created the file in /usr/local/nagios/etc/nrpe.cfg and listed the following

Code: Select all

command[check_uptime]=/usr/local/nagios/libexec/check_uptime  $ARG1$

dont_blame_nrpe=1
edit: Sorry installed the nagios-nrpe-server plugin and added the above details. Still showing as no "(No output returned from plugin)" and I can't see the nsclient.log file receiving the command. I have been able to return a output from the nagios server to this host so I know there isn't any FW/Network issues in between them
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Nagios 3.5.1 - check_uptime plugin

Post by Box293 »

Lets see if we can find the nrpe.cfg file as the one you create may not be reference.

Code: Select all

find / -name 'nrpe.cfg'
Does this file exist: /etc/xinetd.d/nrpe

If so, it will reference the nrpe.cfg file
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Mcw33
Posts: 4
Joined: Mon Jun 22, 2015 9:40 pm

Re: Nagios 3.5.1 - check_uptime plugin

Post by Mcw33 »

Hi, I get the following

Code: Select all

User@nagios:~$ sudo find / -name 'nrpe.cfg'
[sudo] password for user:
/etc/nagios/nrpe.cfg
/usr/local/nagios/etc/nrpe.cfg
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Nagios 3.5.1 - check_uptime plugin

Post by Box293 »

I believe this file:

/etc/nagios/nrpe.cfg

is what you need to define the following in:

Code: Select all

command[check_uptime]=/usr/local/nagios/libexec/check_uptime $ARG1$

dont_blame_nrpe=1
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked