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

daemon storage #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

EmileCadorel
Copy link

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 :

  • libpthread

There is room for improvments:

  • Writing into a closed socket raise the signal SIGPIPE. I didn't find any way to avoid that, other than just install an handler that does nothing.

@sonarcloud
Copy link

sonarcloud bot commented Sep 5, 2023

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

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

Successfully merging this pull request may close these issues.

1 participant