problem with nrpe and ubuntu

This forum is intended for the discussion of Nagios plugin development. Feature requests, patches, bug fixes, and all types of development-related discussions are welcome!

NOTE: The SourceForge.net nagiosplug-devel mailing list has been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

problem with nrpe and ubuntu

Postby majed » Thu Jul 06, 2017 8:17 am

Health be upon you,
today I installed an ubuntu with nrpe and it worked because I enabled the root user.
On 3 previous ubuntu's, it is not working because the root is disabled.
here is the error:
Code: Select all
cd /usr/lib/nagios/plugins/
@NE8:/usr/lib/nagios/plugins$ sudo -s -u nagios ./check_nrpe -H 127.0.0.1 -c check_disk
NRPE: Unable to read output

I researched the error and it is narrowed to:
either the path nrpe.cfg is wrong or there is a permission problem.
according to
https://serverfault.com/questions/323233/nrpe-unable-to-read-output-but-why
Code: Select all
nagios ALL=(ALL) NOPASSWD:/usr/lib/nagios/plugins/

must be added to the sudoers file.
I am reluctant to do that as in the past i played with the sudoers file and it stopped being accessed! I had to use the ubuntu cd to edit it and this is dangerous in a production environment.
do you confirm that this is the problem?

config of /etc/nagios/nrpe.cfg
Code: Select all
allowed_hosts=127.0.0.1, 10.10.10.12

command[check_users]=sudo /usr/lib/nagios/plugins/check_users -w 5 -c 10
command[check_load]=sudo /usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_disk]=sudo /usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda3
command[check_zombie_procs]=sudo /usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=sudo /usr/lib/nagios/plugins/check_procs -w 150 -c 200
command[check_swap]=sudo /usr/lib/nagios/plugins/check_swap -w 20 -c 10
command[check_mem]=sudo /usr/lib/nagios/plugins/check_mem.pl -u -w 80 -c 90
command[check_cpu]=sudo /usr/lib/nagios/plugins/check_cpu.sh -i 5 -w 80 -c 90

Code: Select all
ls -l /etc/nagios
total 20
-rwxr-xr-x 1 nagios nagios 8240 июл  5 12:56 nrpe.cfg
drwxr-xr-x 2 nagios nagios 4096 май  8 19:01 nrpe.d
-rwxr-xr-x 1 nagios nagios  117 май  8 19:00 nrpe_local.cfg

Code: Select all
ls -l /usr/lib/nagios/
total 4
drwxr-xr-x 2 nagios nagios 4096 июл  5 12:24 plugins


Code: Select all
sudo ps cax | grep nrpe
12473 ?        Ss     0:00 nrpe
Seek and you shall find, knock and it shall be opened, cry and you shall find comfort
majed
 
Posts: 86
Joined: Mon Mar 17, 2014 5:29 am

Re: problem with nrpe and ubuntu

Postby tmcdonald » Thu Jul 06, 2017 4:21 pm

Can you verify the NRPE version and installation method? If it was not compiled from source obtained on our GitHub then it might be an older version with known/unknown bugs depending on the packager/maintainer.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tmcdonald
Support Lead / Operations Engineer
 
Posts: 8698
Joined: Mon Sep 23, 2013 8:40 am

Re: problem with nrpe and ubuntu

Postby majed » Fri Jul 07, 2017 4:12 am

here is how it was installed:

Code: Select all
sudo apt-get install openssl nagios-nrpe-server nagios-plugins nagios-plugins-basic nagios-plugins-standard


Code: Select all
$ sudo  -s -u nagios ./check_nrpe -H 127.0.0.1
NRPE v2.15
Seek and you shall find, knock and it shall be opened, cry and you shall find comfort
majed
 
Posts: 86
Joined: Mon Mar 17, 2014 5:29 am

Re: problem with nrpe and ubuntu

Postby scottwilkerson » Fri Jul 07, 2017 11:52 am

In /etc/nagios/nrpe.cfg you have all the checks prefaced with sudo

you shouldn't need this with most, but if you do have it in there you would need to add the sudo permissions to your sudoers file.

To start with, I would remove sudo from the commands in , restart nrpe and try to make the connection from 10.10.10.12

Code: Select all
sudo -s -u nagios ./check_nrpe -H IP_OF_MACHINE_WITH_NRPE -c check_disk
User avatar
scottwilkerson
CTO
 
Posts: 7903
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: problem with nrpe and ubuntu

Postby majed » Mon Jul 10, 2017 1:06 am

