PEP8 the rest of the file
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import string, os
|
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 "Content-type: text/html"
|
||||||
print "max-age: 0"
|
print "max-age: 0"
|
||||||
@@ -24,35 +24,35 @@ print "<pre>"
|
|||||||
|
|
||||||
|
|
||||||
def hstlines(host):
|
def hstlines(host):
|
||||||
cmd="/sbin/ping -c 1 -w 2 %s 2>&1 >/dev/null" % host
|
cmd = "/sbin/ping -c 1 -w 2 %s 2>&1 >/dev/null" % host
|
||||||
r=os.system(cmd)
|
r = os.system(cmd)
|
||||||
if r == 0:
|
if r == 0:
|
||||||
p=os.popen("rsh %s tail -200 .heyu/logs/motion.log | grep -v again | tail -32" % host, "r")
|
p = os.popen("rsh %s tail -200 .heyu/logs/motion.log | grep -v again | tail -32" % host, "r")
|
||||||
l=p.readlines()
|
l = p.readlines()
|
||||||
else:
|
else:
|
||||||
l=["<B>Host %s is unreachable</B> " % host]
|
l = ["<B>Host %s is unreachable</B> " % host]
|
||||||
return l
|
return l
|
||||||
|
|
||||||
rep=[]
|
rep = []
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
rep.append(hstlines(host))
|
rep.append(hstlines(host))
|
||||||
|
|
||||||
print '<table cellpading="0" cellspacing="0" border="0" style="color:black;text-align:left">'
|
print '<table cellpading="0" cellspacing="0" border="0" style="color:black;text-align:left">'
|
||||||
i=0
|
i = 0
|
||||||
print "<tr><th>%s</th></tr>" % string.join(hosts,'</th><th>')
|
print "<tr><th>%s</th></tr>" % string.join(hosts, '</th><th>')
|
||||||
while 1:
|
while 1:
|
||||||
line=[]
|
line = []
|
||||||
f=0
|
f = 0
|
||||||
for h in rep:
|
for h in rep:
|
||||||
try:
|
try:
|
||||||
line.append(h[i][:-1])
|
line.append(h[i][:-1])
|
||||||
f=1
|
f = 1
|
||||||
except:
|
except:
|
||||||
line.append("")
|
line.append("")
|
||||||
if f == 0:
|
if f == 0:
|
||||||
break
|
break
|
||||||
print "<tr><td>%s</td></tr>" % string.join(line,' </td><td>')
|
print "<tr><td>%s</td></tr>" % string.join(line, ' </td><td>')
|
||||||
i+=1
|
i += 1
|
||||||
print '</table></pre>'
|
print '</table></pre>'
|
||||||
|
|
||||||
execfile("/home/andreas/cgi-bin/trailer.py")
|
execfile("/home/andreas/cgi-bin/trailer.py")
|
||||||
|
|||||||
@@ -1,52 +1,58 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
# Monitor Interfaces, send hb msg when add changes
|
# Monitor Interfaces, send hb msg when add changes
|
||||||
import time, os, sys
|
import time
|
||||||
|
import os
|
||||||
|
|
||||||
SLEEP=60
|
SLEEP = 60
|
||||||
SRV="colo2.wapanafa.org"
|
SRV = "colo2.wapanafa.org"
|
||||||
DBG=0
|
DBG = 0
|
||||||
|
|
||||||
home=os.environ.get('HOME','/var/tmp')
|
home = os.environ.get('HOME', '/var/tmp')
|
||||||
HBC="%s/bin/hbc" % home
|
HBC = "%s/bin/hbc" % home
|
||||||
|
|
||||||
IFS=[]
|
IFS = []
|
||||||
f=os.popen('/sbin/ifconfig -a 2>/dev/null', 'r')
|
f = os.popen('/sbin/ifconfig -a 2>/dev/null', 'r')
|
||||||
for l in f.readlines():
|
for l in f.readlines():
|
||||||
if len(l) > 1 and not l[0] in [' ','\t']:
|
if len(l) > 1 and not l[0] in [' ', '\t']:
|
||||||
r=l.split()
|
r = l.split()
|
||||||
if DBG: print r
|
if DBG:
|
||||||
|
print r
|
||||||
if r[0][-1] == ':':
|
if r[0][-1] == ':':
|
||||||
r[0]=r[0][:-1]
|
r[0] = r[0][:-1]
|
||||||
if r[0][:2] == 'lo':
|
if r[0][:2] == 'lo':
|
||||||
continue
|
continue
|
||||||
IFS.append(r[0])
|
IFS.append(r[0])
|
||||||
if DBG: print IFS
|
if DBG:
|
||||||
addrs={}
|
print IFS
|
||||||
|
addrs = {}
|
||||||
for I in IFS:
|
for I in IFS:
|
||||||
addrs[I]=""
|
addrs[I] = ""
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
|
|
||||||
for I in IFS:
|
for I in IFS:
|
||||||
f=os.popen('/sbin/ifconfig %s 2>/dev/null' % I, 'r')
|
f = os.popen('/sbin/ifconfig %s 2>/dev/null' % I, 'r')
|
||||||
ifaddrs=[]
|
ifaddrs = []
|
||||||
for l in f.readlines():
|
for l in f.readlines():
|
||||||
r=l.split()
|
r = l.split()
|
||||||
if DBG > 1: print "x2", r
|
if DBG > 1:
|
||||||
|
print "x2", r
|
||||||
if len(r) == 0 or (r[0] != 'inet' and r[0] != 'inet6'):
|
if len(r) == 0 or (r[0] != 'inet' and r[0] != 'inet6'):
|
||||||
continue
|
continue
|
||||||
if r[1].find('addr:') == 0:
|
if r[1].find('addr:') == 0:
|
||||||
ifaddr=r[1][5:]
|
ifaddr = r[1][5:]
|
||||||
else:
|
else:
|
||||||
ifaddr=r[1]
|
ifaddr = r[1]
|
||||||
ifaddrs.append(ifaddr)
|
ifaddrs.append(ifaddr)
|
||||||
|
|
||||||
if ifaddrs != [] and ifaddrs != addrs[I]:
|
if ifaddrs != [] and ifaddrs != addrs[I]:
|
||||||
msg='%s -m "ifadd %s %s" %s' % (HBC, I, ",".join(ifaddrs), SRV)
|
msg = '%s -m "ifadd %s %s" %s' % (HBC, I, ",".join(ifaddrs), SRV)
|
||||||
if DBG: print msg
|
if DBG:
|
||||||
else: os.system(msg)
|
print msg
|
||||||
addrs[I]=ifaddrs
|
else:
|
||||||
|
os.system(msg)
|
||||||
|
addrs[I] = ifaddrs
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
time.sleep(SLEEP)
|
time.sleep(SLEEP)
|
||||||
|
|||||||
Reference in New Issue
Block a user