File check_mountpoints.py of Package nagios-plugins-nfs (Revision 2a929c0ab11dced76fb0409afe342c74)
Currently displaying revision 2a929c0ab11dced76fb0409afe342c74, show latest
1
#!/usr/bin/python
2
3
import string
4
import sys
5
6
fstab_content=open('/etc/fstab','r')
7
mountlist = list()
8
i=0
9
exitstatus=1
10
mounted=False
11
mountstate='Mounts not OK'
12
13
14
for line in fstab_content:
15
if '#' not in line and len(line) > 2 and 'nfs' in line:
16
(fstabfs,fstabmountpt,fstabtype,fstaboptions,fstabdump,fstabpass)=line.strip().split()
17
procmounts_content=open('/proc/mounts','r')
18
for line in procmounts_content:
19
((procfs,procmountpt,proctype,procoptions,procdump,procpass))=line.strip().split()
20
if fstabtype == 'nfs' and proctype == 'nfs':
21
if fstabmountpt == procmountpt:
22
mounted=True
23
procmounts_content.close()
24
if mounted:
25
exitstatus=0
26
mountstate='Mounts OK'
27
else:
28
exitstatus=1
29
mountstate="Mounts not OK"
30
print mountstate
31
sys.exit(exitstatus)
32
mounted=False
33
34
print mountstate
35
sys.exit(exitstatus)
36