Page 1 of 1

Accessing filesystem with root user

Posted: Tue Apr 11, 2017 9:22 am
by sgoffar
Hi Team,

We have a server for which few file systems only have root access so by using the command check_disk we are not able to get data.

We are getting below error. Is there any way to check with root user,

Error Details: DISK CRITICAL - /hana/log/VWH/mnt00001 is not accessible: Permission denied

File System Details:

dfXXX:~ # df -hT | grep /hana/log/VWH/mnt00001
/dev/mapper/vg_log1_dp_11-lvol1 xfs 520G 6.3G 514G 2% /hana/log/VWH/mnt00001
dfwhana20:~ # su nagios
nagios@dfXXX:/root> df -hT | grep /hana/log/VWH/mnt00001
nagios@dfXXX:/root>

Re: Accessing filesystem with root user

Posted: Tue Apr 11, 2017 12:36 pm
by tgriep
If you are using the Linux NRPE Agent to run the check_disk plugin on the remote server, you can do the following changes and the plugin should run as root.

First, add the following 2 lines to the /etc/sudoers file

Code: Select all

Defaults:nagios !requiretty
nagios ALL=(root) NOPASSWD: /usr/local/nagios/libexec/check_disk
Then edit the nrep.cfg file where the check_disk command is defined and add /usr/bin/sudo to the command like the example below.

Code: Select all

command[check_disk]=/usr/bin/sudo /usr/local/nagios/libexec/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
Save the nrpe.cfg file and restart the NRPE agent so the changes will take effect.
Try that and see if it works for you.

Re: Accessing filesystem with root user

Posted: Wed Apr 12, 2017 4:22 am
by sgoffar
Below two line needs to add on Target server or Nagios server /etc/sudoers file. We are using nagios agent to get the data.

Defaults:nagios !requiretty
nagios ALL=(root) NOPASSWD: /usr/local/nagios/libexec/check_disk

Also is nagios user needs to have sudo permission in target server right?

Re: Accessing filesystem with root user

Posted: Wed Apr 12, 2017 11:22 am
by tgriep
Sorry that I wasn't clear but those changes have to be done on the target server.
Those changes should allow the nagios user to run that plugin as root on the target server.

Re: Accessing filesystem with root user

Posted: Thu Apr 13, 2017 10:21 am
by sgoffar
NP, Thanks for the details.

On the same server on status check we are getting below error. Can you please help on this.

When i check the directory /usr/local/nagios/etc/nrpe the file is not present. But the KPI's are collecting data.


cd /usr/local/nagios/etc/nrpe
-bash: cd: /usr/local/nagios/etc/nrpe: No such file or directory

service xinetd status
xinetd.service - Xinetd A Powerful Replacement For Inetd
Loaded: loaded (/usr/lib/systemd/system/xinetd.service; disabled)
Active: active (running) since Thu 2017-04-13 13:36:32 UTC; 1h 37min ago
Main PID: 114244 (xinetd)
CGroup: /system.slice/xinetd.service
└─114244 /usr/sbin/xinetd -stayalive -dontfork

Apr 13 15:11:47 dfXXXXXXX xinetd[114244]: EXIT: nrpe status=0 duration=0(sec)
Apr 13 15:11:50 dfXXXXXXX xinetd[114244]: EXIT: nrpe status=0 duration=5(sec)
Apr 13 15:12:43 dfXXXXXXX xinetd[114244]: START: nrpe from=172.26.241.185
Apr 13 15:12:43 dfXXXXXXX nrpe[129502]: Could not open config directory '/usr/local/nagios/etc/nrpe' for reading.
Apr 13 15:12:43 dfXXXXXXX nrpe[129502]: Continuing with errors...
Apr 13 15:12:44 dfXXXXXXX xinetd[114244]: EXIT: nrpe status=0 duration=1(sec)
Apr 13 15:12:44 dfXXXXXXX xinetd[114244]: START: nrpe from=172.26.241.185
Apr 13 15:12:44 dfXXXXXXX nrpe[129506]: Could not open config directory '/usr/local/nagios/etc/nrpe' for reading.
Apr 13 15:12:44 dfXXXXXXX nrpe[129506]: Continuing with errors...
Apr 13 15:12:44 dfXXXXXXX xinetd[114244]: EXIT: nrpe status=0 duration=0(sec)

Re: Accessing filesystem with root user

Posted: Thu Apr 13, 2017 12:51 pm
by tgriep
In the /usr/local/nagios/etc folder, there should be a nrpe.cfg file, does it exist?

Can you login to the remote server, run the following and post the /tmp/ls.txt file>

Code: Select all

ls -lR /usr/local/nagios >/tmp/ls.txt file
Also, post the /etc/xinetd.d/nrpe file as well so we can view it settings.

Re: Accessing filesystem with root user

Posted: Fri Apr 14, 2017 7:22 am
by sgoffar
Please find below requested details:

/usr/local/nagios/etc # ls -lrt
total 8
-rw-r--r-- 1 nagios nagios 8187 Apr 12 09:23 nrpe.cfg


# cat /etc/xinetd.d/nrpe
# default: on
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
flags = REUSE
socket_type = stream
port = 5666
wait = no
user = nagios
group = nagios
server = /usr/local/nagios/bin/nrpe
server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd
log_on_failure += USERID
disable = no
only_from = X.X.X.X Y.Y.Y.Y

Re: Accessing filesystem with root user

Posted: Fri Apr 14, 2017 9:43 am
by tgriep
Run this to create the folder and set the permissions.

Code: Select all

mkdir  /usr/local/nagios/etc/nrpe
chown nagios.nagios  /usr/local/nagios/etc/nrpe
chmod 775 /usr/local/nagios/etc/nrpe
In the nrpe.cfg file, there is an include_dir option and when the nrpe agent runs, it looks in that folder and if it finds a config file, it uses them as well.
include_dir=/usr/local/nagios/etc/nrpe
That should fix the "Could not open config directory '/usr/local/nagios/etc/nrpe' for reading." error.