From c1e4d622583dfee0e510cd3854103a535b615ff7 Mon Sep 17 00:00:00 2001 From: Aaron Merey Date: Tue, 3 Jul 2018 12:59:28 -0400 Subject: [PATCH] stap-exporter: use prometheus tapset macros and alias in example scripts. --- stap-exporter/scripts/cpu_throttle.stp | 2 +- stap-exporter/scripts/example1.stp | 9 ++++----- stap-exporter/scripts/example2.stp | 9 ++++----- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/stap-exporter/scripts/cpu_throttle.stp b/stap-exporter/scripts/cpu_throttle.stp index e27fb00db..4f4371da0 100644 --- a/stap-exporter/scripts/cpu_throttle.stp +++ b/stap-exporter/scripts/cpu_throttle.stp @@ -32,7 +32,7 @@ probe kprobe.function("therm_throt_process") { } } -probe procfs("cpu_throttle.stp").read.maxsize(0x10000) { +probe prometheus { now = gettimeofday_ns() $value .= "# HELP cpu_throttle_time accumulated time process is performance limited in ms.\n" $value .= "# TYPE cpu_throttle_time counter\n" diff --git a/stap-exporter/scripts/example1.stp b/stap-exporter/scripts/example1.stp index 306b4c0ec..edd56b641 100644 --- a/stap-exporter/scripts/example1.stp +++ b/stap-exporter/scripts/example1.stp @@ -1,10 +1,9 @@ global arr -probe procfs("example1.stp").read.maxsize(0x10000) { - foreach (k = [tid,cpu] in arr) - $value .= "count [tid=".sprint(tid).",cpu=".sprint(cpu)."] ".sprint(k)."\n" -} - probe kprobe.function("sys_read") { arr[tid(), cpu()]++ } + +probe prometheus { + @prometheus_dump_array2(arr, "count", "tid", "cpu") +} diff --git a/stap-exporter/scripts/example2.stp b/stap-exporter/scripts/example2.stp index 46bb0aeeb..e51bab471 100644 --- a/stap-exporter/scripts/example2.stp +++ b/stap-exporter/scripts/example2.stp @@ -1,10 +1,9 @@ global arr -probe procfs("example2.stp").read.maxsize(0x10000) { - foreach (k = [tid,cpu] in arr) - $value .= "count [tid=".sprint(tid).",cpu=".sprint(cpu)."] ".sprint(k)."\n" +probe kprobe.function("sys_open") { + arr[cpu(), tid(), gid()]++ } -probe kprobe.function("sys_open") { - arr[tid(), cpu()]++ +probe prometheus { + @prometheus_dump_array3(arr, "count", "cpu", "tid", "gid") } -- 2.43.5