Created
January 19, 2011 14:33
-
-
Save insom/786237 to your computer and use it in GitHub Desktop.
Check if any process is running that we're not expecting.
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
#!/usr/bin/python | |
from glob import glob | |
import re, sys | |
okay_re = [re.compile(x) for x in [ r'proftpd', r'apache2', r'upload.py', r'getty', r'munin-node', r'inetd', r'init', r'check_horsebolted', r'upstart.udev', r'portmap', r'irqbalance', r'puppet', r'nrpe', r'udevd', r'sshd', r'atd', r'mdadm', r'rsync', r'fail2ban', r'exim4', r'rsyslogd', r'cron', r'ntpd', r'mcollective', r'mysqld', r'bash', r'sleep', r'sync.php', r'queue.php', r'CRON', ]] | |
res = ([z for z in [open(x,'r').read() for x in glob('/proc/*/cmdline')] if not [y for y in okay_re if y.search(z)] and z]) | |
print res | |
sys.exit(res and 2 or 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment