Open jspaleta opened 4 years ago
@jspaleta I've got a feeling that we could try and refactor this plugin to use Gopsutil since the library already does the heavy lifting of generating percentages https://godoc.org/github.com/shirou/gopsutil/cpu#Percent. I actually think it might be ideal to do this since we could just use this one library and generate quite a bit more metric data
/proc/stat provides raw timing information concerning cpu state, that take some processing to be useful.
system-profile-linux could be updated to operate in a way to provide cpu utilization metrics by taking a two separate snapshots of /proc/stat a set interval a part and intepreting the cpu state information increases as a percentage of the available interval... once the clock_tick freqency of the system is known from sysconf lookup (see other issue on that)
Pseudo-math for calculating percentage of time in system state for interval t_0 to t_1
(cpu.system_1 - cpu.system_0) / (clock_tick_frequency * (t_1 - t_0))
clock_tick_frequency is commonly 100 Hz, but this cannot be assumed, must check with sysconf on the value being use by the running kernel.
default interval
t_1 - t_0
could 1 secondThis calculation could be done for all the cpu timing metrics currently being reported to extend the profile information provide.