-
Notifications
You must be signed in to change notification settings - Fork 0
/
stap_all.stp
executable file
·196 lines (163 loc) · 6.66 KB
/
stap_all.stp
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
global parent_id = 0
global browser_id = 0
global store_page_fault //<1|name|pid|time|access_bool|freq> 1-write,0-read
global store_context_switches //<2|name|pid|time|prev_pid|next_pid|freq>
global store_process_or_thread //<3|name|pid|time|thread_id|pid>
global store_msg_aio_read //<4|name|pid|time|protocol|size>
global store_msg_aio_write //<5|name|pid|time|protocol|size>
global store_socket_create //<6|name|pid|time|freq>
global store_socket_close //<7|name|pid|time|freq>
global store_tcp_send //<8|name|pid|time|size>
global store_tcp_recv //<9|name|pid|time|size>
global store_udp_send //<10|name|pid|time|size>
global store_udp_recv //<11|name|pid|time|size>
global store_syscalls //<12|name|pid|time|name|freq>
global store_nw_recv //<13|name|pid|time|bytes_recv>
global store_nw_sent //<14|name|pid|time|bytes_sent>
probe vm.pagefault
{
if(pid() != parent_id && (ppid() == parent_id || ppid() == browser_id)) {
store_page_fault[execname(), pid(), gettimeofday_s(), write_access] <<< 1
}
}
probe scheduler.ctxswitch
{
if(pid() != parent_id && (ppid() == parent_id || ppid() == browser_id)) {
store_context_switches[execname(), pid(), gettimeofday_s(), prev_pid, next_pid] <<< 1
}
}
probe kprocess.create
{
if(pid() != parent_id && (ppid() == parent_id || ppid() == browser_id)) {
store_process_or_thread[execname(), pid(), gettimeofday_s(), new_tid, new_pid] <<< 1
}
}
probe socket.aio_read.return
{
if(pid() != parent_id && (ppid() == parent_id || ppid() == browser_id) && success) {
store_msg_aio_read[execname(), pid(), gettimeofday_s(), protocol] <<< size
}
}
probe socket.aio_write.return
{
if(pid() != parent_id && (ppid() == parent_id || ppid() == browser_id) && success) {
store_msg_aio_write[execname(), pid(), gettimeofday_s(), protocol] <<< size
}
}
probe socket.create.return
{
if(pid() != parent_id && (ppid() == parent_id || ppid() == browser_id)) {
store_socket_create[execname(), pid(), gettimeofday_s()] <<< 1
}
}
probe socket.close.return
{
if(pid() != parent_id && (ppid() == parent_id || ppid() == browser_id)) {
store_socket_close[execname(), pid(), gettimeofday_s()] <<< 1
}
}
probe tcp.sendmsg.return
{
if(pid() != parent_id && (ppid() == parent_id || ppid() == browser_id) && size>0) {
store_tcp_send[execname(), pid(), gettimeofday_s()] <<< size
}
}
probe tcp.recvmsg.return
{
if(pid() != parent_id && (ppid() == parent_id || ppid() == browser_id) && size>0) {
store_tcp_recv[execname(), pid(), gettimeofday_s()] <<< size
}
}
probe udp.sendmsg.return
{
if(pid() != parent_id && (ppid() == parent_id || ppid() == browser_id) && size>0) {
store_udp_send[execname(), pid(), gettimeofday_s()] <<< size
}
}
probe udp.recvmsg.return
{
if(pid() != parent_id && (ppid() == parent_id || ppid() == browser_id) && size>0) {
store_udp_recv[execname(), pid(), gettimeofday_s()] <<< size
}
}
probe syscall.*
{
if(pid() != parent_id && (ppid() == parent_id || ppid() == browser_id)) {
store_syscalls[execname(), pid(), gettimeofday_s(), name] <<< 1
}
}
probe socket.receive
{
if(!success) next
if(pid() != parent_id && (ppid() == parent_id || ppid() == browser_id && sock_fam_num2str(family) == "INET")) {
store_nw_recv[execname(), pid(), gettimeofday_s(), protocol] <<< size
}
}
probe socket.send
{
if(!success) next
if(pid() != parent_id && (ppid() == parent_id || ppid() == browser_id && sock_fam_num2str(family) == "INET")) {
store_nw_sent[execname(), pid(), gettimeofday_s(), protocol] <<< size
}
}
function print_all() {
foreach ([exec, pid, ctime, access] in store_page_fault-) {
printf("1|%s|%d|%lu|%d|%d|0\n", exec, pid, ctime, access, @sum(store_page_fault[exec, pid, ctime, access]))
}
delete store_page_fault
foreach ([exec, pid, ctime, prev_p, next_p] in store_context_switches-) {
printf("2|%s|%d|%lu|%d|%d|%d\n", exec, pid, ctime, prev_p, next_p, @sum(store_context_switches[exec, pid, ctime, prev_p, next_p]))
}
delete store_context_switches
foreach ([exec, pid, ctime, tid, pid] in store_process_or_thread-) {
printf("3|%s|%d|%lu|%d|%d|%d\n", exec, pid, ctime, tid, pid, @sum(store_process_or_thread[exec, pid, ctime, tid, pid]))
}
delete store_process_or_thread
foreach ([exec, pid, ctime, protocol] in store_msg_aio_read-) {
printf("4|%s|%d|%lu|%s|%d|0\n", exec, pid, ctime, sock_prot_num2str(protocol), @sum(store_msg_aio_read[exec, pid, ctime, protocol]))
}
delete store_msg_aio_read
foreach ([exec, pid, ctime, protocol] in store_msg_aio_write-) {
printf("5|%s|%d|%lu|%s|%d|0\n", exec, pid, ctime, sock_prot_num2str(protocol), @sum(store_msg_aio_write[exec, pid, ctime, protocol]))
}
delete store_msg_aio_write
foreach ([exec, pid, ctime] in store_socket_create-) {
printf("6|%s|%d|%lu|%d|0|0\n", exec, pid, ctime, @sum(store_socket_create[exec, pid, ctime]))
}
delete store_socket_create
foreach ([exec, pid, ctime] in store_socket_close-) {
printf("7|%s|%d|%lu|%d|0|0\n", exec, pid, ctime, @sum(store_socket_close[exec, pid, ctime]))
}
delete store_socket_close
foreach ([exec, pid, ctime] in store_tcp_send-) {
printf("8|%s|%d|%lu|%d|0|0\n", exec, pid, ctime, @sum(store_tcp_send[exec, pid, ctime]))
}
delete store_tcp_send
foreach ([exec, pid, ctime] in store_tcp_recv-) {
printf("9|%s|%d|%lu|%d|0|0\n", exec, pid, ctime, @sum(store_tcp_recv[exec, pid, ctime]))
}
delete store_tcp_recv
foreach ([exec, pid, ctime] in store_udp_send-) {
printf("10|%s|%d|%lu|%d|0|0\n", exec, pid, ctime, @sum(store_udp_send[exec, pid, ctime]))
}
delete store_udp_send
foreach ([exec, pid, ctime] in store_udp_recv-) {
printf("11|%s|%d|%lu|%d|0|0\n", exec, pid, ctime, @sum(store_udp_recv[exec, pid, ctime]))
}
delete store_udp_recv
foreach ([exec, pid, ctime, name] in store_syscalls-) {
printf("12|%s|%d|%lu|%s|%d|0\n", exec, pid, ctime, name, @sum(store_syscalls[exec, pid, ctime, name]))
}
delete store_syscalls
foreach ([exec, pid, ctime, prot] in store_nw_recv) {
printf("13|%s|%d|%lu|%d|0|0\n", exec, pid, ctime, @sum(store_nw_recv[exec, pid, ctime, prot]))
}
delete store_nw_recv
foreach ([exec, pid, ctime, prot] in store_nw_sent) {
printf("14|%s|%d|%lu|%d|0|0\n", exec, pid, ctime, @sum(store_nw_sent[exec, pid, ctime, prot]))
}
delete store_nw_sent
}
probe timer.s(1) {
print_all()
}