Mercurial > ~darius > hgwebdir.cgi > adslstats
changeset 3:3748cec0e322
merge
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Wed, 20 Nov 2013 23:56:29 +1030 |
parents | b1048f889ef8 (diff) a795b6cd8b1a (current diff) |
children | 98d351a87043 |
files | adslstats.py |
diffstat | 3 files changed, 140 insertions(+), 142 deletions(-) [+] |
line wrap: on
line diff
--- a/adsl.html Mon Mar 18 23:15:00 2013 +1030 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -<html> -<head> -<meta http-equiv="content-type" content="text/html; charset=utf-8"> -<META http-equiv="Pragma" content="no-cache"> -<META http-equiv="Expires" content="-1"> -<link rel="stylesheet" type="text/css" href="default.css"> -<SCRIPT language="javascript"> - function SetChannelOptions(index) { - var form=document.adsl; - var default_annex='A'; - a = new Array(7); - a[0] = new Option("Auto", "0"); - a[1] = new Option("ADSL Multimode", "1"); - a[2] = new Option("ADSL2", "2"); - a[3] = new Option("ADSL2+", "3"); - a[4] = new Option("G.Lite", "4"); - a[5] = new Option("T1.413", "5"); - a[6] = new Option("G.DMT", "6"); - - for(var i = form.ADSLRATE.length - 1; i > 0; i--) { - form.ADSLRATE.options[i] = null; - } - for(var i = form.ADSLMODE.length - 1; i > 0; i--) { - form.ADSLMODE.options[i] = null; - } - if (default_annex == 'A'){ - b = new Array(4); - b[0] = new Option("Open Annex Type and Follow DSLAM's Setting", "0"); - b[1] = new Option("Annex A", "1"); - b[2] = new Option("Annex L", "2"); - b[3] = new Option("Annex M", "3"); - b[4] = new Option("Annex J", "4"); - form.ADSLMODE.options[0] = b[0]; - form.ADSLMODE.options[1] = b[1]; - form.ADSLMODE.options[2] = b[2]; - form.ADSLMODE.options[3] = b[3]; - form.ADSLMODE.options[4] = b[4]; - form.ADSLMODE.selectedIndex = index; - }else{ - b = new Array(1); - b[0] = new Option("Annex B", "1"); - form.ADSLMODE.options[0] = b[0]; - form.ADSLMODE.selectedIndex = index-1; - } - - if (index == 0 || index==1 ){ - form.ADSLRATE.options[0] = a[0]; - form.ADSLRATE.options[1] = a[1]; - form.ADSLRATE.options[2] = a[2]; - form.ADSLRATE.options[3] = a[3]; - form.ADSLRATE.options[4] = a[4]; - form.ADSLRATE.options[5] = a[5]; - form.ADSLRATE.options[6] = a[6]; - }else{ - form.ADSLRATE.options[0] = a[2]; - form.ADSLRATE.options[1] = a[3]; - } -} - - - function load_adsl(){ - var form = document.adsl; - var ADSL_MODE_VALUE= form.ADSL_MODE.value; - SetChannelOptions(form.ADSL_MODE.value); - if (ADSL_MODE_VALUE==0 || ADSL_MODE_VALUE==1) - form.ADSLRATE.selectedIndex = form.ADSL_RATE.value; - else - form.ADSLRATE.selectedIndex = form.ADSL_RATE.value-2; - } - function verifyform() { - var form=document.adsl; - form.apply.disabled=true; - form.reset.disabled=true; - form.submit(); - return true; - } - </SCRIPT> -</head> -<body class="main" link="#3300cc" alink="#ff0000" vlink="#990066" onload="load_adsl();"> -<table border="1" cellpadding="0" cellspacing="0" scrolling="no" style="border-collapse: collapse" bordercolor="#FFFFFF" width="80%"> -<FORM name=adsl method="post" ACTION="/goform/adsl"> -<tr><td class="headline" colspan=2>ADSL</td></tr> -<tr><td colspan="2" class="header"><nobr>Parameters</nobr></td></tr> -<tr><td class="title" width=35%><nobr>ADSL Mode</nobr></td> -<td><nobr> - <INPUT type=hidden name="ADSL_MODE" value="0"> - <SELECT name=ADSLMODE onchange="SetChannelOptions(this.selectedIndex);"> -<tr><td class="title" width=35%><nobr>Modulator</nobr></td> -<td><nobr> - <INPUT type=hidden name="ADSL_RATE" value="0"> - <SELECT name=ADSLRATE> -<tr><td class="title" width=35%><nobr>DSP FirmwareVersion</nobr></td> -<td><nobr>DMT FwVer: 3.7.6.98_A_TC, HwVer:T14F7_1.0 - -<tr><td class="title" width=35%><nobr>DMT Status</nobr></td> -<td><nobr>Up -<tr><td class="title" width=35%><nobr>Operational Mode</nobr></td> -<td><nobr>ADSL2 -<tr><td class="title" width=35%><nobr>Upstream</nobr></td> -<td><nobr>1001 kbps -<tr><td class="title" width=35%><nobr>Downstream</nobr></td> -<td><nobr>6094 kbps -<tr><td class="title" width=35%><nobr>Noise Margin (Upstream)</nobr></td> -<td><nobr>6.3 db -<tr><td class="title" width=35%><nobr>Noise Margin (Downstream)</nobr></td> -<td><nobr>6.2 db -<tr><td class="title" width=35%><nobr>Attenuation (Upstream)</nobr></td> -<td><nobr>35.2 db -<tr><td class="title" width=35%><nobr>Attenuation (Downstream)</nobr></td> -<td><nobr>46.0 db -<tr> -<td class=headline colspan=2> -<br> -<INPUT type="button" name=apply value="Apply" onclick="verifyform();"> -<INPUT type="button" name=reset value="Refresh" onClick="location.reload();"> -</td> -</tr></FORM> -</table> -</body> -</html> -
--- a/adslstats.py Mon Mar 18 23:15:00 2013 +1030 +++ b/adslstats.py Wed Nov 20 23:56:29 2013 +1030 @@ -69,20 +69,10 @@ (options, args) = opts.parse_args() -statsurl = "http://%s/adsl.asp" % (options.name) +statsurl = "http://%s/status/status_deviceinfo.htm" % (options.name) rrdname = "%s.rrd" % (options.base) graphbasename = options.base -matchnum = re.compile('([0-9]+(\.[0-9]+)?)') -statsdict = { - 7 : 'Upstream', - 8 : 'Downstream', - 9 : 'Noise Margin (Upstream)', - 10 : 'Noise Margin (Downstream)', - 11 : 'Attenuation (Upstream)', - 12 : 'Attenuation (Downstream)' } - - class ADSLStats(object): def __str__(self): return """Line Rate - Up: %d kbits, Down %d kbits @@ -91,21 +81,29 @@ self.nmup, self.nmdown, self.attenup, self.attendown) -def cleannum(s): - s1 = matchnum.match(s).groups()[0] - try: - return int(s1) - except ValueError: - return float(s1) - def getstats(f): s = BeautifulSoup(f) - a = s.findAll('tr') + a = s.findAll('td') - for i in statsdict: - assert a[i].td.contents[0].contents[0] == statsdict[i] + # Sanity check in case the firmware changes page layout + assert(a[122]('font')[0].contents[0] == 'SNR Margin') + assert(a[129]('font')[0].contents[0] == 'Line Attenuation') + assert(a[136]('font')[0].contents[0] == 'Data Rate') + + # Check if the modem is offline + if a[124].contents[0].strip() == 'N/A': + return None stats = ADSLStats() + + stats.nmdown = float(a[124].contents[0]) # dB + stats.nmup = float(a[125].contents[0]) # dB + + stats.attendown = float(a[131].contents[0]) # dB + stats.attenup = float(a[132].contents[0]) # dB + + stats.downstream = float(a[138].contents[0]) # kbit/sec + stats.upstream = float(a[139].contents[0]) # kbit/sec # Check if the modem is offline if a[9].td.findNext('td').contents[0].contents[0].find('N/A') != -1: @@ -116,6 +114,7 @@ stats.nmdown = cleannum(a[10].td.findNext('td').contents[0].contents[0]) # dB stats.attenup = cleannum(a[11].td.findNext('td').contents[0].contents[0]) # dB stats.attendown = cleannum(a[12].td.findNext('td').contents[0].contents[0]) # dB +>>>>>>> other return stats
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/status_deviceinfo.htm Wed Nov 20 23:56:29 2013 +1030 @@ -0,0 +1,120 @@ +<html><head> +<meta http-equiv=Content-Script-Type content=text/javascript> +<meta http-equiv=Content-Style-Type content=text/css> +<meta http-equiv=Content-Type content="text/html; charset= +iso-8859-1"> +<link rel="stylesheet" href="../css/style.css" type="text/css"> +<script language="JavaScript"> +function doSave() +{ +document.DvInfo_Form.PVC_or_Renew_or_Release.value = 0; +document.DvInfo_Form.submit(); +} +function PPPoEConnect(num) +{ +document.DvInfo_Form.ManualConnectFlag.value = num; +document.DvInfo_Form.submit(); +} +function doLoad(){ +} +</script> +</head><body onLoad="doLoad()"> +<FORM METHOD="POST" ACTION="/Forms/status_deviceinfo_1" name="DvInfo_Form"><table width="760" border="0" align=center cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> +<tr> +<td height="5" class="light-orange" colspan="5"> </td></tr><tr> +<td width="150" height="30" class="title-main"> +<font color="#FFFFFF">Device Information</font></td><td width="10" class="black"> </td><td width="170"> </td><td width="10" > </td><td width="420" align=right class="tabdata"> +</td></tr><tr> +<td class="light-orange"> </td><td class="light-orange"> </td><td class="tabdata"> <div align=right> +<font color="#000000">Firmware Version</font></div></td><td class="tabdata"><div align=center>:</div></td><td class="tabdata"> +2.11.91.0(UE2.C2)3.11.11.52 </td></tr><tr> +<td class="light-orange"> </td><td class="light-orange"> </td><td class="tabdata"><div align=right> +<font color="#000000">MAC Address</font></div></td><td class="tabdata"><div align=center>:</div></td><td class="tabdata"> +00:04:ed:bb:a9:66</td></tr><tr> +<td class="title-main"> +<font color="#FFFFFF">LAN</font></td><td class="black"> </td><td><hr noshade></td><td><hr noshade></td><td><hr noshade></td></tr><tr> +<td class="light-orange"> </td><td class="light-orange"> </td><td class="tabdata"><div align=right> +<font color="#000000">IP Address</font></div></td><td class="tabdata"><div align=center>:</div></td><td class="tabdata"> +10.0.2.9</td></tr><tr> +<td class="light-orange"> </td><td class="light-orange"> </td><td class="tabdata"><div align=right> +<font color="#000000">Subnet Mask</font></div></td><td class="tabdata"><div align=center>:</div></td><td class="tabdata"> +255.255.255.0</td></tr><tr> +<td class="light-orange"> </td><td class="light-orange"> </td><td class="tabdata"><div align=right> +<font color="#000000">DHCP Server</font></div></td><td class="tabdata"><div align=center>:</div></td><td class="tabdata"> +Disabled</td></tr></table><table width="760" border="0" align=center cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> +<tr> +<td width="150" height="30" class="title-main"> +<font color="#FFFFFF">WAN</font></td><td width="10" class="black"> </td><td width="170"><hr noshade></td><td width="10" ><hr noshade></td><td width="420" colspan="2"><hr noshade> +</td></tr><tr> +<td class="light-orange"> </td><td class="light-orange"> </td><td class="tabdata"><div align=right> +<font color="#000000">Virtual Circuit</font></div></td><td class="tabdata"><div align=center>:</div></td><td class="tabdata" colspan="2"> +<SELECT NAME="DvInfo_PVC" SIZE="1" onchange="doSave()"><OPTION SELECTED>PVC0 +<OPTION>PVC1 +<OPTION>PVC2 +<OPTION>PVC3 +<OPTION>PVC4 +<OPTION>PVC5 +<OPTION>PVC6 +<OPTION>PVC7 +</SELECT></td></tr><tr> +<td class="light-orange"> </td><td class="light-orange"></td><td class="tabdata"><div align=right> +<font color="#000000">Status</font></div></td><td class="tabdata" ><div align=center>:</div></td><td class="tabdata" colspan="2"> +Connected</td></tr><tr> +<td class="light-orange"> </td><td class="light-orange"></td><td class="tabdata"><div align=right> +<font color="#000000">Connection Type</font></div></td><td class="tabdata"><div align=center>:</div></td><td class="tabdata" width="140"> +Bridge</td><td class="tabdata" width="280"> +</td></tr><tr> +<td class="light-orange"> </td><td class="light-orange"></td><td class="tabdata"><div align=right> +<font color="#000000">IP Address</font></div></td><td class="tabdata"><div align=center>:</div></td><td class="tabdata" width="140"> +N/A</td><td class="tabdata" width="280"> +</td></tr><tr> +<td class="light-orange"> </td><td class="light-orange"></td><td class="tabdata"><div align=right> +<font color="#000000">Subnet Mask</font></div></td><td class="tabdata"><div align=center>:</div></td><td class="tabdata" colspan="2"> +N/A</td></tr><tr> +<td class="light-orange"> </td><td class="light-orange"></td><td class="tabdata"><div align=right> +<font color="#000000">Default Gateway</font></div></td><td class="tabdata"><div align=center>:</div></td><td class="tabdata" colspan="2"> +N/A</td></tr><tr> +<td class="light-orange"> </td><td class="light-orange"></td><td class="tabdata"><div align=right> +<font color="#000000">Primary DNS</font></div></td><td class="tabdata"><div align=center>:</div></td><td class="tabdata" colspan="2"> +N/A</td></tr><tr> +<td class="light-orange"> </td><td class="light-orange"></td><td class="tabdata"><div align=right> +<font color="#000000">Secondary DNS</font></div></td><td class="tabdata"><div align=center>:</div></td><td class="tabdata" colspan="2"> +N/A</td></tr><!-- add for PPPOE/PPPOA username --> +<!-- add for firewall status --> +</table><table width="760" border="0" align=center cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="tabdata"> +<tr> +<td width="150" height="30" class="title-main"> +<font color="#FFFFFF">ADSL</font></td><td width="10" class="black"> </td><td width="170"><hr noshade></td><td width="10" ><hr noshade></td><td colspan="3"><hr noshade></td></tr><tr> +<td class="light-orange"> </td><td class="light-orange"></td><td class="tabdata"><div align=right> +<font color="#000000">ADSL Firmware Version</font></div></td><td class="tabdata"><div align=center>:</div></td><td class="tabdata" colspan="3"> + FwVer:3.11.11.52_TC3085 HwVer:T14.F7_3.0</td></tr><tr> +<td class="light-orange"> </td><td class="light-orange"></td><td class="tabdata"><div align=right> +<font color="#000000">Line State</font></div></td><td class="tabdata"><div align=center>:</div></td><td class="tabdata" colspan="3"> +Showtime </td></tr><tr> +<td class="light-orange"> </td><td class="light-orange"></td><td class="tabdata"><div align=right> +<font color="#000000">Modulation</font></div></td><td class="tabdata"><div align=center>:</div></td><td class="tabdata" colspan="3"> +ADSL2 PLUS</td></tr><tr> +<td class="light-orange"> </td><td class="light-orange"></td><td class="tabdata"><div align=right> +<font color="#000000">Annex Mode</font></div></td><td class="tabdata"><div align=center>:</div></td><td class="tabdata" colspan="3"> +ANNEX_A</td></tr><tr> +<td class="light-orange"> </td><td class="light-orange"></td><td class="tabdata"><hr noshade class="light-orange-line"></td><td class="tabdata"><hr noshade class="light-orange-line"></td><td class="tabdata" colspan="3"><hr noshade class="light-orange-line"></td></tr><tr> +<td class="light-orange"></td><td class="light-orange"></td><td class="tabdata"><div align=right></div></td><td class="tabdata"></td><td width="70" align=center class="tabdata"> +<font color="#000000">Downstream</font></td><td width="70" align=center class="tabdata"> +<font color="#000000">Upstream</font></td><td width="280"> </td></tr><tr> +<td class="light-orange"></td><td class="light-orange"></td><td class="tabdata"><div align=right> +<font color="#000000">SNR Margin</font></div></td><td class="tabdata"><div align=center>:</div></td><td width="70" align=center class="tabdata"> +6.5 </td><td width="70" align=center class="tabdata"> +5.9</td><td class="tabdata">db</td></tr><tr> +<td class="light-orange"></td><td class="light-orange"></td><td class="tabdata"><div align=right> +<font color="#000000">Line Attenuation</font></div></td><td class="tabdata"><div align=center>:</div></td><td width="70" align=center class="tabdata"> +47.9 </td><td width="70" align=center class="tabdata"> + 33.5 </td><td width="280" class="tabdata">db</td></tr><tr> +<td class="light-orange"></td><td class="light-orange"></td><td class="tabdata"><div align=right> +<font color="#000000">Data Rate</font></div></td><td class="tabdata"><div align=center>:</div></td><td width="70" align=center class="tabdata"> + 5626 </td><td width="70" align=center class="tabdata"> + 990 </td><td width="280" class="tabdata">kbps</td></tr><!-- add for outpower by jqzhou_20090218 --> +<tr> +<td class="light-orange"></td><td class="light-orange"></td><td width="170"> </td><td width="10"> </td><td colspan="3" class="tabdata"> </td></tr></table><table width="760" border="0" align=center cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> +<tr> +<td width="160" class="black" height="42" > </td><td width="160" class="orange"> </td><td width="440" class="orange"> </td></tr></table><INPUT TYPE="HIDDEN" NAME="PVC_or_Renew_or_Release" VALUE="0"><INPUT TYPE="HIDDEN" NAME="ManualConnectFlag" VALUE="0"></form> +</body></html> \ No newline at end of file