blob: a830b1534b40035bf2fbbac365f77a4db8372e53 (
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
44
45
46
47
48
49
50
|
#! /usr/bin/env 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");
printf ("%%LineEnd:0\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%c", gettimeofday_ms(), qsq_util_reset(q), 0)
}
probe kernel.function("kbd_event") {
if ($event_type == 1 && $value)
printf("kbd %d %d\n0x%x%c", gettimeofday_ms(), $event_code, $event_code, 0)
}
probe kernel.function("pty_write") {
count = %(kernel_v>="2.6.31" %? $c %: $count %)
if (count > 0) {
printf("pty %d ", gettimeofday_ms())
str = $buf
for (i = 0; i < count; ++i) {
if (i > 1)
printf("\n")
c = kernel_char(str + i)
printf("%c", c)
}
printf("%c", 0)
}
}
|