Skip to content

Instantly share code, notes, and snippets.

@arbinish
Created June 8, 2015 04:03
Show Gist options
  • Save arbinish/d1f3844d6b3767eaf836 to your computer and use it in GitHub Desktop.
Save arbinish/d1f3844d6b3767eaf836 to your computer and use it in GitHub Desktop.
import sys
from subprocess import PIPE, Popen
fd = open('/etc/fstab')
mounts = set([])
for line in fd:
line = line.strip()
if line.startswith('#'):
continue
mnt_point = line.split()
if len(mnt_point) < 2:
continue
if mnt_point[1].startswith('/'):
mounts.add(mnt_point[1].strip())
fd.close()
sys_mount = set([])
p = Popen(['mount'], stdout=PIPE, stderr=PIPE)
stdout, stdrr = p.communicate()
for line in stdout.splitlines():
mnt_point = line.split()
if len(mnt_point) < 2:
continue
sys_mount.add(mnt_point[2].strip())
#print mounts
#print sys_mount
missing_mounts = mounts.difference(sys_mount)
if len(missing_mounts) > 0:
print ">>> following mounts are missing"
for m in missing_mounts:
print m
else:
print "mount check passed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment