Page 1 of 1
Issues with setting check_mountpoints on linux server
Posted: Fri Jun 19, 2020 3:25 pm
by kostadin.boychev
I set up a monitoring service on a linux host with check_nrpe_mount (attached image of the service). On a brand new set up host on Nagios (5.6.14 version btw) this returns "NRPE: Command 'check_mountpoints' not defined".
The check_mountpoints.sh file is in /usr/local/nagios/libexec/ but not under the nagios user - its under root. Is this a permission issue and how can I resolve that? I would need to replicate this process and monitor mounts on a lot more hosts so please advice what is the best solution to this.
Re: Issues with setting check_mountpoints on linux server
Posted: Fri Jun 19, 2020 4:14 pm
by lmiltchev
The check_nrpe plugin is usually used for monitoring remote machines, on which NRPE agent is installed. So the check_mountpoints command must be defined on the client (remote box) in the
common.cfg file or in the
nrpe.cfg file.
The common.cfg file is added when you install the Linux agent (NRPE + Nagios Plugins) via our official installer. See the document below:
https://assets.nagios.com/downloads/nag ... _Agent.pdf
If you compiled NRPE from source, you won't have common.cfg on the client. In this case, you can define it in the nrpe.cfg file. You could define the command in any of these two files. Dont' forget to restart the NRPE daemon, so that changes can take effect.
If the /usr/local/nagios/libexec/check_mountpoints.sh script requires root privileges, you would need to use sudo in your command, and add nagios to your sudoers file.
Tips: First, test the command locally on the remote machine, just to make sure it works. Then, you could test it from the Nagios XI server.
Code: Select all
/usr/local/nagios/libxec/check_nrpe -H <client ip> -c check_mountpoints -a '<some args if any>'
Let us know if you get stuck on something. Thanks!
Re: Issues with setting check_mountpoints on linux server
Posted: Wed Jun 24, 2020 7:54 am
by kostadin.boychev
Hello really banging my head on this one.
Defined in common.cfg
### Check Mount
command[check_mountpoints]=/usr/local/nagios/libexec/check_mountpoints.sh $ARG1$
Now I am getting : NRPE: Unable to read output error instead.
Tried using check_mountpoint instead of check_nrpe_mount and I get :
CRITICAL: /mnt/jupyterpersonal/ doesn't exist in fstab /etc/fstab ; /mnt/jupyterpersonal/ is not mounted ; /mnt/jupyterpersonal/ doesn't exist on filesystem ;
Which would be wonderful if it was true but based on cat /etc/fstab/ and using mount I can see that it is mounted.
Running sudo /usr/local/nagios/libexec/check_mountpoints.sh /insertmountname/ works on the other server that I have it configured and on this one it just returns command not found. If I try the one you described it returns command not found for check_nrpe with sudo rights used.
Went through the configuration wizard which set up check_mountpoint which again returns that nothing is mounted even though the mounts are there.
Any service that monitors works with me as soon as it is working properly and I can replicate on more servers.
Re: Issues with setting check_mountpoints on linux server
Posted: Wed Jun 24, 2020 9:56 am
by lmiltchev
Running sudo /usr/local/nagios/libexec/check_mountpoints.sh /insertmountname/ works on the other server that I have it configured and on this one it just returns command not found.
You are running your command with "sudo", but the one, defined in the common.cfg doesn't have "sudo"...
command[check_mountpoints]=/usr/local/nagios/libexec/check_mountpoints.sh $ARG1$
Let see if the command produces the same output when run as root and as nagios user. Can you run the following commands on the remote Linux server, and show the output?
Code: Select all
sudo /usr/local/nagios/libexec/check_mountpoints.sh /<mountname>
su - nagios -c "/usr/local/nagios/libexec/check_mountpoints.sh /<mountname>"
Also, post the sudoers file on the forum.
Restart NRPE (if it's running as a standalone daemon) or xinetd on the client (remote system).
Test your command from the Nagios XI server:
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H <client ip> -c check_mountpoints -a '</<mountname>'
Re: Issues with setting check_mountpoints on linux server
Posted: Fri Jun 26, 2020 7:09 am
by kostadin.boychev
Thanks for the timely replies!
I got back to the issue and tested your recommendations.Ran as root command returns the exact same result. Don't really know the nagios password and switching to nagios user using root privileges still requires to input password when executing a command.
On the other server actually in the common.cfg its defined as
### Check Mount
command[check_mountpoints]=/usr/local/nagios/libexec/check_mountpoint_servername
and check_mountpoint_servername is set by sudo /usr/local/nagios/libexec/check_mountpoints.sh /insertmountname/
In the end that is not what I desire as I want to check all mounts not just hard coded one.Do you think that I should wipe the configs and start from scratch and if that is the case what would be the process? Define check_mountpoint? Use a different script?
Thank you,
Kostadin
Re: Issues with setting check_mountpoints on linux server
Posted: Fri Jun 26, 2020 9:45 am
by lmiltchev
Don't really know the nagios password and switching to nagios user using root privileges still requires to input password when executing a command.
It shouldn't ask you for a password if you added nagios to sudoers file on the client (remote machine). Make sure you have the following lines in sudoers file:
Code: Select all
Defaults:nagios !requiretty
nagios ALL=NOPASSWD: /usr/local/nagios/libexec/check_mountpoints.sh *
then try your check again.
In the end that is not what I desire as I want to check all mounts not just hard coded one.Do you think that I should wipe the configs and start from scratch and if that is the case what would be the process? Define check_mountpoint? Use a different script?
You can just try a different plugins, e.g. check_disk. Add the following line to the common.cfg file on the client:
Code: Select all
command[check_mounts]=/usr/local/nagios/libexec/check_disk -l
and restart NRPE (or xinetd) so that changes can take effect.
Test the new command from the CLI on the Nagios XI server:
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H <client ip> -c check_mounts
Example:
Code: Select all
[root@main-nagios-xi ~]# /usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_mounts
DISK OK - free space: / 26950 MiB (75.36% inode=89%); /dev/shm 3936 MiB (100.00% inode=100%); /boot 325 MiB (72.09% inode=100%);| /=8810MiB;;;0;37674 /dev/shm=0MiB;;;0;3936 /boot=125MiB;;;0;476
You can view the usage of the check_disk plugin by running:
Code: Select all
/usr/local/nagios/libexec/check_disk -h
You can also search for other plugins on the Nagios Exchange:
https://exchange.nagios.org/directory/Plugins
Once you find something that you think might work, test it, and add a new command and service by following the document below:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf