Hi Leute,
ich hab heut mal ein wenig gebastelt und die Infos meines DSL-Modems in FHEM integriert:
(http://imagizer.imageshack.us/v2/xq90/538/dxzOGb.png) (https://imageshack.com/i/eydxzOGbp)
Wenn man mal - nach langer Suche, weils so gut wie keine Informationen gibt - das definitive Root-Passwort für's Modem hat, kann man die Daten wunderschön per Telnet auslesen.
(Ich bin mir nicht sicher, ob ich das Root-PW hier schreiben dürfte, daher hab ichs hier rausgelöscht)
Das ganze hab ich in eine Sub gesteckt und schreibe die Infos alle 10 Minuten per at in einen Dummy:
define DSLModem dummy
define at_DSLInfo at +*00:10:00 {getModemData("DSLModem")}
Dann noch die Routine in der 99_myUtils:
(hier bitte den Text "CP1335VACET" durch die Bezeichnung eures Modems ersetzen)
sub getModemData($)
{
my $dev=shift;
my $hash=$defs{$dev};
my $name = "getModemData";
my $Port = "192.168.1.254";
my $User = "kVtGAbNmsvOqWNOrTjI";
my $Password = "xxxxxxxxxxxxx";
my $telnet = new Net::Telnet ( Timeout=>10, Errmode=>'die');
Log GetLogLevel($name,4), "$name: Connecting to TG788:$Port";
$telnet->open($Port);
$telnet->waitfor('/Username : $/i');
$telnet->print($User);
$telnet->waitfor('/Password : $/i');
$telnet->print($Password);
$telnet->waitfor('/CP1335VACET=>$/i');
$telnet->prompt('/CP1335VACET=>$/');
my @output = $telnet->cmd("xdsl info expand=enabled");
my $str=join('',@output);
@output = $telnet->cmd("system debug cpu");
my $cpu=join('',@output);
@output = $telnet->cmd("system debug mem");
my $mem=join('',@output);
@output = $telnet->cmd("ip iflist");
my $if=join('',@output);
# print @output;
Log GetLogLevel($name,4), "$name: Disconnecting...";
$telnet->print('exit');
readingsBeginUpdate($hash);
if ($str=~/Up time.*?\):[\s]+(.*)/g) {readingsBulkUpdate($hash,"upTime",$1)}
if ($str=~/Payload.*?:[\s]+(.*?)[\s]+(.*)/g) {
readingsBulkUpdate($hash,"dslDown",$1);
readingsBulkUpdate($hash,"dslUp",$2);
readingsBulkUpdate($hash,"DSLSpeed","$1 / $2")
}
if ($str=~/Attenuation.*?:[\s]+(.*?)[\s]+(.*)/g) {
readingsBulkUpdate($hash,"attDown",$1);
readingsBulkUpdate($hash,"attUp",$2);
readingsBulkUpdate($hash,"Dämpfung","$1 / $2")
}
if ($str=~/Margins.*?:[\s]+(.*?)[\s]+(.*)/g) {
readingsBulkUpdate($hash,"marginDown",$1);
readingsBulkUpdate($hash,"marginUp",$2);
readingsBulkUpdate($hash,"Störabstand","$1 / $2")
}
if ($str=~/Output power.*?:[\s]+(.*?)[\s]+(.*)/g) {
readingsBulkUpdate($hash,"outputPwrDown",$1);
readingsBulkUpdate($hash,"outputPwrUp",$2);
readingsBulkUpdate($hash,"Sendeleistung","$1 / $2")
}
if ($str=~/LOS.*?[\s]+(\d+)/g) { readingsBulkUpdate($hash,"LOS",$1); }
if ($str=~/LOF.*?[\s]+(\d+)/g) { readingsBulkUpdate($hash,"LOF",$1); }
if ($str=~/LPR.*?[\s]+(\d+)/g) { readingsBulkUpdate($hash,"LPW",$1);}
if ($str=~/ES.*?[\s]+(\d+)/g) { readingsBulkUpdate($hash,"ErrSec",$1);}
if ($str=~/CV.*?[\s]+(\d+)[\s]+(\d+)/g) {
readingsBulkUpdate($hash,"crcDown",$1);
readingsBulkUpdate($hash,"crcUp",$2);
readingsBulkUpdate($hash,"CRC-Fehler","$1 / $2")
}
if ($str=~/FEC.*?[\s]+([\d|N\/A]+)[\s]+([\d|N\/A]+)/g) {
readingsBulkUpdate($hash,"fecDown",$1);
readingsBulkUpdate($hash,"fecUp",$2);
readingsBulkUpdate($hash,"FEC-Fehler","$1 / $2")
}
if ($str=~/HEC.*?[\s]+([\d|N\/A]+)[\s]+([\d|N\/A]+)/g) {
readingsBulkUpdate($hash,"hecDown",$1);
readingsBulkUpdate($hash,"hecUp",$2);
readingsBulkUpdate($hash,"HEC-Fehler","$1 / $2")
}
if ($cpu=~/CPU-0.*?\n\s+([\d\.]+)\s+([\d\.]+)\s+([\d\.]+)/g) {
readingsBulkUpdate($hash,"cpu0_idle",$1);
readingsBulkUpdate($hash,"cpu0_user",$2);
readingsBulkUpdate($hash,"cpu0_kernel",$3);
readingsBulkUpdate($hash,"CPU0","$1 - $2 - $3");
}
if ($cpu=~/CPU-1.*?\n\s+([\d\.]+)\s+([\d\.]+)\s+([\d\.]+)/g) {
readingsBulkUpdate($hash,"cpu1_idle",$1);
readingsBulkUpdate($hash,"cpu1_user",$2);
readingsBulkUpdate($hash,"cpu1_kernel",$3);
readingsBulkUpdate($hash,"CPU1","$1 - $2 - $3");
}
if ($mem=~/Total.*?([\d]+).*?\nUsed.*?([\d]+).*?\n.*?kernel.*?([\d]+).*?\n.*?appl.*?([\d]+)/g) {
readingsBulkUpdate($hash,"mem_total",$1);
readingsBulkUpdate($hash,"mem_used",$2);
readingsBulkUpdate($hash,"mem_kernel",$3);
readingsBulkUpdate($hash,"mem_app",$4);
readingsBulkUpdate($hash,"MEM","$2 / $1")
}
if ($if=~/aINTERNET.*?[\s]+(\d+)[\s]+(\d+)[\s](GB|MB)[\s]+(\d+)[\s](GB|MB)/g) {
if($3 eq "GB") {readingsBulkUpdate($hash,"aINTERNET_down",$2*1024)} else {readingsBulkUpdate($hash,"aINTERNET_down",$2)};
readingsBulkUpdate($hash,"aINTERNET_downtxt","$2 $3");
if($5 eq "GB") {readingsBulkUpdate($hash,"aINTERNET_up",$4*1024)} else {readingsBulkUpdate($hash,"aINTERNET_up",$4)};
readingsBulkUpdate($hash,"aINTERNET_uptxt","$4 $5");
}
if ($if=~/LocalNetwork.*?[\s]+(\d+)[\s]+(\d+)[\s](GB|MB)[\s]+(\d+)[\s](GB|MB)/g) {
if($3 eq "GB") {readingsBulkUpdate($hash,"localNetwork_down",$2*1024)} else {readingsBulkUpdate($hash,"localNetwork_down",$2)};
readingsBulkUpdate($hash,"localNetwork_downtxt","$2 $3");
if($5 eq "GB") {readingsBulkUpdate($hash,"localNetwork_up",$4*1024)} else {readingsBulkUpdate($hash,"localNetwork_up",$4)};
readingsBulkUpdate($hash,"localNetwork_uptxt","$4 $5");
}
readingsEndUpdate($hash,1);
}
Und das ganze dann noch in eine ReadingsGroup verpackt:
define DSLInfo readingsGroup DSLModem:,!title
DSLModem:,<Running since>,upTime,<br>,< >
DSLModem:,<DSL>,<Down>,<Up>,<>
DSLModem:,<Speed>,dslDown,dslUp,< >
DSLModem:,<Data>,aINTERNET_downtxt,aINTERNET_uptxt,< >
DSLModem:,<Sendeleistung>,outputPwrDown,outputPwrUp,< >
DSLModem:,<Dämpfung>,attDown,attUp,< >
DSLModem:,<Störabstand>,marginDown,marginUp,< >
DSLModem:,<FEC>,fecDown,fecUp,< >
DSLModem:,<HEC>,hecDown,hecUp,< >
DSLModem:,<CRC>,crcDown,crcUp,< >
DSLModem:,< >,< >,< >,< >
DSLModem:,<CPU>,<User>,<Kernel>,<Idle>
DSLModem:,<CPU 0>,cpu0_user,cpu0_kernel,cpu0_idle
DSLModem:,<CPU 1>,cpu1_user,cpu1_kernel,cpu1_idle
DSLModem:,< >,< >,< >,< >
DSLModem:,<Mem>,<Apps>,<System>,<Used>
DSLModem:,mem_total,mem_app,mem_kernel,mem_used
attr DSLInfo DbLogExclude .*
attr DSLInfo cellStyle {"r:18,c:1" => 'style="font-weight:bold;;color:dodgerblue"',"r:14,c:1" => 'style="font-weight:bold;;color:dodgerblue"',"r:4,c:1" => 'style="font-weight:bold;;color:dodgerblue"',"r:1" => 'style="font-weight:bold;;color:Green"',"r:2" => 'style="font-weight:bold;;color:Green"',"r:4,c:2" => 'style="font-weight:bold;;color:green"',"r:4,c:3" => 'style="font-weight:bold;;color:red"',"r:14,c:2" => 'style="font-weight:bold;;color:green"',"r:14,c:3" => 'style="font-weight:bold;;color:red"',"r:14,c:4" => 'style="font-weight:bold;;color:yellow"',"r:18,c:2" => 'style="font-weight:bold;;color:green"',"r:18,c:3" => 'style="font-weight:bold;;color:red"',"r:18,c:4" => 'style="font-weight:bold;;color:yellow"'}
attr DSLInfo nonames 1
attr DSLInfo valueColumns { upTime => 'colspan="3"',title => 'colspan="4"' }
attr DSLInfo valueFormat {if($READING eq 'title'){$VALUE="Technicolor TG788A1vn"}}
attr DSLInfo valueSuffix {outputPwrDown => " dBm", outputPwrUp => " dBm", attUp=>" dB",attDown=>" dB", marginUp=>" dB",marginDown=>" dB"}
Telnet muss dazu natürlich in Perl installiert sein: >cpan install Net::Telnet<
Vielleicht kann ja der eine oder andere Landsmann unter uns hier was damit anfangen.
lg, Ici
PS: Ich hab hier auch noch eine nagelneue A1-WLAN-Box DV221 hier rumstehn, vielleicht mach ich in den nächsten Tagen mal für diese auch so eine Sub :)
... Na Servus - berauschend ist Dein DSL-Speed aber a ned ...
Und ich dacht mir, nur hier in Bayern bin i so langsam :-\
Seit Juli 2012 sand ca. 800m von mir entfernt vdsl50 da, nur weder Telekom noch Bürgermeister
wollen's bis zu uns verlegen... rentiert sich ned, sagn's, de A...l... >:(
Daher hab i a nur ca. 2 Mbit down und 400 up.
War etz zwar total offtopic, aber abundzu muaß der Frust raus ::)
Servus und Grüße ins Nachbarland
Karl
HAllo Ici
Funkt einwandfrei nachdem man sich ein wenig beschäftigt hat damit.
Man sollte dazu vermerken das bei dir "CP1335VACET" in der Sub Routine durch den Namen des eigenen Modems ersetzt gehört.
Bei mir siehts so aus (siehe Anhang)
LG TOM
ZitatNa Servus - berauschend ist Dein DSL-Speed aber a ned ...
Hatte bis vor 2 Wochen auch noch max. 2048.....Dann hab ich des neue Modem bekommen, weil das alte plötzlich ständig Verbindungsabbrüche hatte und sich nicht mehr syncen konnte.
Seither komm ich interessanterweise auf 4MB, obwohl sich an der Leitung nix geändert hatte.
Jetzt is aber leider Ende der Fahnenstange.....Die Telekom kommt bei uns mit 6.5MB vom Nachbardorf hierher....Da gibts keine Steigerung mehr momentan ;(
lg, Ici
PS: vor 15 Jahren, als wir das Haus hier gekauft haben, sind wir von Wien aufs Land gezogen.....Damals hab ich von Telekabel auf 58k-Modem umsteigen müssen, weils hier heraussen nix besseres gab :o