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

Contents of /scripts/check_filesystem

Parent Directory Parent Directory | Revision Log Revision Log


Revision 43 - (show annotations)
Sat Jul 19 23:57:10 2008 UTC (15 years, 4 months ago) by apollock
File size: 685 byte(s)
Initial check-in of script to monitor filesystems for being correctly mounted

1 #!/usr/bin/python
2
3 from optparse import OptionParser
4 import sys
5
6 parser = OptionParser()
7 (options, args) = parser.parse_args()
8
9 mounts = {}
10
11 try:
12 procmounts = open("/proc/mounts")
13
14 for mount in procmounts:
15 mounts[mount.split(" ")[1]] = mount.split(" ")[3].split(",")[0]
16
17 procmounts.close()
18 except IOError, e:
19 print "UNKNOWN: %s" % e
20 sys.exit(3)
21
22 if args[0] not in mounts:
23 state = "UNKNOWN"
24 print "%s: %s is not currently mounted" % (state, args[0])
25 sys.exit(3)
26
27 if mounts[args[0]] != args[1]:
28 state = "CRITICAL"
29 print "%s: %s is %s" % (state, args[0], mounts[args[0]])
30 sys.exit(2)
31 else:
32 state = "OK"
33 print "%s: %s is %s" % (state, args[0], mounts[args[0]])
34 sys.exit(0)

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.22