copied from http://sourceware.org/ml/systemtap/2006-q4/msg00022.html. just in case this machine goes down then i can look here.
also liked this blog.. will be reading content in future when have time
http://akudump.blogspot.com/
global ifxmit_p, ifrecv_p, ifxmit_b, ifrecv_b, ifdevs, ifpid, execname, user
probe netdev.transmit
{
execname[pid()] = execname()
user[pid()] = uid()
ifdevs[pid(), dev_name] = dev_name
ifxmit_p[pid(), dev_name] ++
ifxmit_b[pid(), dev_name] += length
ifpid[pid(), dev_name] ++
}
probe netdev.receive
{
execname[pid()] = execname()
user[pid()] = uid()
ifdevs[pid(), dev_name] = dev_name
ifrecv_p[pid(), dev_name] ++
ifrecv_b[pid(), dev_name] += length
ifpid[pid(), dev_name] ++
}
function print_activity()
{
printf("%5s %5s %-7s %7s %7s %7s %7s %-15s\n",
"PID", "UID", "DEV", "XMIT_PK", "RECV_PK", "XMIT_KB",
"RECV_KB", "COMMAND")
foreach ([pid,dev] in ifpid-) {
printf("%5d %5d %-7s %7d %7d %7d %7d %-15s\n",
pid, user[pid], dev,
ifxmit_p[pid, dev], ifrecv_p[pid, dev], ifxmit_b[pid, dev]/1024,
ifrecv_b[pid, dev]/1024,
execname[pid])
}
print("\n")
delete execname
delete user
delete ifdevs
delete ifxmit_p
delete ifrecv_p
delete ifxmit_b
delete ifrecv_b
delete ifpid
}
probe timer.ms(5000)
{
print_activity()
}
No comments:
Post a Comment