Add NFS monitoring to database servers
authorMichael Peters <mpeters@emeralddata.net>
Wed, 15 May 2013 14:56:33 +0000 (10:56 -0400)
committerAndy Witter <awitter@georgialibraries.org>
Wed, 15 May 2013 14:56:33 +0000 (10:56 -0400)
Signed-off-by: Andy Witter <awitter@georgialibraries.org>
GenaSYS.sh
templates/monitor/check_nfs.sh [new file with mode: 0755]
templates/monitor/nrpe_local.cfg
templates/monitor/services.cfg

index 3dde83a..9427f38 100755 (executable)
@@ -2234,6 +2234,7 @@ echo 'cp "${WD}/monitoring/check_cpu.sh" "/usr/lib/nagios/plugins"' >>$TMPSETUPM
 echo 'cp "${WD}/monitoring/reporter_status.sh" "/usr/lib/nagios/plugins"' >>$TMPSETUPMONITOR
 echo 'cp "${WD}/monitoring/check_lock" "/usr/lib/nagios/plugins"' >>$TMPSETUPMONITOR
 echo 'cp "${WD}/monitoring/check_file_age" "/usr/lib/nagios/plugins"' >>$TMPSETUPMONITOR
+echo 'cp "${WD}/monitoring/check_nfs.sh" "/usr/lib/nagios/plugins"' >>$TMPSETUPMONITOR
 echo 'cp "${WD}/monitoring/nrpe_local.cfg" "/etc/nagios"' >>$TMPSETUPMONITOR
 chmod 755 $TMPSETUPMONITOR
 
@@ -2463,6 +2464,7 @@ cp "$TEMPLATEDIR/monitor/nrpe_local.cfg" "setup_${NODE_FOLDER}/monitoring"
 cp "$TEMPLATEDIR/monitor/reporter_status.sh" "setup_${NODE_FOLDER}/monitoring"
 cp "$TEMPLATEDIR/monitor/check_file_age" "setup_${NODE_FOLDER}/monitoring"
 cp "$TEMPLATEDIR/monitor/check_lock" "setup_${NODE_FOLDER}/monitoring"
+cp "$TEMPLATEDIR/monitor/check_nfs.sh" "setup_${NODE_FOLDER}/monitoring"
 
 if [[ "$USE_HOSTNAME_PREFIX" = "y" || "$USE_HOSTNAME_PREFIX" = "Y" ]] #TODO check this use strip prefix instead
 then
diff --git a/templates/monitor/check_nfs.sh b/templates/monitor/check_nfs.sh
new file mode 100755 (executable)
index 0000000..8399f07
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/bash
+# 
+## FILE: check_nfs.sh
+##
+## DESCRIPTION: This is a nagios compatible script to checks NFS mounts against what 
+##                                                     should be mounted in /etc/fstab and if there is a stale mount.
+##
+## AUTHOR: Dennis Ruzeski (denniruz@gmail.com)
+##
+## Creation Date: 1/23/2013
+##
+## Last Modified: 1/25/2013
+## 
+## VERSION: 1.0
+##
+## USAGE: ./check_nfs.sh
+##        This version takes no arguments
+##
+## TODO: Improve the check for stale mounts, add command line arguments to provide the ability to 
+##                      check mount statut, stale mounts, and latency separately.
+#
+declare -a nfs_mounts=( $(grep -v ^\# /etc/fstab |grep nfs |awk '{print $2}') )
+declare -a MNT_STATUS
+declare -a SFH_STATUS
+for mount_type in ${nfs_mounts[@]} ; do 
+       if [ $(stat -f -c '%T' ${mount_type}) = nfs ]; then 
+               read -t3 < <(stat -t ${mount_type})
+                       if [ $? -ne 0 ]; then
+                       SFH_STATUS=("${SFH_STATUS[@]}" "ERROR: ${mount_type} might be stale.")
+                       else
+                       MNT_STATUS=("${MNT_STATUS[@]}" "OK: ${mount_type} is ok.") 
+                       fi      
+               else 
+               MNT_STATUS=("${MNT_STATUS[@]}" "ERROR: ${mount_type} is not properly mounted.")
+fi 
+done
+echo ${MNT_STATUS[@]} ${SFH_STATUS[@]} |grep -q ERROR 
+       if [ $? -eq 0 ]; then
+               RETVAL=2
+        echo "CRITICAL - NFS mounts may be stale or unavailable"
+       else
+               RETVAL=0
+        echo "OK - NFS mounts are functioning within normal operating parameters"
+       fi
+unset -v MNT_STATUS
+unset -v SFH_STATUS
+exit ${RETVAL}
+
+
index c70bf7c..e4f0185 100644 (file)
@@ -26,3 +26,6 @@ command[fines_lock_age]=/usr/lib/nagios/plugins/check_file_age -w 10800 -c 14400
 
 # CPU I/O
 command[check_cpu_io]=/usr/lib/nagios/plugins/check_cpu.sh -iw 30 -ic 50
+
+# Check NFS Mounts
+command[check_nfs]=/usr/lib/nagios/plugins/check_nfs.sh
index 52642d0..09b8887 100644 (file)
@@ -136,3 +136,14 @@ define service {
         check_command                   check_nrpe!fines_lock_age!3600!5400
 }
 
+#=============#
+# NFS Mounts  #
+#=============#
+define service {
+        hostgroup_name                  db-servers
+        service_description             Check Backups NFS Mount
+        use                             generic-service
+        notification_interval           240
+        check_command                   check_nrpe!check_nfs!/var/backups
+}
+