Open pavelmash opened 3 years ago
I create a gist what reads btime from stats
C is not my main language, I not sure where to put a readbtime
function in the libprom sources.
it seems to read /proc/{pid}/stats
which according to https://man7.org/linux/man-pages/man5/proc.5.html needs to be handled roughly as you described.
it is read in https://github.com/digitalocean/prometheus-client-c/blob/master/prom/src/prom_process_stat.c#L164 with sscanf.
process_cpu_total_seconds
already has some conversion code in https://github.com/digitalocean/prometheus-client-c/blob/master/prom/src/prom_collector.c#L225.
and i guess we could patch it in https://github.com/digitalocean/prometheus-client-c/blob/master/prom/src/prom_collector.c#L249
The solution is to read
btime
from/proc/stat
(once) and calculate process_start_time_seconds as