Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Berechnung von CPU-Load: Verbesserungsvorschlag #171

Open
marian-t-web-de opened this issue Feb 12, 2024 · 0 comments
Open

Berechnung von CPU-Load: Verbesserungsvorschlag #171

marian-t-web-de opened this issue Feb 12, 2024 · 0 comments

Comments

@marian-t-web-de
Copy link

marian-t-web-de commented Feb 12, 2024

Hallo,

die cpu_load states des rpi2 Adapters bilden die Interpretation der Ausgabe von /proc/loadavg. Diese stellt alledings kein cpu_load, sondern - kurzgefasst - das Ergebniss der Division der Anzahl der aktiven durch die Anzahl aller Processe (über 1/5/15 Min.)
In Allgemeinen weicht diese von der tatsächlichen CPU-Last deutlich (siehe https://www.baeldung.com/linux/get-cpu-usage).

In meinem Fall ergibt die /proc/loadavg bzw. uptime CPU_load von über 40%, die aus vmstat errechnete zw. 3% und 15% (s.u.) scheint mir realistischer und näher der 'top' Ausgabe.

Wäre es möglich zu den vorhandenen States der rpi2 Adapters zusätzlich die vmstat basierte CPU-Last - gem. untenstehenden Formel - hinzufügen (als enhancement)?

pi@raspberrypi:~ $ cat /proc/loadavg
0.26 0.38 0.37 4/836 7107
pi@raspberrypi:~ $ cat /proc/loadavg
0.50 0.43 0.38 3/837 7314
pi@raspberrypi:~ $ cat /proc/loadavg
0.46 0.42 0.38 1/838 7394
pi@raspberrypi:~ $ uptime
14:55:24 up 31 days, 23:42, 1 user, load average: 0,38, 0,41, 0,38
pi@raspberrypi:~ $ uptime
14:55:31 up 31 days, 23:42, 1 user, load average: 0,35, 0,41, 0,37
pi@raspberrypi:~ $ uptime
14:55:32 up 31 days, 23:42, 1 user, load average: 0,40, 0,42, 0,38
pi@raspberrypi:~ $ uptime
14:55:34 up 31 days, 23:42, 1 user, load average: 0,40, 0,42, 0,38
pi@raspberrypi:~ $ uptime
14:55:35 up 31 days, 23:42, 1 user, load average: 0,40, 0,42, 0,38
pi@raspberrypi:~ $ vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd frei buff Cache si so bi bo in cs us sy id wa st
5 0 99732 1187104 62792 701320 0 0 2 4 4 2 8 4 87 0 0
pi@raspberrypi:~ $ vmstat 3 4
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd frei buff Cache si so bi bo in cs us sy id wa st
1 0 99732 1180048 62792 701484 0 0 2 4 4 2 8 4 87 0 0
1 0 99732 1180048 62792 701484 0 0 0 17 846 1285 4 4 92 0 0
1 0 99732 1180048 62792 701484 0 0 0 5 662 976 3 2 95 0 0
1 0 99732 1180048 62792 701484 0 0 0 44 1082 1760 5 4 91 0 0
pi@raspberrypi:~ $ echo "CPU Usage: "$[100-$(vmstat 1 2|tail -1|awk '{print $15}')]"%"
CPU Usage: 8%
pi@raspberrypi:~ $ echo "CPU Usage: "$[100-$(vmstat 1 2|tail -1|awk '{print $15}')]"%"
CPU Usage: 15%
pi@raspberrypi:~ $ echo "CPU Usage: "$[100-$(vmstat 1 2|tail -1|awk '{print $15}')]"%"
CPU Usage: 3%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant