-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.py
More file actions
35 lines (32 loc) · 906 Bytes
/
test.py
File metadata and controls
35 lines (32 loc) · 906 Bytes
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
import dtrace
import time
d = dtrace.DtraceConsumer()
d.strcompile("""
syscall:::entry
{
self->syscall_entry_ts[probefunc] = vtimestamp;
}
syscall:::return
/self->syscall_entry_ts[probefunc]/
{
@time[probefunc] = lquantize((vtimestamp - self->syscall_entry_ts[probefunc] ) / 1000, 0, 512, 1);
self->syscall_entry_ts[probefunc] = 0;
}
""")
def drop_handler(cpuid, drop_count, total_drops, message):
print "WARNING: detected %d drops on cpu %d (total drops so far: %d)" % (drop_count, cpuid, total_drops)
d.set_drop_handler(drop_handler)
d.go()
def construct_aggregation(dtrace_handle):
aggregation = {}
def construction_callback(var_id, key, val):
aggregation[key[0]] = val
dtrace_handle.aggwalk(construction_callback)
return aggregation
count = 0
while True:
print "-------%d-------" % count
count += 1
print construct_aggregation(d)
time.sleep(0.1)
d.stop()