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

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

Vorheriges Thema - Nächstes Thema

hexenmeister

Telnet-Modul ist nicht erforderlich, es sei denn, Du konfigurierst einen Remote-Zugriff per Telnet.
Wie ist SYSMON-Eintrag definiert?

frank

ZitatWie ist SYSMON-Eintrag definiert?
ich habe das beispiel benutzt "define sysmon SYSMON 1 1 1 10" und erhalte mit der aktuellen version

2015.08.10 13:43:19.402 1: PERL WARNING: Bareword found where operator expected at ./FHEM/42_SYSMON.pm line 4251, near "s/[^0-9]//gr"
2015.08.10 13:43:19.427 1: reload: Error:Modul 42_SYSMON deactivated:
Can't modify non-lvalue subroutine call in substitution (s///) at ./FHEM/42_SYSMON.pm line 4251, near "s/[^0-9]//gr"
syntax error at ./FHEM/42_SYSMON.pm line 4251, near "s/[^0-9]//gr"
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4262.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4264.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4265.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4269.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4271.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4272.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4273.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4273.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4274.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4274.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4275.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4275.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4287.
Global symbol "$dev" requires explicit package name at ./FHEM/42_SYSMON.pm line 4304.
Global symbol "$dev" requires explicit package name at ./FHEM/42_SYSMON.pm line 4305.
Type of arg 1 to keys must be hash or array (not hash element) at ./FHEM/42_SYSMON.pm line 4305, near "})"
./FHEM/42_SYSMON.pm has too many errors.

2015.08.10 13:43:19.428 0: Can't modify non-lvalue subroutine call in substitution (s///) at ./FHEM/42_SYSMON.pm line 4251, near "s/[^0-9]//gr"
syntax error at ./FHEM/42_SYSMON.pm line 4251, near "s/[^0-9]//gr"
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4262.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4264.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4265.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4269.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4271.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4272.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4273.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4273.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4274.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4274.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4275.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4275.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4287.
Global symbol "$dev" requires explicit package name at ./FHEM/42_SYSMON.pm line 4304.
Global symbol "$dev" requires explicit package name at ./FHEM/42_SYSMON.pm line 4305.
Type of arg 1 to keys must be hash or array (not hash element) at ./FHEM/42_SYSMON.pm line 4305, near "})"
./FHEM/42_SYSMON.pm has too many errors.
FHEM: 6.0(SVN) => Pi3(buster)
IO: CUL433|CUL868|HMLAN|HMUSB2|HMUART
CUL_HM: CC-TC|CC-VD|SEC-SD|SEC-SC|SEC-RHS|Sw1PBU-FM|Sw1-FM|Dim1TPBU-FM|Dim1T-FM|ES-PMSw1-Pl
IT: ITZ500|ITT1500|ITR1500|GRR3500
WebUI [HMdeviceTools.js (hm.js)]: https://forum.fhem.de/index.php/topic,106959.0.html

hexenmeister

Jo, das ist was anderes, hier scheinen die Erweiterungen zum Bar-Chart-Anzeigen nicht mit der Perl-Version auf der Box zu spielen.
Im Anhang ist eine Version ohne. Die entspricht ansonsten der aktuellen Version.

frank

perfekter service.  :)

danke, ist jetzt mindestens schon mal definiert.
FHEM: 6.0(SVN) => Pi3(buster)
IO: CUL433|CUL868|HMLAN|HMUSB2|HMUART
CUL_HM: CC-TC|CC-VD|SEC-SD|SEC-SC|SEC-RHS|Sw1PBU-FM|Sw1-FM|Dim1TPBU-FM|Dim1T-FM|ES-PMSw1-Pl
IT: ITZ500|ITT1500|ITR1500|GRR3500
WebUI [HMdeviceTools.js (hm.js)]: https://forum.fhem.de/index.php/topic,106959.0.html

frank

hallo alexander,

bei mir auf der fritzbox habe ich ein speicherproblem (auch ohne dein modul  ;)). "cannot fork: cannot allocate memory" bekomme ich von zeit zu zeit. http://forum.fhem.de/index.php/topic,39887.0.html
um das näher zu untersuchen, plotte ich gerade die ram-nutzung. gibt es die möglichkeit, den gerade von fhem genutzen speicher zu ermitteln? dann könnte ich besser erkennen, wer den weniger werdenden freien speicher benutzt. zumindestens ob der an fhem geht, oder nicht.

