Mercurial > ~darius > hgwebdir.cgi > adslstats
diff adslstats.py @ 4:f50214bca1ae
Update for Billion 7700NR2
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Fri, 07 Feb 2014 20:35:59 +1030 |
parents | a795b6cd8b1a |
children | 072489c80c51 |
line wrap: on
line diff
--- a/adslstats.py Mon Mar 18 23:15:00 2013 +1030 +++ b/adslstats.py Fri Feb 07 20:35:59 2014 +1030 @@ -69,19 +69,17 @@ (options, args) = opts.parse_args() -statsurl = "http://%s/adsl.asp" % (options.name) +statsurl = "http://%s/statsadsl.html" % (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)' } - + 3 : 'Status:', + 8 : 'SNR Margin (0.1 dB):', + 9 : 'Attenuation (0.1 dB):', + 14 : 'Rate (Kbps):', +} class ADSLStats(object): def __str__(self): @@ -103,19 +101,22 @@ a = s.findAll('tr') for i in statsdict: - assert a[i].td.contents[0].contents[0] == statsdict[i] + assert a[i].td.contents[0] == statsdict[i] stats = ADSLStats() # Check if the modem is offline - if a[9].td.findNext('td').contents[0].contents[0].find('N/A') != -1: + if a[3].td.contents[0] != 'Up': return None - stats.upstream = cleannum(a[7].td.findNext('td').contents[0].contents[0]) # kbits - stats.downstream = cleannum(a[8].td.findNext('td').contents[0].contents[0]) # kbits - stats.nmup = cleannum(a[9].td.findNext('td').contents[0].contents[0]) # dB - 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 + + # dB + stats.nmdown = float(a[8].td.findNext('td').contents[0]) / 10.0 + stats.nmup = float(a[8].td.findNext('td').findNext('td').contents[0]) / 10.0 + stats.attendown = float(a[9].td.findNext('td').contents[0]) / 10.0 + stats.attenup = float(a[9].td.findNext('td').findNext('td').contents[0]) / 10.0 + # kBit + stats.upstream = float(a[14].td.findNext('td').contents[0]) / 10.0 + stats.downstream = float(a[14].td.findNext('td').findNext('td').contents[0]) / 10.0 return stats