Page 1 of 1

Mount Point Monitoring

Posted: Thu Aug 13, 2020 11:44 am
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!!!

Re: Mount Point Monitoring

Posted: Thu Aug 13, 2020 3:05 pm
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

Re: Mount Point Monitoring

Posted: Mon Aug 24, 2020 7:02 am
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?

Re: Mount Point Monitoring

Posted: Mon Aug 24, 2020 4:37 pm
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.