aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@0x00.co>2012-12-19 09:53:03 +0200
committerFilipp Lepalaan <f@0x00.co>2012-12-19 09:53:03 +0200
commitdca858dd87d262f665dd5625f17e31b0c9710088 (patch)
tree4d8418ce20deec8860202ffde0254dacd678c714
parent6b1c810664f5e40f1595cdbca37215373438fb0a (diff)
downloadsimpleton-dca858dd87d262f665dd5625f17e31b0c9710088.tar.gz
simpleton-dca858dd87d262f665dd5625f17e31b0c9710088.tar.bz2
simpleton-dca858dd87d262f665dd5625f17e31b0c9710088.zip
Second commit
-rw-r--r--README.md25
-rwxr-xr-xsimpleton.py31
2 files changed, 55 insertions, 1 deletions
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))