--- scripts/check_filesystem 2008/07/19 23:57:10 43 +++ scripts/check_filesystem 2008/07/21 05:35:01 44 @@ -4,31 +4,36 @@ import sys parser = OptionParser() +# TODO: add option parsing (options, args) = parser.parse_args() +READABLE_MOUNTS = { + "rw" : "read-write", + "ro" : "read-only", + } + mounts = {} try: - procmounts = open("/proc/mounts") + proc_mounts = open("/proc/mounts") - for mount in procmounts: - mounts[mount.split(" ")[1]] = mount.split(" ")[3].split(",")[0] + for mount in proc_mounts: + mounts[mount.split(" ")[1]] = mount.split(" ")[3].split(",")[0] - procmounts.close() + proc_mounts.close() except IOError, e: - print "UNKNOWN: %s" % e - sys.exit(3) + print "FILESYSTEM UNKNOWN: %s" % e + sys.exit(3) if args[0] not in mounts: - state = "UNKNOWN" - print "%s: %s is not currently mounted" % (state, args[0]) - sys.exit(3) + print "FILESYSTEM UNKNOWN: %s is not currently mounted" % (args[0]) + sys.exit(3) if mounts[args[0]] != args[1]: - state = "CRITICAL" - print "%s: %s is %s" % (state, args[0], mounts[args[0]]) - sys.exit(2) + print "FILESYSTEM CRITICAL: %s is mounted %s" % (args[0], + READABLE_MOUNTS[mounts[args[0]]]) + sys.exit(2) else: - state = "OK" - print "%s: %s is %s" % (state, args[0], mounts[args[0]]) - sys.exit(0) + print "FILESYSTEM OK: %s is mounted %s" % (args[0], + READABLE_MOUNTS[mounts[args[0]]]) + sys.exit(0)