Ein Modul zur Erfassen von diversen RPi/Linux-Statistiken (SYSMON)

Begonnen von hexenmeister, 06 Dezember 2013, 17:44:38

Vorheriges Thema - Nächstes Thema

blueklamo

Danke ! @Hexenmeister und alle anderen Helfer für das SYSMON

* hatte zuerst 99_RPiUtils.pm versucht, und bin an "Undefined subroutine &main::ShowRPiValues called at (eval 159) line 1. "  gescheitert
* mit deinem Neuen Modul "42_SYSMon.pm" <schon vorhanden und hineinkopieren deiner Beispieleinträge (siehe erste Seite) läuft Es schon sehr gut.

* dazu noch eine Frage:
ganz unten im Beispiel für fhem.conf steht:
# Anzeige CPU Auslasung
define wl_sysmon_cpustat SVG FileLog_sysmon:SM_CPUStat:CURRENT
attr wl_sysmon_cpustat group RPi
attr wl_sysmon_cpustat label "CPU(min/max): user:$data{min1}/$data{max1} nice:$data{min2}/$data{max2} sys:$data{min3}/$data{max3} idle:$data{min4}/$data{max4} io:$data{min5}/$data{max5} irq:$data{min6}/$data{max6} sirq:$data{min7}/$data{max7}"
attr wl_sysmon_cpustat plotsize 840,420
attr wl_sysmon_cpustat room 9.99_Test
define wl_sysmon_cpustat_s SVG FileLog_sysmon:SM_CPUStatSum:CURRENT
attr wl_sysmon_cpustat_s group RPi
attr wl_sysmon_cpustat_s label "CPU(min/max): user:$data{min1}/$data{max1} nice:$data{min2}/$data{max2} sys:$data{min3}/$data{max3} idle:$data{min4}/$data{max4} io:$data{min5}/$data{max5} irq:$data{min6}/$data{max6} sirq:$data{min7}/$data{max7}"
attr wl_sysmon_cpustat_s plotsize 840,420
attr wl_sysmon_cpustat_s room 9.99_Test

## ok das ist scheinbar ein TEST

# es wird der Raum 9.99_Test erzeugt, und dort 2 große Plots erstellt (nur leider ohne Inhalt)

# ich habs auf RasPi-B , und auf dem aktuellen RasPI-2-B so laufen
#in beiden Fällen stehen in der "sysmon-2015-02.log" nur weit oben (am Anfang der Datei) einige vermutlich gemeinte Einträge z.B:
Pi-2-B
2015-02-22_21:16:24 sysmon stat_cpu3_percent: 0.05 0.00 0.05 99.90 0.00 0.00 0.00
2015-02-22_21:16:24 sysmon stat_cpu0_text: user: 0.84 %, nice: 0.00 %, sys: 0.18 %, idle: 98.94 %, io: 0.03 %, irq: 0.00 %, sirq: 0.00 %
Pi-B
2015-02-22_21:33:04 sysmon stat_cpu: 87789 0 55398 58154673 31670 1073 213678

# was mir bei Aufruf von :  SM_CPUStat:CURRENT und  SM_CPUStatSum   nicht logisch erscheint.
* sollten diese Aufrufe angepasst werden (auch an die Unterschiede 1, oder 4-CPU der RPi ?
* und warum erfolgen keine aktuellen Einträge mehr ?

sorry für die vermutlich naive Frage (bin kein Experte / nur begeisterter Nutzer von FHEM)
Ich bin nur neugierig, kann es jedoch auch als Test betrachten, und den letzten Abschnitt (Raum 9.99_Test einfach löschen)

m.f.G  blueklamo
Banana-PI mit CUL868 , 5FHT u. FS20 aktiv 
Pi-B+ mit owfs <<->> CubieTruck OWServer/OWDevice
## Bastelprojekt: ((Pi2-B mit Cam ....?))

hexenmeister

SYSMON liest die CPU-Auslastung mit Aufruf von cat /proc/stat
Wenn das auf Deinem System geht (wovon ich ausgehe), dann kann SYSMON das auch erfassen.
Wenn das nicht im Log erscheint, vermute ich, dass dies per event-on-update-reading oder event-on-update-change verhindert wird. Ohne Deine Definition zu sehen, kann ich nichts sagen.

blueklamo

event-on-update-reading      cpu_temp,cpu_temp_avg,cpu_freq,eth0_diff,loadavg,ram,fs_.*       < ist drin
und  Ja beide RasPi können                           cat /proc/stat
z.B. Pi-2-B:
pi@rasp2fhem ~ $  cat /proc/stat
cpu  17014 0 21057 33435552 2195 5 208 0 0 0
cpu0 6665 0 7308 8326956 634 5 165 0 0 0
cpu1 4028 0 4679 8367250 519 0 14 0 0 0
cpu2 3777 0 4667 8370241 503 0 18 0 0 0
cpu3 2544 0 4403 8371105 539 0 11 0 0 0
intr 25991527 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8096 2361 0 0 0 0 0 0 23623863 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3383 2 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 30 123377 0 0 0 0 0 0 0 0 0 0 0 0 0 0 976686 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ctxt 3502319
btime 1424632585
processes 17257
procs_running 1
procs_blocked 0
softirq 2505353 688955 685824 16757 18596 0 0 132915 675162 460 286684

Ich dachte, da ich alle Einstellungen von deiner Vorgabe-(Beispiel) kopiert habe, geht es einfach so. 

*dann muß ich den Eintrag    event-on-update-reading   wohl um  Etwas erweitern ?  z.B.  "stat_cpu"    (OK?)

Banana-PI mit CUL868 , 5FHT u. FS20 aktiv 
Pi-B+ mit owfs <<->> CubieTruck OWServer/OWDevice
## Bastelprojekt: ((Pi2-B mit Cam ....?))

hexenmeister

Ja, wenn man das haben will, sollte man noch "stat_cpu_percent" hinzufügen, oder sogar für die einzelenen Kerne.
Im Beispiel habe ich das absichtlich unterlassen, da diese Option doch relativ viel Daten erzeugt und die meisten Nutzer wenig Nutzen davon tragen ;)

