diff options
-rw-r--r-- | README.md | 25 | ||||
-rwxr-xr-x | simpleton.py | 31 |
2 files changed, 55 insertions, 1 deletions
@@ -1,4 +1,27 @@ simpleton ========= -A simple tool to check that your services are up
\ No newline at end of file +A simple tool to check that your services are up. About as braindead as it gets, but better than nothing. ;-) + + +Installation +============ +1. Install prerequisites: + + sudo pip install pyyaml termcolor + +2. Create your ~/.simpleton.yaml file: + + HTTP: + - http://intra.example.com + + SMTP: + - mail.example.com + + FTP: + - files.example.com + +Todo +==== +- Add more protocol support, even simple socket connections would be good +- Deeper checks (SMTP sending, FTP logins, HTML parsing, etc) diff --git a/simpleton.py b/simpleton.py new file mode 100755 index 0000000..9f9ec64 --- /dev/null +++ b/simpleton.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +import time, os, sys +import urllib, ftplib, smtplib, yaml +from termcolor import colored, cprint + +if len(sys.argv) < 2 or not os.path.exists(sys.argv[1]): + fh = open(os.path.join(os.getenv('HOME'), '.simpleton.yaml')) + +services = yaml.load(fh) +tests, passed, started = (0, 0, time.time()) + +for k, v in services.items(): + for u in v: + tests += 1 + msg = '* testing %s: %s' % (k, u) + out = colored(msg, 'green') + try: + if k == 'HTTP': + urllib.urlopen(u) + if k == 'FTP': + ftplib.FTP(u) + if k == 'SMTP': + smtplib.SMTP(u) + passed += 1 + except Exception, e: + out = colored(msg, 'red') + + print out + +print '%d of %d tests passed in %d seconds' % (passed, tests, int(time.time() - started)) |