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

Annotation of /scripts/check_filesystem

Parent Directory Parent Directory | Revision Log Revision Log


Revision 44 - (hide annotations)
Mon Jul 21 05:35:01 2008 UTC (15 years, 2 months ago) by apollock
File size: 841 byte(s)
Largely cosmetic changes:
* made indentation 2 spaces
* reworded messages

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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.22