add new check
authorStephen Gran <steve@lobefin.net>
Sat, 29 Dec 2012 12:14:06 +0000 (12:14 +0000)
committerStephen Gran <steve@lobefin.net>
Sat, 29 Dec 2012 12:14:06 +0000 (12:14 +0000)
Signed-off-by: Stephen Gran <steve@lobefin.net>
dsa-nagios-checks/checks/dsa-check-filesystems [new file with mode: 0755]
dsa-nagios-checks/debian/changelog

diff --git a/dsa-nagios-checks/checks/dsa-check-filesystems b/dsa-nagios-checks/checks/dsa-check-filesystems
new file mode 100755 (executable)
index 0000000..4b74785
--- /dev/null
@@ -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
index 458e9ab..5d47be2 100644 (file)
@@ -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 <weasel@debian.org>  Wed, 19 Dec 2012 19:27:39 +0100
+ -- Stephen Gran <sgran@debian.org>  Sat, 29 Dec 2012 12:05:57 +0000
 
 dsa-nagios-checks (92.1) unstable; urgency=low