Mount Point Monitoring

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
s.diwakar1
Posts: 44
Joined: Thu Feb 27, 2020 9:45 am

Mount Point Monitoring

Post by s.diwakar1 »

Hi Everyone,

Hope you all are good !!!

I am using the Nagios Core 4.4.5

We are monitoring the Mount Points using the Script: "./check_mount.sh"
https://exchange.nagios.org/directory/P ... is/details

For one of our host, some mount points are showing as Not mounted under FS. Whereas, when we are checking manually at the server end and running the command manually. Then it is showing correct output and also getting the service status as Ok in Nagios. But after some time some of the mount points are showing as not mounted until we do not run the command manually.

Kindly suggest.

Thank you so much in advance!!!
Thanks & Regards,
Diwakar Sharma
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Mount Point Monitoring

Post by cdienger »

The code of the plugin looks pretty straight forward:

Code: Select all

MOUNTED=`mount | grep "$MOUNT" | grep -c "$FS "`            # execute the command to check the mount...

if [ $MOUNTED -eq 0 ]; then
    MSG="CRITICAL - $FS not mounted under $MOUNT."
    RC=$NAGIOS_CRIT
  elif [ $MOUNTED -eq 1 ]; then
    MSG="OK - $FS mounted under $MOUNT."
    RC=$NAGIOS_OK
  else
    MSG="WARNING - $FS is mounted several times! ($MOUNTED)"
    RC=$NAGIOS_WARN
fi
The key part being:

Code: Select all

mount | grep "$MOUNT" | grep -c "$FS"
Where $FS is an argument passed to the plugin.

Is the mount suppose to always be attached or is it attached only for certain users like when the log in? Is it possible that someone or something is unmounting it?

What account are you using to run the command manually? When Nagios automatically runs it, the script is going to run via some agent like ssh, ncpa, nrpe which would use likely use a different account(nagios account probably) to execute it. You can try to switch to this account and run the plugin:

Code: Select all

su - nagios
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
s.diwakar1
Posts: 44
Joined: Thu Feb 27, 2020 9:45 am

Re: Mount Point Monitoring

Post by s.diwakar1 »

After executing the script manually using Nagios Account, the output is same as on Nagios Console (not mounted under FS). But the FSs are mounted to the server.

Can you please suggest what to do next?
Thanks & Regards,
Diwakar Sharma
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Mount Point Monitoring

Post by gormank »

Since it works are root and not nagios, it may need to run via sudo. I'd have a look at the sudoers config for syntax and put it under /etc/sudoers.d/ in a separate file.
Locked