DSL Monitor, Website + PHP-Skript

Horschdie

Neuer User
Mitglied seit
12 Sep 2015
Beiträge
10
Punkte für Reaktionen
0
Punkte
1
Hi zusammen,

aus der Not heraus habe ich mir eine kleine Website gebastelt um den Status meiner DSL-Leitung über einen längeren Zeitraum beobachten
und protokollieren zu können.

Über ein PHP-Skript werden die DSL-Infos der Box ausgelesen und in ein File geschrieben, die Website stellt nur den Inhalt des Files dar.
Man kann den Zeitraum der angezeigten Daten selbst über die Website auswählen und man kann auch in Bereiche reinzoomen.
Das Ganze läuft bei mir auf meinem kleinen Odroid C1 mit Ubuntu mit einem Cronjob der jede Minute das DSL-PHP-Skript ausführt.

Da es für mich sehr hilfreich war zu verstehen welche Probleme ich überhaupt habe und zu welchen Zeiten die Probleme bevorzugt
auftreten etc. habe ich mir mal die Mühe gemacht und das jetzt Online bereitgestellt. Vielleicht kann es ja noch jemand brauchen.
Meine Leitung funktioniert jedenfalls seit ein paar Tagen auf einmal wieder zuverlässig und ich vermute 1&1 hat nach meinen etlichen
Beschwerden irgendwas gemacht...ich hoffe jedenfalls das bleibt so und werde es weiterhin beobachten. ;)

Updates

v2.2, 16.06.2018

  • works with FRITZ!OS: 06.83
  • split data extraction in multiple strings
  • IP + DNS logging is not working currently
  • examples are not up to date...
v2.1, 31.01.2016, Ein paar Monate lief es super, aber nun sind meine Probleme wieder da...

  • fixed start_index if start_date wasn't found
  • added DSLAM info to data log
  • added regex data example
  • updated dsl_mon_example.log

v2.0, 30.01.2016

  • Optimized for short time ranges with big data


screenshot.jpgDez15-Jan16.jpg

Sourcen: https://github.com/DsChAeK/dsl-monitor
 
Zuletzt bearbeitet:
Schönes Projekt, auch wenn die plötzlich konstanten Daten komisch sind.

Es gibt übrigens bessere Datenquellen als das Webinterface mit regulären Ausdrücken: Entweder die UPNP-Schnittstelle oder DOM-Parser fürs Webinterface
 
Zuletzt bearbeitet:
Moins

Funktioniert nicht auf/mit XAMMP (Windows 7).
Trotz Anpassung der Fritz!Box API in: fritzbox_user.conf.php
Wegen Benutzer/Passwort Login.
Es kommen einfach keine Daten an.
dsl_monitor_01.jpg

Wahrscheinlich deswegen?
dsl.php
Code:
[B]Fatal error[/B]:  Call to undefined function curl_init() in [B]C:\xampp\htdocs\dsl-monitor\fritz\fritzbox_api.class.php[/B] on line [B]180[/B]

Deswegen mal flux in die php.ini geschaut, dort war dies nicht aktiv: extension=php_curl.dll

Aber nach Aktivierung bekam ich dies...
Code:
Response of initialization call /login_sid.lua in initSID was not xml-formatted.
[B]Notice[/B]:  Undefined variable: html in [B]C:\xampp\htdocs\dsl-monitor\dsl.php[/B] on line [B]136[/B]

[B]Notice[/B]:  Undefined variable: html in [B]C:\xampp\htdocs\dsl-monitor\dsl.php[/B] on line [B]153[/B]

[B]Notice[/B]:  Undefined variable: html in [B]C:\xampp\htdocs\dsl-monitor\dsl.php[/B] on line [B]174[/B]

[B]Notice[/B]:  Undefined variable: html in [B]C:\xampp\htdocs\dsl-monitor\dsl.php[/B] on line [B]190[/B]

[B]Notice[/B]:  Undefined variable: html in [B]C:\xampp\htdocs\dsl-monitor\dsl.php[/B] on line [B]206[/B]
:noidea:

Hardware: 7360SL (siehe Signatur)
 
Zuletzt bearbeitet:
Danke für den Tip mit den anderen Datenquellen, kenn mich leider nicht so toll aus und bin auch kein Web-Entwickler, sieht man ja auch am Code...Hauptsache tut erstmal. :)
Bei mir wurde die V-Stelle unerwartet geändert, daher der plötzliche Wandel meiner Leitung...

Da kommt eine Exception von dem Fritz API, daher ist die Variable $html nicht bekannt. Vielleicht findest du hier warum es bei dir Fehler gibt.
 
@koy: Was gibt denn fritz.box/login_sid.lua aus?
 
Ein Testaufruf mit einer gültigen SID?

