/[svn.andrew.net.au]/scripts/check_filesystem
ViewVC logotype

Diff of /scripts/check_filesystem

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 43 by apollock, Sat Jul 19 23:57:10 2008 UTC revision 44 by apollock, Mon Jul 21 05:35:01 2008 UTC
# Line 4  from optparse import OptionParser Line 4  from optparse import OptionParser
4  import sys  import sys
5    
6  parser = OptionParser()  parser = OptionParser()
7    # TODO: add option parsing
8  (options, args) = parser.parse_args()  (options, args) = parser.parse_args()
9    
10    READABLE_MOUNTS = {
11        "rw" : "read-write",
12        "ro" : "read-only",
13      }
14    
15  mounts = {}  mounts = {}
16    
17  try:  try:
18          procmounts = open("/proc/mounts")    proc_mounts = open("/proc/mounts")
19    
20          for mount in procmounts:    for mount in proc_mounts:
21                  mounts[mount.split(" ")[1]] = mount.split(" ")[3].split(",")[0]      mounts[mount.split(" ")[1]] = mount.split(" ")[3].split(",")[0]
22    
23          procmounts.close()    proc_mounts.close()
24  except IOError, e:  except IOError, e:
25          print "UNKNOWN: %s" % e    print "FILESYSTEM UNKNOWN: %s" % e
26          sys.exit(3)    sys.exit(3)
27    
28  if args[0] not in mounts:  if args[0] not in mounts:
29          state = "UNKNOWN"    print "FILESYSTEM UNKNOWN: %s is not currently mounted" % (args[0])
30          print "%s: %s is not currently mounted" % (state, args[0])    sys.exit(3)
         sys.exit(3)  
31    
32  if mounts[args[0]] != args[1]:  if mounts[args[0]] != args[1]:
33          state = "CRITICAL"    print "FILESYSTEM CRITICAL: %s is mounted %s" % (args[0],
34          print "%s: %s is %s" % (state, args[0], mounts[args[0]])      READABLE_MOUNTS[mounts[args[0]]])
35          sys.exit(2)    sys.exit(2)
36  else:  else:
37          state = "OK"    print "FILESYSTEM OK: %s is mounted %s" % (args[0],
38          print "%s: %s is %s" % (state, args[0], mounts[args[0]])      READABLE_MOUNTS[mounts[args[0]]])
39          sys.exit(0)    sys.exit(0)

Legend:
Removed from v.43  
changed lines
  Added in v.44

  ViewVC Help
Powered by ViewVC 1.1.22