check_mount says nothing is mounted

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
dkstuart23
Posts: 8
Joined: Thu Feb 18, 2021 2:42 pm

check_mount says nothing is mounted

Post 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?
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: check_mount says nothing is mounted

Post 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.

Code: Select all

sestatus
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
dkstuart23
Posts: 8
Joined: Thu Feb 18, 2021 2:42 pm

Re: check_mount says nothing is mounted

Post 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.
Locked