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) |