All pastes #579334 Raw Edit

Something

public text v1 · immutable
·published 2007-06-20 16:46 UTC
rendered paste body
#!/usr/bin/env python

import os, fnmatch

def all_files(root, patterns='*', single_level=False, yield_folders=False):
    # Expand patterns from semicolon-separated string to list
    patterns = patterns.split(';')
    for path, subdirs, files in os.walk(root):
        if yield_folders:
            files.extend(subdirs)
        files.sort()
        for name in files:
            for pattern in patterns:
                if fnmatch.fnmatch(name, pattern):
                    yield os.path.join(path, name)
                    break
            if single_level:
                break


all_hosts = os.path.expanduser('~/all_hosts')
file = open(all_hosts)
myline = file.readline()
allhost_list = myline.split(' ')
missing_hosts = []

print allhosts_list

for path in all_files(os.path.expanduser('~/nagios_audit'), '*.cfg'):
    if os.path.basename(path).strip('-EMS.cfg') not in allhost_list:
        missing_hosts.append(os.path.basename(path).strip('-EMS.cfg'))

print missing_hosts