Eigentlich war das Beispiel eben nur als Beispiel und Anregung zu eingener Konfiguration gedacht, nicht als Fertiglösung.


blueklamo

Danke nochmals  "Wieder was gelernt!"

Und besonderen Dank " für das prima funktionierende Beispiel "
alleine hätte ich das nicht hinbekommen ;=)

ES funktioniert

* Und wenn ich über das Kennenlern- und Experimentier- Stadium hinaus bin, weiß ich sicherlich auch besser
  welche Anzeigen (für mich) wichtig und sinnvoll sind.
* Sysmon sieht auf jeden Fall schon mal super aus, und hilft bestimmt auch bei Erweiterungen abzuschätzen
  Was geht, und was eher nicht
* Wenn erst mal Alles richtig läuft kann man ES ja komplett deaktivieren (u. bei Bedarf wieder einschalten)

m.f.G  blueklamo
Banana-PI mit CUL868 , 5FHT u. FS20 aktiv 
Pi-B+ mit owfs <<->> CubieTruck OWServer/OWDevice
## Bastelprojekt: ((Pi2-B mit Cam ....?))

nesges

Zitat von: hexenmeister am 04 Februar 2015, 00:09:27Evtl. ersetze ich die ifconfig-Aufrufe durch den Vorschlag von @nesges (vielen Dank an dieser Stelle :) )
Ich muss mir noch genauer ansehen, aber beim schnellen Blick sieht sehr gut aus. Sowohl auf Cubietruck als auch auf dem Fritzbox.

Hatten sich hier noch Probleme ergeben? Kann ich unterstützen? Aktuell verwende ich die Speed-Readings noch in einer lokal gepatchten 72_Fritzbox.pm.

hexenmeister

Ähm... Habe ehrlich gesagt bereits ganz vergessen.
Womit war da noch mal das Problem? Magst Du einen SYSMON-Patch nach Deinen Vorstellungen erstelen?

nesges

#802
Auf Seite 48; es ging zum einen um Ersatz für's ifconfig-Parsen, zum anderen vermisste ich Readings mit den puren Zahlenwerten. Folgender minimalinvasiver Patch gegen die aktuelle SVN-Version:

--- svn/fhem-code/fhem/FHEM/42_SYSMON.pm        2015-02-24 23:32:06.329578154 +0100
+++ /opt/fhem/FHEM/42_SYSMON.pm 2015-02-25 00:03:43.000000000 +0100
@@ -2374,16 +2374,19 @@
     }

     if(defined $ip) {
+       $ip =~ s/addr://;
        $map->{$nName.IP_SUFFIX} = $ip;
     }

     if(defined $ip6) {
+       $ip6 =~ s/addr://;
        $map->{$nName.IP6_SUFFIX} = $ip6;
     }

-    my $rxRaw = -1;
-    my $txRaw = -1;
+    my $rxRaw = SYSMON_execute($hash, "cat /sys/class/net/$nName/statistics/rx_bytes")||-1;
+    my $txRaw = SYSMON_execute($hash, "cat /sys/class/net/$nName/statistics/tx_bytes")||-1;

+  if($rxRaw<0||$txRaw<0) {
     if(defined $dataThroughput) {
       # remove RX bytes or TX bytes from string
       $dataThroughput =~ s/RX bytes://;
@@ -2414,12 +2417,16 @@
         }
       }
     }
