| 1 |
#! /usr/bin/env stap |
| 2 |
|
| 3 |
############################################################ |
| 4 |
# Dropwatch.stp |
| 5 |
# Author: Neil Horman <[email protected]> |
| 6 |
# An example script to mimic the behavior of the dropwatch utility |
| 7 |
# http://fedorahosted.org/dropwatch |
| 8 |
############################################################ |
| 9 |
|
| 10 |
# Array to hold the list of drop points we find |
| 11 |
global locations |
| 12 |
|
| 13 |
# Note when we turn the monitor on and off |
| 14 |
probe begin { printf("Monitoring for dropped packets\n") } |
| 15 |
probe end { printf("Stopping dropped packet monitor\n") } |
| 16 |
|
| 17 |
# increment a drop counter for every location we drop at |
| 18 |
probe kernel.trace("kfree_skb") { |
| 19 |
reason = @choose_defined($reason,0); |
| 20 |
locations[$location,reason] <<< 1 |
| 21 |
} |
| 22 |
|
| 23 |
# Every 5 seconds report our drop locations |
| 24 |
probe timer.sec(5) |
| 25 |
{ |
| 26 |
printf("\n%s\n", ctime(gettimeofday_s())) |
| 27 |
foreach ([l,r] in locations-) { |
| 28 |
printf("%d packets dropped at %s for reason: %d\n", |
| 29 |
@count(locations[l,r]), symdata(l), r) |
| 30 |
} |
| 31 |
delete locations |
| 32 |
} |