ok i removed sudo:
Code: Select all
command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_disk]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda1
command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200
command[check_swap]=/usr/lib/nagios/plugins/check_swap -w 20 -c 10
command[check_mem]=/usr/lib/nagios/plugins/check_mem.pl -u -w 80 -c 90
command[check_cpu]=/usr/lib/nagios/plugins/check_cpu.sh -i 5 -w 80 -c 90

restarted nrpe..
sysadmin@NS5:/usr/lib/nagios/plugins$ sudo -s -u nagios ./check_nrpe -H 127.0.0.1 -c check_disk
NRPE: Unable to read output
looks like the next step is to add to sudoers file. but i'll be patient and hear what you have to say.
Seek and you shall find, knock and it shall be opened, cry and you shall find comfort
majed
 
Posts: 86
Joined: Mon Mar 17, 2014 5:29 am

Re: problem with nrpe and ubuntu

Postby scottwilkerson » Mon Jul 10, 2017 10:11 am

Just to verify I would confirm you can run this as the nagios user first:
Code: Select all
sudo su nagios -c "/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda1"
User avatar
scottwilkerson
CTO
 
Posts: 7903
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: problem with nrpe and ubuntu

Postby majed » Tue Jul 11, 2017 1:07 am

:~$ cd /usr/lib/nagios/plugins/
:/usr/lib/nagios/plugins$ ./check_disk -w 20% -c 10% -p /dev/sda1
DISK OK - free space: / 6835 MB (70% inode=82%);| /=2819MB;8156;9176;0;10196
:/usr/lib/nagios/plugins$ sudo su nagios -c "/check_disk -w 20% -c 10% -p /dev/sda1"
:/usr/lib/nagios/plugins$
no output from the command!
what does this mean?
Seek and you shall find, knock and it shall be opened, cry and you shall find comfort
majed
 
Posts: 86
Joined: Mon Mar 17, 2014 5:29 am

Re: problem with nrpe and ubuntu

Postby tgriep » Tue Jul 11, 2017 12:44 pm

The path in your command doesn't look right so try running this example using the full path to the plugin.
Code: Select all
sudo su nagios -c "/usr/lib/nagios/plugins/check_disk/check_disk -w 20% -c 10% -p /dev/sda1"


If an error is generated when you run it, post it here so we can view it.
One thing to check is to see if the nagios user account can access the folders the plugins are located in and that it can execute the plugins themselves.
The error you are receiving could be caused by that.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 6081
Joined: Thu Oct 30, 2014 9:02 am

Re: problem with nrpe and ubuntu

Postby majed » Fri Jul 28, 2017 4:55 am

Peace, I was on a long sick leave.
Code: Select all
sudo su nagios -c "/usr/lib/nagios/plugins/check_disk/check_disk -w 20% -c 10% -p /dev/sda1"
:~$ cd /usr/lib/nagios/plugins/
:/usr/lib/nagios/plugins$ sudo  -s -u nagios ./check_nrpe -H 127.0.0.1 -c check_disk
DISK OK - free space: / 6770 MB (70% inode=82%);| /=2885MB;8156;9176;0;10196


Code: Select all
:~$ /usr/lib/nagios/plugins/check_disk  -w 20% -c 10% -p /dev/sda1
DISK OK - free space: / 6770 MB (70% inode=82%);| /=2885MB;8156;9176;0;10196
:~$ sudo -i -u nagios
:~$ /usr/lib/nagios/plugins/check_disk  -w 20% -c 10% -p /dev/sda1
DISK OK - free space: / 6770 MB (70% inode=82%);| /=2885MB;8156;9176;0;10196
:~$ sudo su nagios -c "/usr/lib/nagios/plugins/check_disk  -w 20% -c 10% -p /dev/sda1"
:~$

i tried su - nagios but it keeps saying the password is wrong, while sudo -i -u nagios did not ask for a password. is your suspicion correct?
Seek and you shall find, knock and it shall be opened, cry and you shall find comfort
majed
 
Posts: 86
Joined: Mon Mar 17, 2014 5:29 am

Re: problem with nrpe and ubuntu

Postby tgriep » Fri Jul 28, 2017 12:58 pm

I think the issue is that the nagios useraccount has a password set to it or it is expired and that is causing the issue.
Login to that server as root and run the following to remove the password and to set the account to not expire.
Code: Select all
passwd --delete nagios
chage -I -1 -m 0 -M 99999 -E -1 nagios

The nagios user account cannot have a password so hopefully this will fix the issue.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 6081
Joined: Thu Oct 30, 2014 9:02 am

Next

Return to Nagios Plugin Development

Who is online

Users browsing this forum: No registered users and 3 guests