-
Notifications
You must be signed in to change notification settings - Fork 0
/
sotop.d
executable file
·44 lines (39 loc) · 1.14 KB
/
sotop.d
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
#!/usr/sbin/dtrace -s
#pragma D option quiet
#pragma D option destructive
syscall::read*:entry, syscall::recv*:entry
/fds[arg0].fi_fs == "sockfs" || fds[arg0].fi_name == "<socket>"/
{
self->read = 1;
}
syscall::read*:return, syscall::recv*:return
/self->read/
{
this->size = (int)arg0 > 0 ? arg0 : 0;
@rc[execname,pid] = count();
@rb[execname, pid] = sum(this->size);
self->read = 0;
}
syscall::write*:entry, syscall::send*:entry
/fds[arg0].fi_fs == "sockfs" || fds[arg0].fi_name == "<socket>"/
{
/* this under-counts writev() size (assumes iov_len is 1) */
this->size = arg2;
@wc[execname, pid] = count();
@wb[execname, pid] = sum(this->size);
}
profile:::profile-100hz
{
/* will sum %CPUs on multi-core systems */
@cpu[execname, pid] = count();
}
profile:::tick-1sec
{
normalize(@rb,1024); normalize(@wb, 1024);
system("clear");
printf(" %-16s %-8s %8s %8s %10s %10s %8s\n", "PROCESS", "PID", "READS", "WRIITES", "READ_KB", "WRITE_KB", "CPU");
setopt("aggsortpos", "4"); setopt("aggsortrev", "4");
printa(" %-16s %-8d %@8d %@8d %@10d %@10d %@8d\n",
@rc, @wc, @rb, @wb, @cpu);
trunc(@rc); trunc(@wc); trunc(@rb); trunc(@wb); trunc(@cpu);
}