Changeset 10427 in hybrid for branches/releng-9.0/nanobsd/files/usr/local
- Timestamp:
- Apr 10, 2012, 10:23:55 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/releng-9.0/nanobsd/files/usr/local/www/wlweb/index.cgi
r10426 r10427 1 #!/usr/ local/bin/python1 #!/usr/bin/env python 2 2 # 3 # Wireless Leiden webinterface for (embedded) nodes 3 # Wireless Leiden webinterface for (embedded) nodes, printing some basic debug 4 # information, for people who does not like SSH logins 5 # 4 6 # Rick van der Zwet <info@rickvanderzwet.nl> 5 7 # Richard van Mansom (richardvm@wirelessleiden.nl), striped the webserver 6 8 7 9 from subprocess import * 8 import os10 import socket 9 11 10 def tailFile(file): 11 lines=-10 12 return("<em>Tail (%i): %s</em><br /><pre>%s</pre>" % (lines,file,Popen(["tail", str(lines), file], stdout=PIPE).communicate()[0])); 12 def tailFile(file, lines=10): 13 return("<em>Tail (%i): %s</em><br /><pre>%s</pre>" % (lines,file,Popen(["/usr/bin/tail", '-%s' % lines, file], stdout=PIPE, shell=False).communicate()[0])) 13 14 14 15 def catFile(file): 15 return("<em>File: %s</em><br /><pre>%s</pre>" % (file,Popen([" cat", file], stdout=PIPE).communicate()[0]));16 return("<em>File: %s</em><br /><pre>%s</pre>" % (file,Popen(["/bin/cat", file], stdout=PIPE, shell=False).communicate()[0])) 16 17 17 18 def allRoutes(): 18 return("<em>netstat -nr</em><br /><pre>%s</pre>" % Popen([" netstat", "-n", "-r"], stdout=PIPE).communicate()[0]);19 return("<em>netstat -nr</em><br /><pre>%s</pre>" % Popen(["/usr/bin/netstat", "-n", "-r"], stdout=PIPE, shell=False).communicate()[0]) 19 20 20 21 def processList(): 21 return("<em>ps -aux</em><br /><pre>%s</pre>" % Popen(["ps", "-a", "-u", "-x"], stdout=PIPE).communicate()[0]); 22 return("<em>ps -aux</em><br /><pre>%s</pre>" % Popen(["/bin/ps", "-a", "-u", "-x"], stdout=PIPE, shell=False).communicate()[0]) 23 24 def interfaceList(): 25 return("<em>ifconfig -a</em><br /><pre>%s</pre>" % Popen(["/sbin/ifconfig", "-a"], stdout=PIPE, shell=False).communicate()[0]) 26 27 def arpList(): 28 return("<em>arp -n -a</em><br /><pre>%s</pre>" % Popen(["/usr/sbin/arp", "-n", "-a"], stdout=PIPE, shell=False).communicate()[0]) 22 29 23 30 24 def main(): 25 return ( "Content-Type: text/html\n\n" + 26 "<img src='/static/wl-logo.png' />" + 27 "Welcome to <a href='http://www.wirelessleiden.nl'>Stichting Wireless Leiden</a> host/node <em>" + 28 Popen(["hostname"], stdout=PIPE).communicate()[0] + 29 "</em><p />" + tailFile('/var/log/messages') + "<p />" + 30 tailFile('/var/log/debug.log') + "<p />" + 31 catFile('/var/run/dmesg.boot') + "<p />" + 32 allRoutes() + "<p />" + 33 processList() + "<p />" + 34 "<em>$Id$</em>" ) 31 if __name__ == '__main__': 32 print "Content-Type: text/html\n\n" 33 print "<img src='/static/wl-logo.png' />" 34 print "Welcome to <a href='http://www.wirelessleiden.nl'>Stichting Wireless Leiden</a> host/node <em>%s</em>" % socket.gethostname() 35 35 36 print main() 36 items = ['motd', 'messages', 'debug.log', 'dmesg.boot', 'ps', 'ifconfig', 'arp', 'routes'] 37 print "<a name='top'><ul>" 38 for item in items: 39 print "<li><a href='#{0}'>{0}</a></li>".format(item) 40 print '</ul>' 41 42 def item_label(): 43 return "<a href='#top'>Back to Top</a><a name='%s'></a><p />" % items.pop(0) 44 45 print item_label() 46 print catFile('/etc/motd') 47 print item_label() 48 print tailFile('/var/log/messages') 49 print item_label() 50 print tailFile('/var/log/debug.log') 51 print item_label() 52 print catFile('/var/run/dmesg.boot') 53 print item_label() 54 print processList() + "<p />" 55 print item_label() 56 print interfaceList() + "<p />" 57 print item_label() 58 print arpList() + "<p />" 59 print item_label() 60 print allRoutes() + "<p />" 61 print "<em>$Id$</em>"
Note:
See TracChangeset
for help on using the changeset viewer.