blob: 26d35aca4f4198c6f962a3603fa3fa23d1ac2616 (
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
|
#! /usr/bin/stap
probe begin
{
printf ("%%Title:CPU utilization\n");
printf ("%%XAxisTitle:Time\n");
printf ("%%YAxisTitle:Percent\n");
printf ("%%DataSet:cpu 100 00ff00 bar\n");
printf ("%%DataSet:kbd 75 ff0000 discreet\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)
}
|