powerapi-ng / hwpc-sensor

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

Trailing `\n` in socket name breaks csv output #3

Closed PierreRustOrange closed 4 years ago

PierreRustOrange commented 4 years ago

When detecting the socket id, a trailing \n character is left in the package_id.

This breaks the csv output by breaking lines, for example, I get this in an rapl output csv file:

k8s@k8s-nuc:~/Projects/powerapi/hwpc-sensor$ tail -f /tmp/powerapi-sensor-reporting/rapl 
timestamp,sensor,target,socket,cpu,RAPL_ENERGY_PKG,time_enabled,time_running
1592814808213,pr-sensor,all,0
,7,19138871296,155813121,155813121
1592814809242,pr-sensor,all,0
,7,86548152320,1184425793,1184425793
1592814810280,pr-sensor,all,0
,7,67986522112,2222247455,2222247455

This can also be seen by adding some logs :

I: 20-06-22 09:13:11 hwinfo: found cpu  'cpu7' id : '7' for pkg '0
' 
PierreRustOrange commented 4 years ago

Fix available in PR #4