Expose process_cpu_seconds_system_total and process_cpu_seconds_user_total in process metrics

This commit is contained in:
Aliaksandr Valialkin 2019-08-05 19:16:20 +03:00
parent 5a9cdd0bef
commit c68df4bc3d

View File

@ -67,7 +67,11 @@ func writeProcessMetrics(w io.Writer) {
// It is expensive obtaining `process_open_fds` when big number of file descriptors is opened, // It is expensive obtaining `process_open_fds` when big number of file descriptors is opened,
// don't do it here. // 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_major_pagefaults_total %d\n", p.Majflt)
fmt.Fprintf(w, "process_minor_pagefaults_total %d\n", p.Minflt) fmt.Fprintf(w, "process_minor_pagefaults_total %d\n", p.Minflt)
fmt.Fprintf(w, "process_num_threads %d\n", p.NumThreads) fmt.Fprintf(w, "process_num_threads %d\n", p.NumThreads)