Skip to content

Commit

Permalink
Update login for Fritz!OS 7.25 compatibility (#52)
Browse files Browse the repository at this point in the history
* use username and password
* default to python3
  • Loading branch information
Tafkas authored Mar 26, 2021
1 parent eee98fe commit 1e3e718
Show file tree
Hide file tree
Showing 12 changed files with 274 additions and 203 deletions.
10 changes: 10 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 7.25.0
*2021-03-26*

- Support for FritzOS!7.25 including log in via username password

## 7.0.0
*2018-09-11*

- Support for FritzOS!7.00

## 6.83.2
*2017-09-05*

Expand Down
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# fritzbox-munin

A collection of munin plugins to monitor your AVM FRITZ!Box router. The scripts have been developed using a [FRITZ!Box 7590](http://geni.us/OO2c7S)(Amazon link) running FRITZ!OS 7.00.
A collection of munin plugins to monitor your AVM FRITZ!Box router. The scripts have been developed using a [FRITZ!Box 7590](http://geni.us/OO2c7S)(Amazon link) running FRITZ!OS 7.25.

If you are using the scripts on a different Fritz!Box model please let me know by

Expand All @@ -15,11 +15,13 @@ If you are using the scripts on a different Fritz!Box model please let me know b
- [FRITZ!Box 7390](http://geni.us/BlAP)
- [FRITZ!Box 7430](http://geni.us/BlAP)
- [FRITZ!Box 7490](http://geni.us/fTyoY)
- [FRITZ!Box 7530](https://geni.us/h8oqYd)
- [FRITZ!Box 7530 AX](https://geni.us/a4dS5)
- [FRITZ!Box 7560](http://geni.us/6gPZNI)
- [FRITZ!Box 7580](http://geni.us/yUYyQTE)
- [FRITZ!Box 7590](http://geni.us/OO2c7S)

If you are still running Fritz!OS 6.30 check out the [releases section](https://github.com/Tafkas/fritzbox-munin/releases/tag/6.30.1).
If you are still running an older Fritz!OS version check out the [releases section](https://github.com/Tafkas/fritzbox-munin/releases/).

## Introduction

Expand All @@ -41,32 +43,32 @@ If you are using the scripts on a different Fritz!Box model please let me know b

## fritzbox\_cpu\_usage

fritzbox\_cpu\_usage shows you the cpu usage (requires password)
fritzbox\_cpu\_usage shows you the cpu usage (requires username & password)
![http://i.imgur.com/A9uGvWP.png](http://i.imgur.com/A9uGvWP.png)

## fritzbox\_cpu\_temperature

fritzbox\_cpu\_temperature shows you the cpu temperature (requires password)
fritzbox\_cpu\_temperature shows you the cpu temperature (requires username & password)
![http://i.imgur.com/duHYhw6.png](http://i.imgur.com/duHYhw6.png)

## fritzbox\_memory\_usage

fritzbox\_memory\_usage shows you the memory usage (requires password)
fritzbox\_memory\_usage shows you the memory usage (requires username & password)
![http://i.imgur.com/WhxrINK.png](http://i.imgur.com/WhxrINK.png)

## fritzbox\_power\_consumption

fritzbox\_power\_consumption shows you the power consumption (requires password)
fritzbox\_power\_consumption shows you the power consumption (requires username & password)
![http://i.imgur.com/a7uQzn6.png](http://i.imgur.com/a7uQzn6.png)

## fritzbox\_uptime

fritzbox\_uptime shows you the uptime in days (requires password) (language dependant, see below).
fritzbox\_uptime shows you the uptime in days (requires username & password) (language dependant, see below).
![http://i.imgur.com/Jr8OibH.png](http://i.imgur.com/Jr8OibH.png)

## fritzbox\_wifi\_devices

fritzbox\_wifi\_devices shows you the number of connected wifi clients (requires password) (language dependant, see below).
fritzbox\_wifi\_devices shows you the number of connected wifi clients (requires username & password) (language dependant, see below).
![http://i.imgur.com/lqvK1b2.png](http://i.imgur.com/lqvK1b2.png)

## Installation & Configuration
Expand All @@ -85,6 +87,7 @@ If you are using the scripts on a different Fritz!Box model please let me know b

[fritzbox_*]
env.fritzbox_ip <ip_address_to_your_fritzbox>
env.fritzbox_username <fritzbox_username>
env.fritzbox_password <fritzbox_password>
env.traffic_remove_max true # if you do not want the possible max values
host_name fritzbox
Expand Down
32 changes: 21 additions & 11 deletions fritzbox_connection_uptime.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""
fritzbox_connection_uptime - A munin plugin for Linux to monitor AVM Fritzbox connection uptime
Copyright (C) 2015 Christian Stade-Schuldt
Expand All @@ -10,44 +10,54 @@
This plugin requires the fritzconnection plugin. To install it using pip:
pip install fritzconnection
This plugin supports the following munin configuration parameters:
[fritzbox_*]
env.fritzbox_ip [ip address of the fritzbox]
env.fritzbox_username [fritzbox username]
env.fritzbox_password [fritzbox password]
#%# family=auto contrib
#%# capabilities=autoconf
"""

import os
import sys

from fritzconnection import FritzConnection
from fritzconnection.lib.fritzstatus import FritzStatus

server = os.environ["fritzbox_ip"]
username = os.environ["fritzbox_username"]
password = os.environ["fritzbox_password"]


def print_values():
try:
conn = FritzConnection(address=os.environ['fritzbox_ip'])
fs = FritzStatus(address=server, user=username, password=password)
except Exception as e:
sys.exit("Couldn't get connection uptime")

uptime = conn.call_action('WANIPConnection', 'GetStatusInfo')['NewUptime']
print('uptime.value %.2f' % (int(uptime) / 86400.0))
uptime = fs.uptime
print("uptime.value %.2f" % (int(uptime) / 86400.0))


def print_config():
print("graph_title AVM Fritz!Box Connection Uptime")
print("graph_args --base 1000 -l 0")
print('graph_vlabel uptime in days')
print("graph_vlabel uptime in days")
print("graph_scale no'")
print("graph_category network")
print("uptime.label uptime")
print("uptime.draw AREA")
if os.environ.get('host_name'):
print("host_name " + os.environ['host_name'])
if os.environ.get("host_name"):
print("host_name " + os.environ["host_name"])


if __name__ == "__main__":
if len(sys.argv) == 2 and sys.argv[1] == 'config':
if len(sys.argv) == 2 and sys.argv[1] == "config":
print_config()
elif len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
elif len(sys.argv) == 2 and sys.argv[1] == "autoconf":
print("yes") # Some docs say it'll be called with fetch, some say no arg at all
elif len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] == 'fetch'):
elif len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] == "fetch"):
try:
print_values()
except:
Expand Down
28 changes: 15 additions & 13 deletions fritzbox_cpu_temperature.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""
fritzbox_cpu_temperature - A munin plugin for Linux to monitor AVM Fritzbox
Copyright (C) 2015 Christian Stade-Schuldt
Expand All @@ -9,6 +9,7 @@
[fritzbox_*]
env.fritzbox_ip [ip address of the fritzbox]
env.fritzbox_username [fritzbox username]
env.fritzbox_password [fritzbox password]
This plugin supports the following munin configuration parameters:
Expand All @@ -20,19 +21,20 @@
import sys
import fritzbox_helper as fh

PAGE = 'ecoStat'
PAGE = "ecoStat"


def get_cpu_temperature():
"""get the current cpu temperature"""

server = os.environ['fritzbox_ip']
password = os.environ['fritzbox_password']
server = os.environ["fritzbox_ip"]
username = os.environ["fritzbox_username"]
password = os.environ["fritzbox_password"]

session_id = fh.get_session_id(server, password)
session_id = fh.get_session_id(server, username, password)
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
data = json.loads(xhr_data)
print('temp.value %d' % (int(data['data']['cputemp']['series'][0][-1])))
print("temp.value %d" % (int(data["data"]["cputemp"]["series"][0][-1])))


def print_config():
Expand All @@ -46,15 +48,15 @@ def print_config():
print("temp.graph LINE1")
print("temp.min 0")
print("temp.info Fritzbox CPU temperature")
if os.environ.get('host_name'):
print("host_name " + os.environ['host_name'])
if os.environ.get("host_name"):
print("host_name " + os.environ["host_name"])


if __name__ == '__main__':
if len(sys.argv) == 2 and sys.argv[1] == 'config':
if __name__ == "__main__":
if len(sys.argv) == 2 and sys.argv[1] == "config":
print_config()
elif len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
print('yes')
elif len(sys.argv) == 1 or len(sys.argv) == 2 and sys.argv[1] == 'fetch':
elif len(sys.argv) == 2 and sys.argv[1] == "autoconf":
print("yes")
elif len(sys.argv) == 1 or len(sys.argv) == 2 and sys.argv[1] == "fetch":
# Some docs say it'll be called with fetch, some say no arg at all
get_cpu_temperature()
28 changes: 15 additions & 13 deletions fritzbox_cpu_usage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""
fritzbox_cpu_usage - A munin plugin for Linux to monitor AVM Fritzbox
Copyright (C) 2015 Christian Stade-Schuldt
Expand All @@ -9,6 +9,7 @@
[fritzbox_*]
env.fritzbox_ip [ip address of the fritzbox]
env.fritzbox_username [fritzbox username]
env.fritzbox_password [fritzbox password]
This plugin supports the following munin configuration parameters:
Expand All @@ -20,19 +21,20 @@
import sys
import fritzbox_helper as fh

PAGE = 'ecoStat'
PAGE = "ecoStat"


def get_cpu_usage():
"""get the current cpu usage"""

server = os.environ['fritzbox_ip']
password = os.environ['fritzbox_password']
server = os.environ["fritzbox_ip"]
username = os.environ["fritzbox_username"]
password = os.environ["fritzbox_password"]

session_id = fh.get_session_id(server, password)
session_id = fh.get_session_id(server, username, password)
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
data = json.loads(xhr_data)
print('cpu.value %d' % (int(data['data']['cpuutil']['series'][0][-1])))
print("cpu.value %d" % (int(data["data"]["cpuutil"]["series"][0][-1])))


def print_config():
Expand All @@ -46,16 +48,16 @@ def print_config():
print("cpu.graph AREA")
print("cpu.min 0")
print("cpu.info Fritzbox CPU usage")
if os.environ.get('host_name'):
print("host_name " + os.environ['host_name'])
if os.environ.get("host_name"):
print("host_name " + os.environ["host_name"])


if __name__ == '__main__':
if len(sys.argv) == 2 and sys.argv[1] == 'config':
if __name__ == "__main__":
if len(sys.argv) == 2 and sys.argv[1] == "config":
print_config()
elif len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
print('yes')
elif len(sys.argv) == 1 or len(sys.argv) == 2 and sys.argv[1] == 'fetch':
elif len(sys.argv) == 2 and sys.argv[1] == "autoconf":
print("yes")
elif len(sys.argv) == 1 or len(sys.argv) == 2 and sys.argv[1] == "fetch":
# Some docs say it'll be called with fetch, some say no arg at all
try:
get_cpu_usage()
Expand Down
Loading

0 comments on commit 1e3e718

Please sign in to comment.