Dann kommt bei mir diese XML zurück...
HTML:
<?xml version="1.0" encoding="utf-8"?>
<SessionInfo>
<SID>7aecb5c36745b333</SID>
<Challenge>866ba98c</Challenge>
<BlockTime>0</BlockTime>
<Rights>
<Name>Dial</Name>
<Access>2</Access>
<Name>HomeAuto</Name>
<Access>2</Access>
<Name>BoxAdmin</Name>
<Access>2</Access>
<Name>Phone</Name>
<Access>2</Access>
<Name>NAS</Name>
<Access>2</Access>
</Rights>
</SessionInfo>
...der Benutzer ist also ein "Boxadmin" mit Konfigurationsrechten.

Ich fürchte, irgendetwas stimmt noch nicht mit der XAMMP/PHP Konfiguration (php.ini).

Denn ein Aufruf, unabhängig von dsl_monitor, der...
"http://localhost/fb_api/fritzbox_get_foncallslist_xml.php"
...bringt so ziemlich den selben Fehler...
Code:
[B]Notice[/B]:  Undefined variable: message in [B]C:\xampp\htdocs\fb_api\fritzbox_get_foncallslist_xml.php[/B] on line [B]59[/B]
Response of initialization call /login_sid.lua in initSID was not xml-formatted.
 
Zuletzt bearbeitet:
In der fritzbox_user.conf.php ist 'root' festgelegt, vielleicht änderst du da mal den Benutzer.

$this->config->setItem('remote_config_user', 'root');
 
Danke.

Die remote_config Geschichte wird doch nur bei Fernzugriff benötigt!?

Lokal sollten doch diese Angaben reichen...
fritzbox_user.conf.php
PHP:
<?php
date_default_timezone_set('Europe/Berlin');
if ( !isset($this->config) )
{
  die(__FILE__ . ' must not be called directly');
}

####################### central API config ########################
# notice: you only have to set values differing from the defaults #
###################################################################

# use the new .lua login method in current (end 2012) labor and newer firmwares (Fritz!OS 5.50 and up)
$this->config->setItem('use_lua_login_method', true);

# set to your Fritz!Box IP address or DNS name (defaults to fritz.box), for remote config mode, use the dyndns-name like example.dyndns.org
$this->config->setItem('fritzbox_ip', 'fritz.box');

# if needed, enable remote config here
#$this->config->setItem('enable_remote_config', true);
#$this->config->setItem('remote_config_user', 'koyaanisqatsi');
#$this->config->setItem('remote_config_password', 'SECRET');

# set to your Fritz!Box username, if login with username is enabled (will be ignored, when remote config is enabled)
$this->config->setItem('username', 'koyaanisqatsi');

# set to your Fritz!Box password (defaults to no password, will be ignored, when remote config is enabled)
$this->config->setItem('password', 'SECRET');

# set the logging mechanism (defaults to console logging)
$this->config->setItem('logging', 'console'); // output to the console
#$this->config->setItem('logging', 'silent');  // do not output anything, be careful with this logging mode
#$this->config->setItem('logging', 'tam.log'); // the path to a writeable logfile

# the newline character for the logfile (does not need to be changed in most cases)
$this->config->setItem('newline', (PHP_OS == 'WINNT') ? "\r\n" : "\n");


############## module specific config ###############

# set the path for the call list for the foncalls module
$this->config->setItem('foncallslist_path', __DIR__ . '/anrufsliste.csv');
?>

Das bestätigt auch die Änderung auf: enable_remote_config, true
...denn dann kommt genau derselbe Fehler.
(Natürlich mit dem echten Passwort)
 
Zuletzt bearbeitet:
Also die einzigste Änderung an die ich mich erinnere war user auf 'root' zu ändern und das Passwort über meine config.php einzuschleusen, dann gings bei mir.
Vielleicht mal das API frisch runterladen und neu anpassen?
 
