diff --git a/roles/nagios_client/files/scripts/check_readonly_fs b/roles/nagios_client/files/scripts/check_readonly_fs new file mode 100755 index 0000000000..cd2b1973a7 --- /dev/null +++ b/roles/nagios_client/files/scripts/check_readonly_fs @@ -0,0 +1,84 @@ +#!/bin/bash + +# check_readonlyfs: Check for readonly filesystems +# Copyright (C) 2010 Davide Madrisan + +PROGNAME=`/bin/basename $0` +PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` +REVISION=`echo '$Revision: 1 $' | sed -e 's/[^0-9.]//g'` + +. $PROGPATH/utils.sh + +print_usage() { + echo "Usage: $PROGNAME --no-network-fs" + echo "Usage: $PROGNAME --help" + echo "Usage: $PROGNAME --version" +} + +print_help() { + print_revision $PROGNAME $REVISION + echo "" + print_usage + echo "" + echo "readonly filesystem checker plugin for Nagios" + echo "" + support +} + +NETFS=1 + +# Grab the command line arguments + +exitstatus=$STATE_WARNING #default + +while test -n "$1"; do + case "$1" in + --help|-h) + print_help + exit $STATE_OK + ;; + --version|-V) + print_revision $PROGNAME $REVISION + exit $STATE_OK + ;; + --no-network-fs|-n) + NETFS="0" + ;; + *) + echo "Unknown argument: $1" + print_usage + exit $STATE_UNKNOWN + ;; + esac + shift +done + +[ -r /proc/mounts ] || { echo "cannot read /proc/mounts!"; exit $STATE_UNKNOWN; } + +nerr=0 +IFS_SAVE="$IFS" + +rofs_list="" +while read dev mp fs mopt ignore; do + [ "$dev" = none ] && continue + case $fs in binfmt_misc|devpts|iso9660|proc|selinuxfs|rpc_pipefs|sysfs|tmpfs|usbfs) + continue ;; + esac + case $fs in autofs|nfs|nfs4|smbfs) + # skip the network filesystems + [ "$NETFS" = 0 ] && continue ;; + esac + + IFS=","; set -- $mopt; IFS="$IFS_SAVE" + while :; do + case "$1" in + ro) rofs_list="$rofs_list $mp"; nerr=$(( $nerr + 1 )) ;; + "") shift; break ;; + esac + shift + done +done < <(LC_ALL=C /bin/cat /proc/mounts 2>/dev/null) + +[ $nerr -eq 0 ] && { echo OK; exit $STATE_OK; } || echo "$rofs_list: read only fs" + +exit $exitstatus diff --git a/roles/nagios_client/tasks/main.yml b/roles/nagios_client/tasks/main.yml index 4cafff151f..1d5a5b0fe8 100644 --- a/roles/nagios_client/tasks/main.yml +++ b/roles/nagios_client/tasks/main.yml @@ -33,6 +33,7 @@ - check_supybot_plugin - check_datanommer_timesince.py - check_memcache_connect + - check_readonly_fs when: not inventory_hostname.startswith('noc') tags: - nagios_client @@ -78,6 +79,7 @@ with_items: - check_mirrorlist_cache.cfg - check_raid.cfg + - check_readonly_fs.cfg - check_cron.cfg - check_disk.cfg - check_swap.cfg diff --git a/roles/nagios_client/templates/check_disk.cfg.j2 b/roles/nagios_client/templates/check_disk.cfg.j2 index c20da22c5d..6eb12a676a 100644 --- a/roles/nagios_client/templates/check_disk.cfg.j2 +++ b/roles/nagios_client/templates/check_disk.cfg.j2 @@ -1,2 +1,3 @@ command[check_disk_/]={{ libdir }}/nagios/plugins/check_disk -w 15% -c 10% -p / command[check_disk_/boot]={{ libdir }}/nagios/plugins/check_disk -w 15% -c 10% -p /boot +command[check_disk_/srv/cache/lookaside]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /srv/cache/lookaside diff --git a/roles/nagios_client/templates/check_readonly_fs.cfg.j2 b/roles/nagios_client/templates/check_readonly_fs.cfg.j2 new file mode 100644 index 0000000000..df896b7dc3 --- /dev/null +++ b/roles/nagios_client/templates/check_readonly_fs.cfg.j2 @@ -0,0 +1 @@ +command[check_readonly_fs]=/usr/lib64/nagios/plugins/check_readonly_fs