green-kernel / powerletrics

Powermetrics for Linux
GNU Affero General Public License v3.0
5 stars 0 forks source link

powermetrics on 🐧 => powerletrics

PowerLetrics is an open-source framework designed to monitor and analyze power consumption metrics at the process level on Linux. Similar to how top displays memory or CPU time, PowerLetrics provides the "Energy Footprint" of each process in real-time. This project is still in the early stages of development. Please test it and submit any issues.

This project is heavily influenced by the powermetrics program on macOS.

Install and run

  1. You need to install bcc on your system which should include all the python bindings

https://github.com/iovisor/bcc/blob/master/INSTALL.md

  1. You can then install the program with pip install powerletrics. Please note that if you are using a venv you will need to create it with --system-site-packages as otherwise we don't have access to the bcc libs

  2. If you want to use RAPL and PSYS data you need to build the binaries. You will need gcc and make on your system. PowerLetrics will try and build everything on the first run for you.

  3. You can then run the program from the shell:

    powerletrics -i 1000 --show-all

CPU Energy

There is also the option to get the CPU energy from RAPL. You can activate this with --rapl.

If your computer support it you can also get the PSYS energy with --psys.

We don't enable this by default as we want to make the program runnable in a VM so people can test it easily and we want the default to work in all environments.

If you want to use this feature you will need to install gcc on your machine and build the tools with make

Screenshot

How it looks

Screenshot with server

How the HTML server looks

Parameters

-i / --sample-rate

-n / --sample-count

-o / --output-file

-r / --order

--show-all

--show-process-io

--show-process-netstats

--show-command-line

--format

--proc-memory

--flush

--server

--port

--host

--rapl

--psys

--rapl-sample-rate

Weights for energy impact

When calculating the energy impact each value is multiplied with a weight these are different for each machine. You can modify them in the config.conf or /etc/powerletrics file.

FAQ and Tips:

Terminal wraps because of long command line paramters

Execute this before starting the program

tput rmam

Why is the memory value different to the value I see in top

Because we use Total Virtual Memory instead of Resident Set Size

Why are there programs that do not show up in the list

Only programs that have run are listed as they are the only ones that have actually used something.

Why don't you use psutil

Because it does the same things (yes we check) and is slower as it adds more overhead. We still 😍 psutil though.