Yo, mach ich mal.
Komisch nur das die API Version die bei dsl_monitor dabei ist, bei euch anscheinend ohne Probleme läuft.
Deswegen verspreche ich mir nicht viel davon.
Apropos: Die Konfigurationsdatei von dsl_monitor (config.php) hatte ich natürlich vorher angepasst (Passwort/$password).
...mich verwirren die angeblich nicht definierten Variablen.
Code:
[COLOR=#ff0000][B](Vor Aktivierung von curl in der php.ini)
[/B][/COLOR][04-Oct-2015 12:31:50] PHP Notice:  Undefined index: start in C:\xampp\htdocs\dsl-monitor\index.php on line 166

[04-Oct-2015 12:31:51] PHP Notice:  Undefined index: end in C:\xampp\htdocs\dsl-monitor\index.php on line 166

[04-Oct-2015 12:31:51] PHP Warning:  fopen(log/dsl_mon.log) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory in C:\xampp\htdocs\dsl-monitor\index.php on line 67

[04-Oct-2015 12:33:02] PHP Notice:  Undefined index: start in C:\xampp\htdocs\dsl-monitor\index.php on line 166

[04-Oct-2015 12:33:02] PHP Notice:  Undefined index: end in C:\xampp\htdocs\dsl-monitor\index.php on line 166

[04-Oct-2015 12:33:02] PHP Warning:  fopen(./log/dsl_mon.log) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory in C:\xampp\htdocs\dsl-monitor\index.php on line 67

[04-Oct-2015 12:34:02] PHP Notice:  Undefined index: start in C:\xampp\htdocs\dsl-monitor\index.php on line 166

[04-Oct-2015 12:34:02] PHP Notice:  Undefined index: end in C:\xampp\htdocs\dsl-monitor\index.php on line 166

[04-Oct-2015 13:09:13] PHP Fatal error:  Call to undefined function curl_init() in C:\xampp\htdocs\dsl-monitor\fritz\fritzbox_api.class.php on line 180

[04-Oct-2015 13:15:27] PHP Fatal error:  Call to undefined function curl_init() in C:\xampp\htdocs\dsl-monitor\fritz\fritzbox_api.class.php on line 180
[COLOR=#ff0000][B](Nach Aktivierung von curl in der php.ini)[/B][/COLOR]
[04-Oct-2015 13:17:10] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 136

[04-Oct-2015 13:17:10] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 153

[04-Oct-2015 13:17:10] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 174

[04-Oct-2015 13:17:10] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 190

[04-Oct-2015 13:17:10] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 206

[04-Oct-2015 13:17:29] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 136

[04-Oct-2015 13:17:29] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 153

[04-Oct-2015 13:17:29] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 174

[04-Oct-2015 13:17:29] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 190

[04-Oct-2015 13:17:29] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 206

[04-Oct-2015 13:20:15] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 136

[04-Oct-2015 13:20:15] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 153

[04-Oct-2015 13:20:15] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 174

[04-Oct-2015 13:20:15] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 190

[04-Oct-2015 13:20:15] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 206

[04-Oct-2015 13:29:40] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 136

[04-Oct-2015 13:29:40] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 153

[04-Oct-2015 13:29:40] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 174

[04-Oct-2015 13:29:40] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 190

[04-Oct-2015 13:29:41] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 206

[04-Oct-2015 13:30:10] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 136

[04-Oct-2015 13:30:10] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 153

[04-Oct-2015 13:30:10] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 174

[04-Oct-2015 13:30:10] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 190

[04-Oct-2015 13:30:10] PHP Notice:  Undefined variable: html in C:\xampp\htdocs\dsl-monitor\dsl.php on line 206
Das PHP scheint bei mir strikter zu Laufen als bei euch. :gruebel:
 
Zuletzt bearbeitet:
Das vor der curl-Umstellung versteh ich auch nicht, aber das danach schon.
Das liegt daran, dass $html erst am Ende vom try-Block definiert ist und er davor schon wegen der API-Exception in den catch Fall rausspringt.
 
Funktioniert das Script auch unter der neuen 6.50 Firmware?

Habe das mal auf meinen Webserver installiert aber irgendwie funktioniert das bei mir nicht. Habe zu testzwecken mal das Passwort der Weboberfläche der Fritzbox entfernt aber jedesmal sehe ich in den Diagrammen keine Daten.
Beim Versuch die Datei dsl.php aufzurufen, erhalte ich nur eine weiße Seite.
Könnte das Script für meine Fehlerdiagnose nämlich gut gebrauchen. Nutze eine Fritzbox 7490 mit der aktuellen 6.50 Firmware.

Vielen Dank im Voraus

Mit freundlichen Grüßen

Dopamin
 
Vermutlich eher nicht, da ich alles aus dem Seitenquellcode parse was ich brauche.
Beim Aufruf der dsl.php muß danach das Logfile erstellt, bzw. ein neuer Eintrag generiert worden sein. Die weiße Seite ist normal.
Wenn kein Fehler kommt, aber das auch nicht klappt, dann ist es vermutlich ein Rechte-Problem auf den Log-Ordner, oder eben
die Links passen nicht mehr zur Firmware. Den Logordner kannst du über die config.php auch umstellen!

Baue mal in das dsl.php Skript ein var_dump ein und ruf es manuell im Browser auf.

PHP:
...
  catch (Exception $e)
  {
   echo $e->getMessage();
  }

var_dump($html);

  // Logline
  $logline  = '';

...

Wenn da Daten erscheinen, dann Quelltext öffnen und hier posten, dann kann ich den Parser darauf anpassen.
Sollte da schon nix erscheinen könnte es auch am Fritzbox-Login oder fehlerhaften Links liegen.
 

Zurzeit aktive Besucher

Keine Mitglieder online.

Statistik des Forums

Themen
244,868
Beiträge
2,219,770
Mitglieder
371,584
Neuestes Mitglied
porcupine
Holen Sie sich 3CX - völlig kostenlos!
Verbinden Sie Ihr Team und Ihre Kunden Telefonie Livechat Videokonferenzen

Gehostet oder selbst-verwaltet. Für bis zu 10 Nutzer dauerhaft kostenlos. Keine Kreditkartendetails erforderlich. Ohne Risiko testen.

3CX
Für diese E-Mail-Adresse besteht bereits ein 3CX-Konto. Sie werden zum Kundenportal weitergeleitet, wo Sie sich anmelden oder Ihr Passwort zurücksetzen können, falls Sie dieses vergessen haben.