Created
June 8, 2015 04:03
-
-
Save arbinish/d1f3844d6b3767eaf836 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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