-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathsyscall_by_zone.py
More file actions
executable file
·51 lines (33 loc) · 925 Bytes
/
Copy pathsyscall_by_zone.py
File metadata and controls
executable file
·51 lines (33 loc) · 925 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
"""
Use the Python DTrace consumer and count syscalls by zone.
Created on Oct 10, 2011
@author: tmetsch
"""
from __future__ import print_function
import time
from ctypes import cast, c_char_p, c_int
from dtrace_ctypes import consumer
SCRIPT = 'syscall:::entry { @num[zonename] = count(); }'
def walk(data, _):
"""
Nice formatted aggregate walker.
"""
tmp = data.contents.dtada_data
name = cast(tmp + 16, c_char_p).value
count = consumer.deref(tmp + 272, c_int).value
print('Zone "{0:s}" made {1:d} syscalls.'.format(name.decode(), count))
return 0
def main():
"""
Run DTrace...
"""
dtrace = consumer.DTraceConsumerThread(SCRIPT, walk_func=walk)
dtrace.start()
# we will stop the thread after some time...
time.sleep(5)
# stop and wait for join...
dtrace.stop()
dtrace.join()
if __name__ == '__main__':
main()