From c68df4bc3d1e2efef8fdffaae90b0f1554aab37d Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 5 Aug 2019 19:16:20 +0300 Subject: [PATCH] Expose `process_cpu_seconds_system_total` and `process_cpu_seconds_user_total` in process metrics --- process_metrics_linux.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/process_metrics_linux.go b/process_metrics_linux.go index 3f4744a..4442992 100644 --- a/process_metrics_linux.go +++ b/process_metrics_linux.go @@ -67,7 +67,11 @@ func writeProcessMetrics(w io.Writer) { // It is expensive obtaining `process_open_fds` when big number of file descriptors is opened, // don't do it here. - fmt.Fprintf(w, "process_cpu_seconds_total %g\n", float64(p.Utime+p.Stime)/userHZ) + utime := float64(p.Utime) / userHZ + stime := float64(p.Stime) / userHZ + fmt.Fprintf(w, "process_cpu_seconds_system_total %g\n", stime) + fmt.Fprintf(w, "process_cpu_seconds_total %g\n", utime+stime) + fmt.Fprintf(w, "process_cpu_seconds_user_total %g\n", utime) fmt.Fprintf(w, "process_major_pagefaults_total %d\n", p.Majflt) fmt.Fprintf(w, "process_minor_pagefaults_total %d\n", p.Minflt) fmt.Fprintf(w, "process_num_threads %d\n", p.NumThreads)