diff --git a/mlog.cgi b/mlog.cgi
index 55dcd5d..63127ca 100755
--- a/mlog.cgi
+++ b/mlog.cgi
@@ -1,11 +1,11 @@
#!/usr/bin/env python
import string, os
-VER="mlog 1.00"
+VER = "mlog 1.00"
-hosts=["weekend", "wingbat"]
+hosts = ["weekend", "wingbat"]
-URI="/~andreas/private/mlog.cgi?"
+URI = "/~andreas/private/mlog.cgi?"
print "Content-type: text/html"
print "max-age: 0"
@@ -24,35 +24,35 @@ print "
"
def hstlines(host):
- cmd="/sbin/ping -c 1 -w 2 %s 2>&1 >/dev/null" % host
- r=os.system(cmd)
+ cmd = "/sbin/ping -c 1 -w 2 %s 2>&1 >/dev/null" % host
+ r = os.system(cmd)
if r == 0:
- p=os.popen("rsh %s tail -200 .heyu/logs/motion.log | grep -v again | tail -32" % host, "r")
- l=p.readlines()
+ p = os.popen("rsh %s tail -200 .heyu/logs/motion.log | grep -v again | tail -32" % host, "r")
+ l = p.readlines()
else:
- l=["Host %s is unreachable " % host]
+ l = ["Host %s is unreachable " % host]
return l
-rep=[]
-for host in hosts:
+rep = []
+for host in hosts:
rep.append(hstlines(host))
print ''
-i=0
-print "| %s |
" % string.join(hosts,'')
+i = 0
+print " | | %s |
" % string.join(hosts, '')
while 1:
- line=[]
- f=0
+ line = []
+ f = 0
for h in rep:
try:
line.append(h[i][:-1])
- f=1
+ f = 1
except:
line.append("")
if f == 0:
break
- print " | | %s |
" % string.join(line,' ')
- i+=1
+ print " | | %s |
" % string.join(line, ' ')
+ i += 1
print ' |
'
execfile("/home/andreas/cgi-bin/trailer.py")
diff --git a/monif b/monif
index fa3e92c..dd92915 100755
--- a/monif
+++ b/monif
@@ -1,52 +1,58 @@
#!/usr/bin/env python
# Monitor Interfaces, send hb msg when add changes
-import time, os, sys
+import time
+import os
-SLEEP=60
-SRV="colo2.wapanafa.org"
-DBG=0
+SLEEP = 60
+SRV = "colo2.wapanafa.org"
+DBG = 0
-home=os.environ.get('HOME','/var/tmp')
-HBC="%s/bin/hbc" % home
+home = os.environ.get('HOME', '/var/tmp')
+HBC = "%s/bin/hbc" % home
-IFS=[]
-f=os.popen('/sbin/ifconfig -a 2>/dev/null', 'r')
+IFS = []
+f = os.popen('/sbin/ifconfig -a 2>/dev/null', 'r')
for l in f.readlines():
- if len(l) > 1 and not l[0] in [' ','\t']:
- r=l.split()
- if DBG: print r
+ if len(l) > 1 and not l[0] in [' ', '\t']:
+ r = l.split()
+ if DBG:
+ print r
if r[0][-1] == ':':
- r[0]=r[0][:-1]
+ r[0] = r[0][:-1]
if r[0][:2] == 'lo':
continue
IFS.append(r[0])
-if DBG: print IFS
-addrs={}
+if DBG:
+ print IFS
+addrs = {}
for I in IFS:
- addrs[I]=""
+ addrs[I] = ""
while 1:
for I in IFS:
- f=os.popen('/sbin/ifconfig %s 2>/dev/null' % I, 'r')
- ifaddrs=[]
+ f = os.popen('/sbin/ifconfig %s 2>/dev/null' % I, 'r')
+ ifaddrs = []
for l in f.readlines():
- r=l.split()
- if DBG > 1: print "x2", r
- if len(r) == 0 or (r[0] != 'inet' and r[0] != 'inet6'):
+ r = l.split()
+ if DBG > 1:
+ print "x2", r
+ if len(r) == 0 or (r[0] != 'inet' and r[0] != 'inet6'):
continue
if r[1].find('addr:') == 0:
- ifaddr=r[1][5:]
+ ifaddr = r[1][5:]
else:
- ifaddr=r[1]
+ ifaddr = r[1]
ifaddrs.append(ifaddr)
if ifaddrs != [] and ifaddrs != addrs[I]:
- msg='%s -m "ifadd %s %s" %s' % (HBC, I, ",".join(ifaddrs), SRV)
- if DBG: print msg
- else: os.system(msg)
- addrs[I]=ifaddrs
+ msg = '%s -m "ifadd %s %s" %s' % (HBC, I, ",".join(ifaddrs), SRV)
+ if DBG:
+ print msg
+ else:
+ os.system(msg)
+ addrs[I] = ifaddrs
f.close()
time.sleep(SLEEP)