Page 1 of 1

How to configure to check mount status for a mount point

Posted: Thu Feb 20, 2020 8:28 am
by lgaddam
HI,

Presently we have installed nrpe agent on remote Linux servers with cpu, memory, swap monitoring.

We got a requirement to check mount status for particular mounts but not its utilization for Linux remote machines.

How to configure in Nagios ?

Please provide me steps

Re: How to configure to check mount status for a mount point

Posted: Thu Feb 20, 2020 11:51 am
by jdunitz
There is already a "check_mountpoints" command that will do what you want if you want to check a remote filesystem like NFS, CIFS, Lustre, etc.
However, if you want to check a regular local disk filesystem, that will require some editing.
Be aware that if you edit a plugin, your changes will get overwritten when the plugin gets updated in future releases. To avoid this, you'll want to have a separate copy of the plugin with a different name. Essentially, you're forking the plugin, and will have to maintain it separately.

In order to do what you want, you'll have to do a few things:
0) Know what type of filesystem you're checking for. For example, here we have an ext2 filesystem I created (and loop mounted):

Code: Select all

# mount | grep export
/export.img on /export type ext2 (rw,loop=/dev/loop0)
1) Place a copy of the /usr/local/nagios/libexec/check_mountpoints.sh script on your client system

Code: Select all

# scp /usr/local/nagios/libexec/check_mountpoints.sh  your-client-system:/usr/local/nagios/libexec
2) modify the /usr/local/nagios/libexec/check_mountpoints.sh (on your client system) to understand your filesystem type.
Around line 249 of that script, add your filesystem type (as determined by the output of the "mount" command:

Code: Select all

248-        ## check kernel mounts
249:        ${GREP} "${MP}" ${MTAB} | ${GREP} -q -E "(ext2|nfs|nfs4|davfs|cifs|fuse|simfs|glusterfs|ocfs2|lustre)" &>/dev/null
250-        if [ $? -ne 0 ]; then
251-        ## if a softlink is not an adequate replacement
See that I added "ext2" to the beginning of that list? You may need ext3, ext4, btrfs, or whatever you're using.

3) Add an entry for "check_mountpoints" to /usr/local/nagios/etc/nrpe/common.cfg (or, if you prefer, add a separate whatever.cfg file with the check_mountpoints line in it):

Code: Select all

### MISC SYSTEM METRICS ###
#command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_users]=/usr/local/nagios/libexec/check_users $ARG1$
command[check_load]=/usr/local/nagios/libexec/check_load $ARG1$
command[check_swap]=/usr/local/nagios/libexec/check_swap $ARG1$
command[check_cpu_stats]=/usr/local/nagios/libexec/check_cpu_stats.sh $ARG1$
command[check_mem]=/usr/local/nagios/libexec/custom_check_mem -n $ARG1$
# Added for disk mounts
command[check_mountpoints]=/usr/local/nagios/libexec/check_mountpoints.sh $ARG1$
4) Run the NRPE Agent wizard from the front page of your XI system (Configure -> Configuration Wizards), and add an additional NRPE command to check your filesystem:
CheckExportNRPE.PNG
You should now start seeing an item service status for your filesystem check.

Hope that helps!

--Jeffrey

Re: How to configure to check mount status for a mount point

Posted: Tue Feb 25, 2020 9:41 am
by lgaddam
Its not working.

Below are the thongs which I did.

1.Checked the type of filesystem : it is "cifs"
[root@p01 ~]# mount | grep /mnt/ecm
XXXXXX on /mnt/ecm type cifs (rw)
[root@op01 ~]#

2.Already "cifs" is present in the script at line 249, so did not do any changes in the script

3.out of common.cfg file on remote Linux machine.

[root@p01 nrpe]# cat common.cfg

### GENERIC SERVICES ###
command[check_init_service]=sudo /usr/local/nagios/libexec/check_init_service $ARG1$
command[check_services]=/usr/local/nagios/libexec/check_services -p $ARG1$

### MISC SYSTEM METRICS ###
#command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_users]=/usr/local/nagios/libexec/check_users $ARG1$
command[check_load]=/usr/local/nagios/libexec/check_load $ARG1$
command[check_swap]=/usr/local/nagios/libexec/check_swap $ARG1$
command[check_cpu_stats]=/usr/local/nagios/libexec/check_cpu_stats.sh $ARG1$
command[check_mem]=/usr/local/nagios/libexec/custom_check_mem -n $ARG1$
command[check_mountpoint]=/usr/local/nagios/libexec/check_mountpoints.sh -m $ARG1$

