added check_mount.sh to check docker2:/Media mount
This commit is contained in:
parent
9f252f70a2
commit
e9ff747162
|
@ -0,0 +1,125 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
Copyright="(C) 2016-2018 - Carlos Ijalba GPLv3" # <perkolator @ gmail.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
########################################################################################################################
|
||||
#
|
||||
# Program: check_mount.sh
|
||||
#
|
||||
# Parameters:
|
||||
# $1 - FS to check --MANDATORY--
|
||||
# $2 - Mount type [ nfs3 | nfs4 | cifs | jfs2 | procfs | ext3 | ext4... ] --OPTIONAL-- (NFS by default)
|
||||
#
|
||||
# Output:
|
||||
# 3 - Error: No FS passed on parameter $1.
|
||||
# 2 - CRITICAL: FS not OK, the FS specified is not mounted by $2.
|
||||
# 1 - WARNING: FS not OK, the FS specified is mounted several times (it might not be a problem).
|
||||
# 0 - OK: FS OK, the FS specified has an instance mounted under $2 mount type.
|
||||
#
|
||||
# Description:
|
||||
#
|
||||
# Shell Script for Nagios, checks if the FS passed on $1 is mounted under Mount Type $2. If no parameter passed on $2
|
||||
# NFS type is assumed by default. This script do not check fstab or /etc/filesystem or other tab entries, as it is
|
||||
# designed to consume as little CPU time as possible and to be used in different OS types.
|
||||
#
|
||||
# It is a simple script, but it detects mounts of practically any type of FS, and multiple instances mounted of the same FS.
|
||||
#
|
||||
# Verified compatible with the following OS:
|
||||
# IBM AIX v5.2-v7.2
|
||||
# RHEL v4.8-v6.6, RHL v9
|
||||
# Ubuntu v10.04-v18.04 LTS
|
||||
# SuSe v11
|
||||
# CentOS v6.5-10
|
||||
# CygWin v2.0.4-v2.5.1 & BusyBox v1.22.1
|
||||
# Oracle Solaris x86 v10-v11.3
|
||||
# SCO OpenServer v6.0.0
|
||||
# SCO UnixWare v7.1.4+, v7.1.4
|
||||
#
|
||||
# Versions Date Programmer, Modification
|
||||
# ------------ ---------- ----------------------------------------------------
|
||||
# Version=1.00 03/06/2016 Carlos Ijalba, Original version.
|
||||
# Version=1.01 10/06/2016 Carlos Ijalba, GPLv3 open source release.
|
||||
Version=1.02 # 21/08/2018 Carlos Ijalba, corrected bug (suggested by candreasen) & added small speedup & version control.
|
||||
#
|
||||
########################################################################################################################
|
||||
#set -x
|
||||
|
||||
# Constants
|
||||
|
||||
PROGRAM=$(basename $0) # Name of this script
|
||||
NAGIOS_ERROR=3
|
||||
NAGIOS_CRIT=2
|
||||
NAGIOS_WARN=1
|
||||
NAGIOS_OK=0
|
||||
|
||||
|
||||
# Usage
|
||||
|
||||
if [ $# -lt 1 ]
|
||||
then
|
||||
cat << EOF
|
||||
$PROGRAM v$Version - $Copyright
|
||||
|
||||
ERROR - No FS passed under parameter \$1
|
||||
|
||||
USE:
|
||||
check_mount.sh [ \$1 - Filesystem ] | optional: [ \$2 - Type (NFS by default)]
|
||||
|
||||
Reports:
|
||||
OK - \$1 mounted under \$2.
|
||||
CRITICAL - \$1 not mounted under \$2.
|
||||
WARNING - \$1 is mounted several times! (number of times mounted)
|
||||
|
||||
Examples:
|
||||
check_mount.sh /developer/logs <-- check NFS mount of /developer/logs
|
||||
check_mount.sh /developer cifs <-- check CIFS mount of /developer
|
||||
check_mount.sh /ora12c nfs4 <-- check NFSv4 mount of /ora12c
|
||||
check_mount.sh /db2 ext3 <-- check EXT3 mount of /db2
|
||||
check_mount.sh /CICS jfs2 <-- check JFS2 mount of /CICS
|
||||
|
||||
EOF
|
||||
RC=$NAGIOS_ERROR
|
||||
exit $RC
|
||||
fi
|
||||
FS=$1
|
||||
|
||||
|
||||
# Main
|
||||
|
||||
MOUNT=$2
|
||||
if [ -z "$MOUNT" ]
|
||||
then
|
||||
MOUNT="nfs" # if $2 not specified, assume NFS by default
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
echo $MSG
|
||||
echo $PROGRAM v$Version
|
||||
exit $RC
|
||||
|
||||
# End
|
|
@ -45,6 +45,9 @@ command[check_docker_dhcpd]=/usr/lib/nagios/plugins/check_docker.sh -n dhcpd -s
|
|||
command[check_k8s_api]=/usr/lib/nagios/plugins/check_kubernetes_api.sh -k /home/nagios/.kube/config
|
||||
command[check_k8s_nodes]=/usr/lib/nagios/plugins/check_kube_nodes.sh -k /home/nagios/.kube/config
|
||||
|
||||
# docker2
|
||||
command[check_media]=/usr/lib/nagios/plugins/check_mount.sh /Media cifs
|
||||
|
||||
# pi4 nodes
|
||||
command[check_docker_rpi-monitor]=/usr/lib/nagios/plugins/check_docker.sh -n rpi-monitor -s
|
||||
|
||||
|
|
|
@ -30,6 +30,14 @@
|
|||
owner: root
|
||||
group: root
|
||||
|
||||
- name: copy check_mount.sh file to /lib/nagios/plugins
|
||||
template:
|
||||
src: files/check_mount.sh
|
||||
dest: /lib/nagios/plugins/check_mount.sh
|
||||
mode: "0755"
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: copy nrpe.cfg file to /etc/nagios
|
||||
template:
|
||||
src: files/nrpe.cfg.j2
|
||||
|
|
Loading…
Reference in New Issue