summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.examples/general/grapher.stp
blob: 9079cb40f0833a1421378fb78f736bce6416c45d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#! /usr/bin/stap

probe begin
{
printf ("%%DataSet:cpu 100 00ff00 bar\n");
printf ("%%DataSet:kbd 75 ff0000 discreet\n");
printf ("%%DataSet:pty 50 0000ff discreet\n");
printf ("cpu %%Title:CPU utilization\n");
printf ("cpu %%XAxisTitle:Time\n");
printf ("cpu %%YAxisTitle:Percent\n");

}

# CPU utilization
probe begin { qnames["cpu"] ++; qsq_start ("cpu") }
probe scheduler.cpu_on { if (!idle) {qs_wait ("cpu") qs_run ("cpu") }}
probe scheduler.cpu_off { if (!idle) qs_done ("cpu") }

global qnames

function qsq_util_reset(q) {
  u=qsq_utilization (q, 100)
  qsq_start (q)
  return u
}

probe timer.ms(100) {  # collect utilization percentages frequently
  foreach (q in qnames)
    printf("cpu %d %d\n", gettimeofday_ms(), qsq_util_reset(q))
}

probe kernel.function("kbd_event") {
 if ($event_type == 1 && $value)
   printf("kbd %d %d\n", gettimeofday_ms(), $event_code)
}

probe kernel.function("pty_write") {
 if (count > 0)
  printf("pty %d %.5s\n", gettimeofday_ms(), buf)
}