gruss frank
FHEM: 6.0(SVN) => Pi3(buster)
IO: CUL433|CUL868|HMLAN|HMUSB2|HMUART
CUL_HM: CC-TC|CC-VD|SEC-SD|SEC-SC|SEC-RHS|Sw1PBU-FM|Sw1-FM|Dim1TPBU-FM|Dim1T-FM|ES-PMSw1-Pl
IT: ITZ500|ITT1500|ITR1500|GRR3500
WebUI [HMdeviceTools.js (hm.js)]: https://forum.fhem.de/index.php/topic,106959.0.html

hexenmeister

Hi Frank!

Sysmon kann das nicht. Sollte man auch außerhalb von FHEM machen, um das Ergebnis nicht zu verfälschen. Damit sind wir hier OT.
Ich habe schnell (und schmutzig) ein Befehl zusammengesetzt, habe dann aber begriffen, dass FritzBox kein AWK am Bord hat und ps kennt kein xa :(

ps xa | grep "fhem.pl fhem.cfg" | grep -v grep | awk '{system("cat /proc/"$1"/status")}' | grep VmSize | awk '{ SUM += $2} END { print SUM }'

Per Hand geht aber:
ps | grep "fhem.pl fhem.cfg" | grep -v grep
und gefundenen PID einsetzen:
cat /proc/<PID>/status | grep VmSize

K.A. wie man das auf der Box automatisieren kann...,

frank

danke für deinen einsatz.
kommt zumindestens erstmal ein plausible zahl raus. 37576kB
FHEM: 6.0(SVN) => Pi3(buster)
IO: CUL433|CUL868|HMLAN|HMUSB2|HMUART
CUL_HM: CC-TC|CC-VD|SEC-SD|SEC-SC|SEC-RHS|Sw1PBU-FM|Sw1-FM|Dim1TPBU-FM|Dim1T-FM|ES-PMSw1-Pl
IT: ITZ500|ITT1500|ITR1500|GRR3500
WebUI [HMdeviceTools.js (hm.js)]: https://forum.fhem.de/index.php/topic,106959.0.html

Wernieman

Kleine optimierung:
ps | grep [f]hem

damit spart man sich den grep Befehl wieder rauszugreppen ...

und um die Probleme mit dem "PID" raussuchen zu automatisieren .. könntest Du mir bitte mal ie Ausgabe von ps der Fritte geben?
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

frank

danke, wernieman. da alexander bereits die gelbe off-topic-karte gezückt hat, habe ich die ps ausgabe im anderen thread gepostet. dann ist auch alles unter einem dach.

gruss frank
FHEM: 6.0(SVN) => Pi3(buster)
IO: CUL433|CUL868|HMLAN|HMUSB2|HMUART
CUL_HM: CC-TC|CC-VD|SEC-SD|SEC-SC|SEC-RHS|Sw1PBU-FM|Sw1-FM|Dim1TPBU-FM|Dim1T-FM|ES-PMSw1-Pl
IT: ITZ500|ITT1500|ITR1500|GRR3500
WebUI [HMdeviceTools.js (hm.js)]: https://forum.fhem.de/index.php/topic,106959.0.html

volschin

Hallo Alexander,
ich bin gerade an einem kniffligen Problem, dass IMO eine Anpassung des Moduls braucht.

Es gibt ein Reading stat_cpu_percent und eines für stat_cpu_diff. Für stat_cpu_percent gibt es einen Plot, der eigentlich aber sinnlos ist, da immer die gesamte Laufzeit betrachtet wird. Bei cpu_diff ist leider eine Menge Processing zu erledigen, wenn man einen brauchbaren Output haben will.

# 2015-08-23_13:47:59 sysmon stat_cpu_diff: 2132 0 308 44803 3 1 25

#DbLog <SPEC1>:stat_cpu_diff:::$val=~s/(\d*).*/$1/eg
#DbLog <SPEC1>:stat_cpu_diff:::$val=~s/\d*.(\d*).*/$1/eg
#DbLog <SPEC1>:stat_cpu_diff:::$val=~s/\d*.\d*.(\d*).*/$1/eg
#DbLog <SPEC1>:stat_cpu_diff:::$val=~s/\d*.\d*.\d*.(\d*).*/$1/eg
#DbLog <SPEC1>:stat_cpu_diff:::$val=~s/\d*.\d*.\d*.\d*.(\d*).*/$1/eg
#DbLog <SPEC1>:stat_cpu_diff:::$val=~s/\d*.\d*.\d*.\d*.\d*.(\d*).*/$1/eg
#DbLog <SPEC1>:stat_cpu_diff:::$val=~s/\d*.\d*.\d*.\d*.\d*.\d*.(\d*).*/$1/eg


Das Ergebnis ist nicht toll. Eigentlich dachte ich an sowas
(https://oss.oetiker.ch/rrdtool/gallery/amz2.png)

Das heißt ich benötige etwas wie einen _diff aber in Prozent umgerechnet.

Sehe ich das richtig oder stehe ich gerade auf dem Schlauch?

Gruß
Veit
Intel NUC+Ubuntu 24.04+Docker+FHEM6
HomeMatic: HM-MOD-RPI-PCB+HM-USB-CFG2+hmland+diverse, HUE: Hue-Bridge, RaspBee+deCONZ+diverse
Amzn Dash-Buttons, Siro Rollos
4xRPi, 4xCO20, OWL+USB, HarmonyHub, FRITZ!Box 7590, Echo Dots+Show8, HomeBridge

volschin

#1030
Für einen Gesamtwert habe ich es.  8)

# SYSMON
#
# Anzeige: system cpu auslastung
#
# define wl_sysmon_cpustat SVG myDbLog:SM_DB_CPUStat:HISTORY
# attr wl_sysmon_load label "CPU Stat Min: $data{min1}, Max: $data{max1}, Aktuell: $data{currval1}"
# attr wl_sysmon_load plotfunction sysmon
# attr wl_sysmon_load room RaspberryPi
#
# Daten: user nice system idle iowait irq softirq
# Beispiel aus dem Logfile:
# 2015-08-23_13:47:59 sysmon stat_cpu_diff: 2132 0 308 44803 3 1 25
#
#

set terminal png transparent size <SIZE> crop

set output '<OUT>.png'
set xdata time
set timefmt "%Y-%m-%d_%H:%M:%S"
set xlabel " "
set ytics

set title '<L1>'
set grid xtics y2tics

set y2label "Auslastung %"

#DbLog <SPEC1>:stat_cpu_diff:::$val=~s/^(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)/sprintf("%.2f",($1+$2+$3+$5+$6+$7)\/($1+$2+$3+$4+$5+$6+$7)*100)/eg
#DbLog <SPEC1>:stat_cpu0_diff:::$val=~s/^(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)/sprintf("%.2f",($1+$2+$3+$5+$6+$7)\/($1+$2+$3+$4+$5+$6+$7)*100)/eg
#DbLog <SPEC1>:stat_cpu1_diff:::$val=~s/^(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)/sprintf("%.2f",($1+$2+$3+$5+$6+$7)\/($1+$2+$3+$4+$5+$6+$7)*100)/eg
#DbLog <SPEC1>:stat_cpu2_diff:::$val=~s/^(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)/sprintf("%.2f",($1+$2+$3+$5+$6+$7)\/($1+$2+$3+$4+$5+$6+$7)*100)/eg
#DbLog <SPEC1>:stat_cpu3_diff:::$val=~s/^(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)/sprintf("%.2f",($1+$2+$3+$5+$6+$7)\/($1+$2+$3+$4+$5+$6+$7)*100)/eg

plot \
  "<IN>" using 1:2 ls l0 axes x1y1 title 'Gesamt' lw 2.0 with lines, \
  "<IN>" using 1:2 ls l1 axes x1y1 title 'CPU0' lw 1.0 with lines, \
  "<IN>" using 1:2 ls l2 axes x1y1 title 'CPU1' lw 1.0 with lines, \
  "<IN>" using 1:2 ls l3 axes x1y1 title 'CPU2' lw 1.0 with lines, \
  "<IN>" using 1:2 ls l4 axes x1y1 title 'CPU3' lw 1.0 with lines


EDIT: Ergänzt und korrigiert für 4-Kern CPU.
Intel NUC+Ubuntu 24.04+Docker+FHEM6
HomeMatic: HM-MOD-RPI-PCB+HM-USB-CFG2+hmland+diverse, HUE: Hue-Bridge, RaspBee+deCONZ+diverse
Amzn Dash-Buttons, Siro Rollos
4xRPi, 4xCO20, OWL+USB, HarmonyHub, FRITZ!Box 7590, Echo Dots+Show8, HomeBridge

volschin

Ich habe noch damit zu kämpfen, dass der Wert nach einem Reboot so aussieht:
2015-08-25_07:29:06 -5297255 -4373 -1299908 -114827878 -30409 -613 -57086
Intel NUC+Ubuntu 24.04+Docker+FHEM6
HomeMatic: HM-MOD-RPI-PCB+HM-USB-CFG2+hmland+diverse, HUE: Hue-Bridge, RaspBee+deCONZ+diverse
Amzn Dash-Buttons, Siro Rollos
4xRPi, 4xCO20, OWL+USB, HarmonyHub, FRITZ!Box 7590, Echo Dots+Show8, HomeBridge

PeMue

so, langsam werde ich die FritzBox in den Wind schießen. Hatte gestern beim Fax verschicken (1 Seite!) mehrere Reboots und mein 1-wire USB Adapter wurde gegen den RFXTRX vertauscht.
Das größere Problem ist, dass SYSMON nicht mehr geladen wird, hier ein Log Auszug:
2015.08.25 21:06:55 1: reload: Error:Modul 42_SYSMON deactivated:
Can't modify time in substitution (s///) at ./FHEM/42_SYSMON.pm line 4251, near "s/[^0-9]//gr"
syntax error at ./FHEM/42_SYSMON.pm line 4251, near "s/[^0-9]//gr"
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4262.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4264.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4265.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4269.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4271.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4272.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4273.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4273.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4274.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4274.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4275.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4275.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4287.
Global symbol "$dev" requires explicit package name at ./FHEM/42_SYSMON.pm line 4304.
Global symbol "$dev" requires explicit package name at ./FHEM/42_SYSMON.pm line 4305.
Type of arg 1 to keys must be hash or array (not hash element) at ./FHEM/42_SYSMON.pm line 4305, near "})"
./FHEM/42_SYSMON.pm has too many errors.

2015.08.25 21:06:55 0: Can't modify time in substitution (s///) at ./FHEM/42_SYSMON.pm line 4251, near "s/[^0-9]//gr"
syntax error at ./FHEM/42_SYSMON.pm line 4251, near "s/[^0-9]//gr"
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4262.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4264.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4265.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4269.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4271.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4272.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4273.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4273.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4274.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4274.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4275.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4275.
Global symbol "$opt" requires explicit package name at ./FHEM/42_SYSMON.pm line 4287.
Global symbol "$dev" requires explicit package name at ./FHEM/42_SYSMON.pm line 4304.
Global symbol "$dev" requires explicit package name at ./FHEM/42_SYSMON.pm line 4305.
Type of arg 1 to keys must be hash or array (not hash element) at ./FHEM/42_SYSMON.pm line 4305, near "})"
./FHEM/42_SYSMON.pm has too many errors.

Hier noch die Rechte (ok, Albtraum eines jeden SysOp  ;D):
# ls -la 42_SYS*
-rwxrwxr-x    1 root     root        225424 Aug 24 21:39 42_SYSMON.pm

Hat jemand eine Idee, wo ich suchen soll? Habe schon aus dem Repository die aktuelle Version überschrieben, aber da geht nichts mehr  >:(

Danke + Gruß

PeMue



RPi3Bv1.2 rpiaddon 1.66 6.0 1xHM-CC-RT-DN 1.4 1xHM-TC-IT-WM 1.1 2xHB-UW-Sen-THPL-O 0.15 1x-I 0.14OTAU  1xCUNO2 1.67 2xEM1000WZ 2xUniroll 1xASH2200 3xHMS100T(F) 1xRFXtrx 90 1xWT440H 3xTFA30.3150 5xFA21
RPi1Bv2 LCDCSM 1.63 5.8 2xMAX HKT 1xMAX RT V200KW1 Heizung Wasser

hexenmeister

Zitat von: PeMue am 25 August 2015, 21:17:07
so, langsam werde ich die FritzBox in den Wind schießen. Hatte gestern beim Fax verschicken (1 Seite!) mehrere Reboots und mein 1-wire USB Adapter wurde gegen den RFXTRX vertauscht.
Das größere Problem ist, dass SYSMON nicht mehr geladen wird

Probiere mal die Version aus dem Antowrt #1022 auf dieser Seite.

Grüße,

Alexander

hexenmeister

Zitat von: volschin am 25 August 2015, 14:04:17
Für einen Gesamtwert habe ich es.  8)
Sieht komplex aus. Ein Extra-Reading dafür wäre sicher besser. Wie genau willst die Werte haben?