+  }

     if($rxRaw<0) {
        # Daten nicht gefunden / Format unbekannt
        $map->{$nName} = "unexpected format";
          $map->{$nName.DIFF_SUFFIX} = "unexpected format";
     } else {
+      $map->{$nName."_rx"} = $rxRaw;
+      $map->{$nName."_tx"} = $txRaw;
+
       $rxRaw = $rxRaw / 1048576; # Bytes in MB
       $txRaw = $txRaw / 1048576;


$ip =~ s/addr://;
korrigieren mMn einen Bug im Regex, der "addr:" in den IP-Adressen stehen lässt. Falls das Absicht ist, ignorieren - allerdings finde ich ein Reading mit der reinen IP praktischer.

my $rxRaw = SYSMON_execute($hash, "cat /sys/class/net/$nName/statistics/rx_bytes")||-1
hat das Potential die ganze ifconfig-Parserei überflüssig zu machen, d.h. der Block 2390ff könnte wegfallen. Sollte man aber auf anderen Boxen gegen checken oder als Fallback drin lassen.

$map->{$nName."_rx"} = $rxRaw;
war durch dich vorbereitet, fehlte aber noch (sofern ich's nicht übersehen habe).

hexenmeister

Vielen Dank, schaue ich mir an (gerade die Zit etwas knapp).

anfichtn

#804
Moin!

Ich habe gerade SYSMON aktiviert, da mich die Systemstatistik und der aktuelle Zustand interessieren... laut log erfasst SYSMON alle werte, erstellt jedoch keinerlei Readings... hab ich was verpasst?

meine Definition:

define SysMon SYSMON
attr SysMon event-on-update-reading cpu_temp,cpu_temp_avg,cpu_freq,eth0_diff,wlan0_diff,loadavg,ram,^~ /.*usb.*,~ /$
attr SysMon filesystems fs_boot:/boot,fs_root:/:Root,fs_usb1:/media/usb1:USB-Stick
attr SysMon network-interfaces eth0:eth0:Ethernet,wlan0:wlan0:WiFi
attr SysMon room 99_System
attr SysMon verbose 5


define sysv1 weblink htmlCode {SYSMON_ShowValuesHTML('SysMon')}
attr sysv1 room 99_System

define wl_sysmon_load SVG myDbLog:SMLoadDB:CURRENT
attr wl_sysmon_load label "Load Min: $data{min1}, Max: $data{max1}, Aktuell: $data{currval1}"
attr wl_sysmon_load plotfunction SysMon
attr wl_sysmon_load room 99_System
FHEM 5.6 + Pilight + Pimatic auf BananaPro mit Bananian 15.04 r01
FB7270 v2 & FB7412
LDA382A mit WifiLight
MAX-Cube (aculfw), 6 Fensterkonstakte, 5 HK-Thermostate, 3 WandThermostate
[...]

Spartacus

Hallo,
ich bekomme vom SYSMON-Modul immer Fehlermeldungen beim Start von fhem:
Use of uninitialized value $t[-1] in int at ./FHEM/42_SYSMON.                              pm line 3079, <> line 361.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3054, <> line 361.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3065, <> line 361.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3110, <> line 361.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3121, <> line 361.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3132, <> line 361.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3143, <> line 361.
Use of uninitialized value $t[-1] in int at ./FHEM/42_SYSMON.pm line 3079, <> li                              ne 373.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3054, <> line 373.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3065, <> line 373.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3110, <> line 373.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3121, <> line 373.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3132, <> line 373.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3143, <> line 373.


Außerdem stürzt fhem mit einem telnet Error gnadenlos ab, wenn ich libnet-telnet-perl installiere. Ich habe die lib wieder deinstalliert und nun läuft fhem wieder allerdings ohne SYSMON.

Jemand eine Idee?
Christian
Fhem-System: 1 x raspberry PI Typ B, 1 x enOcean PI Typ B | Enocean: PTM210, FMS61NP, FAM14, 2 x FSR14-4x, FTS14-EM | LaCrosse: 2 x TX29D über Jeelink V3 | 1-Wire: 2 x DS18B20 über DS9490R

anfichtn

Zitat von: Spartacus am 26 Februar 2015, 17:38:51
Hallo,
ich bekomme vom SYSMON-Modul immer Fehlermeldungen beim Start von fhem:
Use of uninitialized value $t[-1] in int at ./FHEM/42_SYSMON.                              pm line 3079, <> line 361.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3054, <> line 361.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3065, <> line 361.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3110, <> line 361.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3121, <> line 361.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3132, <> line 361.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3143, <> line 361.
Use of uninitialized value $t[-1] in int at ./FHEM/42_SYSMON.pm line 3079, <> li                              ne 373.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3054, <> line 373.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3065, <> line 373.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3110, <> line 373.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3121, <> line 373.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3132, <> line 373.
Use of uninitialized value in int at ./FHEM/42_SYSMON.pm line 3143, <> line 373.


Außerdem stürzt fhem mit einem telnet Error gnadenlos ab, wenn ich libnet-telnet-perl installiere. Ich habe die lib wieder deinstalliert und nun läuft fhem wieder allerdings ohne SYSMON.

Jemand eine Idee?
Christian
Ohne Config schwierig....

Die Glaskugel schweigt sich dazu auch aus.... :-)
FHEM 5.6 + Pilight + Pimatic auf BananaPro mit Bananian 15.04 r01
FB7270 v2 & FB7412
LDA382A mit WifiLight
MAX-Cube (aculfw), 6 Fensterkonstakte, 5 HK-Thermostate, 3 WandThermostate
[...]

Spartacus

Hallo,
sorry, dachte das wäre nicht wichtig, da Standard, habe momentan alles auskommentiert:
#define KG.sr.rPi.Enterprise SYSMON 5 5 5 10
#attr KG.sr.rPi.Enterprise alias Enterprise
#attr KG.sr.rPi.Enterprise disable 0
#attr KG.sr.rPi.Enterprise event-on-update-reading cpu_temp,cpu_temp_avg,cpu_freq,eth0_diff,loadavg,ram,fs_.*,stat_cpu_percent
#attr KG.sr.rPi.Enterprise filesystems fs_boot:/boot,fs_root:/:Root,fs_usb1:/media/usb1:USB-Stick
#attr KG.sr.rPi.Enterprise group RPi
#attr KG.sr.rPi.Enterprise network-interfaces eth0:eth0:Ethernet,wlan0:wlan0:WiFi
#attr KG.sr.rPi.Enterprise room 99-Dienste
#attr KG.sr.rPi.Enterprise sortby 01
#attr KG.sr.rPi.Enterprise event-on-update-reading cpu_temp,cpu_temp_avg,cpu_freq,eth0_diff,loadavg,ram,^~ /.*usb.*,~ /$
#
# Sysmon für Blackberry
#
#define KG.sr.rPi.Blackberry SYSMON telnet:user@blackberry 5 5 5 10
#attr KG.sr.rPi.Blackberry alias Blackberry
#attr KG.sr.rPi.Blackberry disable 1
#attr KG.sr.rPi.Blackberry event-on-update-reading cpu_temp,cpu_temp_avg,cpu_freq,eth0_diff,loadavg,ram,fs_.*,stat_cpu_percent
#attr KG.sr.rPi.Blackberry filesystems fs_boot:/boot,fs_root:/:Root,fs_usb1:/media/usb1:USB-Stick
#attr KG.sr.rPi.Blackberry group RPi
#attr KG.sr.rPi.Blackberry network-interfaces eth0:eth0:Ethernet,wlan0:wlan0:WiFi
#attr KG.sr.rPi.Blackberry room 99-Dienste
#attr KG.sr.rPi.Blackberry sortby 02


Wie gesagt, Telnet geht momantan gar nicht, dann stürzt fhem ab. Deshalb läuft mein Fritzbox Modul auch nicht. Die Daten vom lokalen System werden sauber ausgelesen. Sind halt nur die Fehlermeldungen beim Starten von fhem...
Christian
Fhem-System: 1 x raspberry PI Typ B, 1 x enOcean PI Typ B | Enocean: PTM210, FMS61NP, FAM14, 2 x FSR14-4x, FTS14-EM | LaCrosse: 2 x TX29D über Jeelink V3 | 1-Wire: 2 x DS18B20 über DS9490R

hexenmeister

@anfichtn
Verstehe ich nicht. Die Konfiguration ist auf den ersten Blich ok. Was steht im Log, was liefert list auf sysmon und was kommt bei get list darauf?

@Spartacus
Die Zeilen aus dem Log sagen mir leider nichts, Deine Version ist anscheinend nicht aktuell. Mache mal am Besten zuerst ein Update.


Auch mit dem Absturz - kann ich nur raten. Error-Log von FHEM wäre schon wichtig.
In jedem Fall hast Du da ein Problem nicht mit dem SYSMON. Es wäre besser in einem anderen Thread aufgehoben.



hexenmeister

Zitat von: nesges am 25 Februar 2015, 00:16:10
Auf Seite 48; es ging zum einen um Ersatz für's ifconfig-Parsen, zum anderen vermisste ich Readings mit den puren Zahlenwerten...

Angesehen und verstanden ;) Danke für die gute Aufbereitung! Ich denke, ich werde das so übernehmen. Evtl. auch mit Fallback (meine Linux-Boxen kommen jedoch mit Denem Vorschlag alle zurecht). Schaffe aber heute wieder nicht. :(