From: Stephen Gran Date: Sat, 29 Dec 2012 12:14:06 +0000 (+0000) Subject: add new check X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=d6e0e373c910d25d8b89a0f34f777304132e807c;hp=bced3d90b5061225f82a9c024f8a7e6af7d6f63c;p=mirror%2Fdsa-nagios.git add new check Signed-off-by: Stephen Gran --- diff --git a/dsa-nagios-checks/checks/dsa-check-filesystems b/dsa-nagios-checks/checks/dsa-check-filesystems new file mode 100755 index 0000000..4b74785 --- /dev/null +++ b/dsa-nagios-checks/checks/dsa-check-filesystems @@ -0,0 +1,42 @@ +#!/usr/bin/ruby + +require 'filesystem' + +ignorefs = ["NFS", "nfs", "nfs4", "nfsd", "afs", "binfmt_misc", "proc", "smbfs", + "autofs", "iso9660", "ncpfs", "coda", "devpts", "ftpfs", "devfs", + "mfs", "shfs", "sysfs", "cifs", "lustre_lite", "tmpfs", "usbfs", + "udf", "fusectl", "fuse.snapshotfs", "rpc_pipefs"] +mountpoints = {} + +FileSystem.mounts.each do |m| + if ((not ignorefs.include?(m.fstype)) && (m.options !~ /bind/)) + mountpoints[m.device] = { 'type' => m.fstype, 'mount' => m.mount } + end +end + +def check_ext3(dev, mnt) + output=%x{tune2fs -l #{dev}} + if output =~ /FS Error count:\s*(\d+)/ and $1.to_i > 0 + return "#{dev} (#{mnt}) has #{$1} errors" + end +end + +output = [] +mountpoints.keys.each do |m| + temp = '' + begin + if mountpoints[m]['type'] =~ /ext/ + temp = check_ext3(m, mountpoints[m]['mount']) + end + rescue Exception => e + end + if temp + output << temp + end +end + +if output.length > 0 + puts output.join("\n") + exit 1 +end +exit 0 diff --git a/dsa-nagios-checks/debian/changelog b/dsa-nagios-checks/debian/changelog index 458e9ab..5d47be2 100644 --- a/dsa-nagios-checks/debian/changelog +++ b/dsa-nagios-checks/debian/changelog @@ -25,6 +25,7 @@ dsa-nagios-checks (9X) Xnstable; urgency=low * dsa-check-udldap-freshness: check new last_update.trace if it exists instead of /var/lib/misc/thishost/passwd.{db,tdb}. * dsa-check-statusfile: Complain if there is no extended information + * add dsa-check-filesystems (only checks ext at the moment) [ Uli Martens ] * dsa-check-soas: Add --no-soa-ns flag. @@ -32,7 +33,7 @@ dsa-nagios-checks (9X) Xnstable; urgency=low [ Martin Zobel-Helas ] * Add dsa-check-drbd, taken from http://code.google.com/p/ganeti/wiki/DrbdDevicesMonitoring - -- Peter Palfrader Wed, 19 Dec 2012 19:27:39 +0100 + -- Stephen Gran Sat, 29 Dec 2012 12:05:57 +0000 dsa-nagios-checks (92.1) unstable; urgency=low