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

Contents of /scripts/check_filesystem

Parent Directory Parent Directory | Revision Log Revision Log


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

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