powerapi-ng / hwpc-sensor

Hardware Performance Counters monitoring agent for containers.
BSD 3-Clause "New" or "Revised" License
14 stars 16 forks source link

daemon storage #6

Open EmileCadorel opened 3 years ago

EmileCadorel commented 3 years ago

Hi,

I added a daemon storage. The idea is to create a server that accepts multiple socket connections. The problem I had with the socket storage was that I needed to launch the formula before the sensor, and there was synchronization issues.

In the code I propose, a thread is running to accept socket connection, and the main thread send the reports to the opened connection. That way, a client can connect and disconnect at any time, while the sensor runs as a daemon.

The storage is launched with the name "daemon", and the P_flag :

sudo ./hwpc-sensor -n test -r daemon -P 8002 -s rapl -o -e RAPL_ENERGY_PKG   

After, you just have to connect with a tcp client :

$ telnet localhost 8002
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
{ "timestamp" : "2021-04-26T09:49:51.808", "sensor" : "test", "target" : "all", "groups" : { "rapl" : { "0" : { "7" : { "RAPL_ENERGY_PKG" : 6633029632.0, "time_enabled" : 9002862900.0, "time_running" : 9002862900.0 } } } } }

Dependency :

There is room for improvments:

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information