cockpit-project / cockpit

Cockpit is a web-based graphical interface for servers.
http://www.cockpit-project.org/
GNU Lesser General Public License v2.1
10.9k stars 1.09k forks source link

Power Usage/Consumption #18504

Open FallingSnow opened 1 year ago

FallingSnow commented 1 year ago

Page: Overview/Metrics

Add power usage metric to the overview page, in the usage box. Show a similar metric to the power usage in s-tui.

Linux power can be viewed on my intel system at

$ sudo cat /sys/class/powercap/intel-rapl:0/energy_uj
14069299309
$ sudo cat /sys/class/powercap/intel-rapl:0/device/intel-rapl:0/name
package-0

I'm not sure but I think you can the watts by taking 2 readings, then applying this formula:

micro watts = (messurement_2 - messurement_1) / time_between_readings_in_seconds

Again this is just a guess of how it's done.

jelly commented 1 year ago

Thanks for the feature request, from my understanding intel-rapl is a power sensor for the CPU itself so not the whole system so this would be limited to specific intel CPU's. From some research I've found out that there is no generic API for power consumption of a system.

Apart from that issue, I wonder what the use case or benefit is for Cockpit to display the system power usage?

garrett commented 1 year ago

Firstly: I do think power usage is a good thing to check overall, even for servers in datacenters.

However, the metrics page itself would spike the power usage, so it would be tricky, for sure. Plus, we'd want to support ARM and AMD too.

If we had a card for power, then we would ideally want to list the most power-hungry processes (in a cgroups v2 way). And also, the design of that page is meant for 4 cards across the top. It wouldn't work with 5 as-is; we'd have to figure that out too.

FallingSnow commented 1 year ago

Thanks for the feature request, from my understanding intel-rapl is a power sensor for the CPU itself so not the whole system so this would be limited to specific intel CPU's. From some research I've found out that there is no generic API for power consumption of a system.

Apart from that issue, I wonder what the use case or benefit is for Cockpit to display the system power usage?

Ah yes, you are right. On my laptop s-tui is able to report psys which I believe is total system power. I think it does this using cat /sys/class/power_supply/BAT0/current_now and cat /sys/class/power_supply/BAT0/voltage_now. But this requires a battery.

I use power usage to determine if the system is running efficiently. When you switch between tuned profiles you can extremely clearly see differences in power usage, even when idle. At idle a 13600k on the virtual-host profile uses ~3 watts, on realtime-virtual-host it idles at 33 watts (11x more power).

FallingSnow commented 1 year ago

I don't currently have an AMD chip to test but I have gotten power usage in the past using https://git.exozy.me/a/zenpower3. That module exposes volts and amps used by the CPU. Not sure about ARM.

jelly commented 1 year ago

Thanks for the feature request, from my understanding intel-rapl is a power sensor for the CPU itself so not the whole system so this would be limited to specific intel CPU's. From some research I've found out that there is no generic API for power consumption of a system. Apart from that issue, I wonder what the use case or benefit is for Cockpit to display the system power usage?

Ah yes, you are right. On my laptop s-tui is able to report psys which I believe is total system power. I think it does this using cat /sys/class/power_supply/BAT0/current_now and cat /sys/class/power_supply/BAT0/voltage_now. But this requires a battery.

For use cases with a battery, one could use upower (afaik) to determine how much power is used. As Cockpit is mostly for servers that won't work as most servers don't have upower nor does it report relevant information

I use power usage to determine if the system is running efficiently. When you switch between tuned profiles you can extremely clearly see differences in power usage, even when idle. At idle a 13600k on the virtual-host profile uses ~3 watts, on realtime-virtual-host it idles at 33 watts (11x more power).

Aha! Honestly for measuring power usage I would buy a wall plug for monitoring the whole system.

JEMcats commented 1 month ago

I would like to see my power consumption in cockpit too, has anyone tried writing their own page for this?