### YUM UPDATES ###
command[check_yum]=/usr/local/nagios/libexec/check_yum

### DISK ###
command[check_disk]=/usr/local/nagios/libexec/check_disk $ARG1$
command[check_ide_smart]=/usr/local/nagios/libexec/check_ide_smart $ARG1$

### PROCESSES ###
command[check_all_procs]=/usr/local/nagios/libexec/custom_check_procs
command[check_procs]=/usr/local/nagios/libexec/check_procs $ARG1$

### OPEN FILES ###
command[check_open_files]=/usr/local/nagios/libexec/check_open_files.pl $ARG1$

### NETWORK CONNECTIONS ###
command[check_netstat]=/usr/local/nagios/libexec/check_netstat.pl -p $ARG1$ $ARG2$

# Added for disk mounts
command[check_mountpoints]=/usr/local/nagios/libexec/check_mountpoints.sh $ARG1$

4.Restarted nrpe: service xinetd status

5.Configuration is attached for this service

6.Error: UNKNOWN

check /mnt/ecm Unknown 37m 30s 5/5 2020-02-25 15:32:33 (No output returned from plugin)

7.I ran the command in Nagios server for testing with check_nrpe.
[root@etc]# /usr/local/nagios/libexec/check_nrpe -H xx.xx.xx.xx -t 500 -c check_mountpoints -a -L -i /mnt/ecm
/usr/local/nagios/libexec/check_nrpe: invalid option -- i

NRPE Plugin for Nagios
Copyright (c) 1999-2008 Ethan Galstad ([email protected])
Version: 2.15
Last Modified: 09-06-2013
License: GPL v2 with exemptions (-l for more info)
SSL/TLS Available: Anonymous DH Mode, OpenSSL 0.9.6 or higher required

Usage: check_nrpe -H <host> [ -b <bindaddr> ] [-4] [-6] [-n] [-u] [-p <port>] [-t <timeout>] [-c <command>] [-a <arglist...>]

Options:
-n = Do no use SSL
-u = Make socket timeouts return an UNKNOWN state instead of CRITICAL
<host> = The address of the host running the NRPE daemon
<bindaddr> = bind to local address
-4 = user ipv4 only
-6 = user ipv6 only
[port] = The port on which the daemon is running (default=5666)
[timeout] = Number of seconds before connection times out (default=10)
[command] = The name of the command that the remote daemon should run
[arglist] = Optional arguments that should be passed to the command. Multiple
arguments should be separated by a space. If provided, this must be
the last option supplied on the command line.

Note:
This plugin requires that you have the NRPE daemon running on the remote host.
You must also have configured the daemon to associate a specific plugin command
with the [command] option you are specifying here. Upon receipt of the
[command] argument, the NRPE daemon will run the appropriate plugin command and
send the plugin output and return code back to *this* plugin. This allows you
to execute plugins on remote hosts and 'fake' the results to make Nagios think
the plugin is being run locally.

Re: How to configure to check mount status for a mount point

Posted: Tue Feb 25, 2020 10:10 am
by jdunitz
I think your problem may be that you're missing some quotes in the arguments you're passing to the plugin.


$ARG1$

Code: Select all

 check_mountpoints
$ARG2$

Code: Select all

 -a '-L -i /mnt/ecm'
After the -a, the command you pass to the plugin should be wrapped in single-quotes.

Hope that helps!

Re: How to configure to check mount status for a mount point

Posted: Tue Feb 25, 2020 11:41 am
by lgaddam
Wow!! Thanks!! Worked!!

Testing also good.

[root@p01 ~]# /usr/local/nagios/libexec/check_nrpe -H xx.xx.x..xx -t 500 -c check_mountpoints -a '-L -i /mnt/ecm'
OK: all mounts were found ( /mnt/ecm)
[root@p01 ~]# /usr/local/nagios/libexec/check_nrpe -H xx.xx.x..xx -t 500 -c check_mountpoints -a '-L -i /mnt/tcm'
CRITICAL: /mnt/tcm is not mounted ; /mnt/tcm doesn't exist on filesystem ;
[root@01 ~]#


You can lock Thread !! Solved My issue !! Many Thanks!!

Re: How to configure to check mount status for a mount point

Posted: Tue Feb 25, 2020 12:27 pm
by scottwilkerson
Great!

Locking thread