Page 1 of 1
check_mount says nothing is mounted
Posted: Wed Jul 07, 2021 8:14 am
by dkstuart23
We have stood up a new RHEL7 server. The config files appear to be set up the same. However, with the check_mount command, it says that nothing is mounted. I did some additional checking and the plugin is running a check of the contents of fstab vesus the output of the mount command. The mount command is returning null. Other plugins run by the 'nrpe' user seem to be working fine. Ideas?
Re: check_mount says nothing is mounted
Posted: Wed Jul 07, 2021 9:21 am
by pbroste
Hello,
Thanks for reaching out.
What command parameters are you running on the check_mount plugin? And, you have tried to run as sudo as well with the same results?
Also please check to see if selinux is enabled? This could be preventing the script from successfully running.
Here is an example that I ran:
Code: Select all
./check_mount.sh /dev/sda1 ext4
OK - /dev/sda1 mounted under ext4.
check_mount.sh v1.02
Thanks,
Perry
Re: check_mount says nothing is mounted
Posted: Thu Jul 08, 2021 9:23 am
by dkstuart23
So we have the Nagios plugins installed in /usr/lib64/nagios/plugins. The script we are running is the same as in many other hosts within our environment.
Code: Select all
#!/bin/bash
# Compare /etc/fstab to mounts command report not in mounts. Ignore proc, rpc_pipefs, swap, and blank lines
MISSINGFS=$(comm -23 <(awk '!/^($|#|.*swap.*|.*tmpfs.*|proc)/{print $2}' /etc/fstab | sort) <(mount | awk '!/(\/proc|rpc_pipefs|tmpfs)/{print $3}' | sort))
MOUNTSNUM=$(mount | awk '!/(\/proc|rpc_pipefs|tmpfs)/{print $3}' | sort | wc -l)
EXITMESSAGE="OK - All /etc/fstab declarations are mounted"
if [ -n "$MISSINGFS" ]; then
EXITMESSAGE="Filesystem(s) in /etc/fstab not mounted: "$(echo $MISSINGFS|xargs)
EXITSTATUS=2
fi
EXITMESSAGE=$EXITMESSAGE"|'mounts'="$MOUNTSNUM
echo $EXITMESSAGE
exit $EXITSTATUS
If I run it under sudo, it works. However, if it runs through Nagios, I've determined that the output of
Code: Select all
(mount | awk '!/(\/proc|rpc_pipefs|tmpfs)/{print $3}' | sort)
is blank.
As I said, I have other hosts in our environment that it works fine. I've check the other Nagios cfg files, sudoers cfg, etc.