File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 2020
2121from __future__ import print_function
2222import argparse
23- from bcc import BPF , USDT
23+ from bcc import BPF , USDT , USDTException
2424import os
25+ import sys
2526from subprocess import call
2627from time import sleep , strftime
2728
@@ -62,7 +63,12 @@ def _find_targets(self):
6263 def _enable_probes (self ):
6364 self .usdts = []
6465 for pid in self .targets :
65- usdt = USDT (pid = pid )
66+ try :
67+ usdt = USDT (pid = pid )
68+ except USDTException :
69+ # avoid race condition on pid going away.
70+ print ("failed to instrument %d" % pid , file = sys .stderr )
71+ continue
6672 for event in self .events :
6773 try :
6874 usdt .enable_probe (event , "%s_%s" % (self .language , event ))
@@ -111,6 +117,9 @@ def get_counts(self, bpf):
111117 for event , category in self .events .items ():
112118 counts = bpf ["%s_%s_counts" % (self .language , event )]
113119 for pid , count in counts .items ():
120+ if pid .value not in result :
121+ print ("result was not found for %d" % pid .value , file = sys .stderr )
122+ continue
114123 result [pid .value ][category ] = count .value
115124 counts .clear ()
116125 return result
You can’t perform that action at this time.
0 commit comments