Skip to content

Instantly share code, notes, and snippets.

@insom
Created January 19, 2011 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save insom/786237 to your computer and use it in GitHub Desktop.
Save insom/786237 to your computer and use it in GitHub Desktop.
Check if any process is running that we're not expecting.
#!/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