From dca858dd87d262f665dd5625f17e31b0c9710088 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Wed, 19 Dec 2012 09:53:03 +0200 Subject: Second commit --- README.md | 25 ++++++++++++++++++++++++- simpleton.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100755 simpleton.py diff --git a/README.md b/README.md index d1684bc..41cfe79 100644 --- a/README.md +++ b/README.md @@ -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)) -- cgit v1.2.3