Use dentry_path() to create full path to inode object
[pohmelfs.git] / tools / perf / scripts / python / net_dropmonitor.py
bloba4ffc95000238cde8f086970f9d23d042ba99c59
1 # Monitor the system for dropped packets and proudce a report of drop locations and counts
3 import os
4 import sys
6 sys.path.append(os.environ['PERF_EXEC_PATH'] + \
7 '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
9 from perf_trace_context import *
10 from Core import *
11 from Util import *
13 drop_log = {}
14 kallsyms = []
16 def get_kallsyms_table():
17 global kallsyms
18 try:
19 f = open("/proc/kallsyms", "r")
20 linecount = 0
21 for line in f:
22 linecount = linecount+1
23 f.seek(0)
24 except:
25 return
28 j = 0
29 for line in f:
30 loc = int(line.split()[0], 16)
31 name = line.split()[2]
32 j = j +1
33 if ((j % 100) == 0):
34 print "\r" + str(j) + "/" + str(linecount),
35 kallsyms.append({ 'loc': loc, 'name' : name})
37 print "\r" + str(j) + "/" + str(linecount)
38 kallsyms.sort()
39 return
41 def get_sym(sloc):
42 loc = int(sloc)
43 for i in kallsyms:
44 if (i['loc'] >= loc):
45 return (i['name'], i['loc']-loc)
46 return (None, 0)
48 def print_drop_table():
49 print "%25s %25s %25s" % ("LOCATION", "OFFSET", "COUNT")
50 for i in drop_log.keys():
51 (sym, off) = get_sym(i)
52 if sym == None:
53 sym = i
54 print "%25s %25s %25s" % (sym, off, drop_log[i])
57 def trace_begin():
58 print "Starting trace (Ctrl-C to dump results)"
60 def trace_end():
61 print "Gathering kallsyms data"
62 get_kallsyms_table()
63 print_drop_table()
65 # called from perf, when it finds a correspoinding event
66 def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm,
67 skbaddr, protocol, location):
68 slocation = str(location)
69 try:
70 drop_log[slocation] = drop_log[slocation] + 1
71 except:
72 drop_log[slocation] = 1