update scripts for FRITZ!OS:131.06.36-32026 BETA

This commit is contained in:
Christian Stade-Schuldt 2015-12-19 11:34:21 +01:00
parent 9e6446a08c
commit c776ef25a9
7 changed files with 88 additions and 19 deletions

61
.gitignore vendored Normal file
View File

@ -0,0 +1,61 @@
# Created by .ignore support plugin (hsz.mobi)
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/

View File

@ -1,5 +1,10 @@
# fritzbox-munin
A collection of munin plugins to monitor your AVM FRITZ!Box router. The scripts have been developed using a FRITZ!Box 7362 SL running FRITZ!OS 06.30.
A collection of munin plugins to monitor your AVM FRITZ!Box router. The scripts have been developed using a
FRITZ!Box 7362 SL running FRITZ!OS:131.06.36-32026 BETA. AVM has modified the web interface if the Fritz!Box
in the current version that the old scripts do not work anymore. This branch also only works if the language
of the Fritz!Box is set to German.
If you are using FRITZ!OS 6.30 use the master branch.
## Introduction

View File

@ -22,7 +22,7 @@ import sys
import fritzbox_helper as fh
PAGE = '/system/ecostat.lua'
pattern = re.compile(".*/(StatTemperature)\".*=.*\"(.*?)\"")
pattern = re.compile('Query\s=\s"(\d{1,3})')
def get_cpu_temperature():
@ -36,7 +36,7 @@ def get_cpu_temperature():
m = re.search(pattern, data)
if m:
print 'temp.value %d' % (int(m.group(2).split(',')[0]))
print 'temp.value %d' % (int(m.group(1)))
def print_config():

View File

@ -22,7 +22,7 @@ import sys
import fritzbox_helper as fh
PAGE = '/system/ecostat.lua'
pattern = re.compile(".*/(StatCPU)\".*=.*\"(.*?)\"")
pattern = re.compile('Query1\s=\s"(\d{1,3})')
def get_cpu_usage():
@ -36,7 +36,7 @@ def get_cpu_usage():
m = re.search(pattern, data)
if m:
print 'cpu.value %d' % (int(m.group(2).split(',')[0]))
print 'cpu.value %d' % (int(m.group(1)))
def print_config():

View File

@ -22,8 +22,8 @@ import sys
import fritzbox_helper as fh
PAGE = '/system/ecostat.lua'
pattern = re.compile(".*/(StatRAM.*?)\".*=.*\"(.*?)\"")
USAGE_MAPPING = {'StatRAMCacheUsed': 'cache', 'StatRAMPhysFree': 'free', 'StatRAMStrictlyUsed': 'strict'}
pattern = re.compile('Query[1-3]\s="(\d{1,3})')
USAGE = ['free', 'cache', 'strict']
def get_memory_usage():
@ -36,8 +36,9 @@ def get_memory_usage():
data = fh.get_page(server, sid, PAGE)
matches = re.finditer(pattern, data)
if matches:
for m in matches:
print'%s.value %d' % (USAGE_MAPPING[m.group(1)], int(m.group(2).split(',')[0]))
data = zip(USAGE, [m.group(1) for m in matches])
for d in data:
print'%s.value %s' % (d[0], d[1])
def print_config():

View File

@ -22,9 +22,8 @@ import sys
import fritzbox_helper as fh
PAGE = '/system/energy.lua'
pattern = re.compile(".*/(.*act?)\".*=.*\"(.*?)\"")
DEVICE_MAPPING = {'rate_abact': 'ab', 'rate_dspact': 'dsl', 'rate_sumact': 'system',
'rate_systemact': 'cpu', 'rate_usbhostact': 'usb', 'rate_wlanact': 'wifi'}
pattern = re.compile('<td>(.+?)"bar\s(act|fillonly)"(.+?)\s(\d{1,3})\s%')
DEVICES = ['system', 'cpu', 'wifi', 'dsl', 'ab', 'usb']
def get_power_consumption():
@ -37,8 +36,9 @@ def get_power_consumption():
data = fh.get_page(server, sid, PAGE)
matches = re.finditer(pattern, data)
if matches:
for m in matches:
print'%s.value %d' % (DEVICE_MAPPING[m.group(1)], int(m.group(2)))
data = zip(DEVICES, [m.group(4) for m in matches])
for d in data:
print'%s.value %s' % (d[0], d[1])
def print_config():

View File

@ -22,7 +22,7 @@ import sys
import fritzbox_helper as fh
PAGE = '/system/energy.lua'
pattern = re.compile(".*/(.*uptime_\w+?)\".*=.*\"(.*?)\"")
pattern = re.compile("(\d+)\s(Tagen|Stunden|Minuten)")
def get_uptime():
@ -37,10 +37,12 @@ def get_uptime():
if matches:
hours = 0.0
for m in matches:
if m.group(1) == "uptime_hours":
hours += int(m.group(2))
if m.group(1) == "uptime_minutes":
hours += int(m.group(2)) / 60.0
if m.group(2) == 'Tagen':
hours += 24 * int(m.group(1))
if m.group(2) == "Stunden":
hours += int(m.group(1))
if m.group(2) == "Minuten":
hours += int(m.group(1)) / 60.0
uptime = hours / 24
print "uptime.value %.2f" % uptime