1
- #!/usr/bin/env python2
1
+ #!/usr/bin/env python3
2
2
#
3
3
# Copyright 2019 Delphix. All rights reserved.
4
4
#
19
19
# the performance data collector.
20
20
#
21
21
22
- from __future__ import print_function
23
-
24
22
from bcc import BPF
25
23
import getopt
26
24
from glob import glob
@@ -423,7 +421,7 @@ class Args:
423
421
line + "'" )
424
422
probe_type = probe_spec [0 ]
425
423
if probe_type == "kprobe" :
426
- if BPF .get_kprobe_functions (probe_spec [1 ]):
424
+ if BPF .get_kprobe_functions (probe_spec [1 ]. encode ( 'utf-8' ) ):
427
425
b .attach_kprobe (event = probe_spec [1 ], fn_name = probe_spec [2 ])
428
426
probes .add ("p_" + probe_spec [1 ] + "_bcc_" + str (os .getpid ()))
429
427
else :
@@ -481,20 +479,20 @@ class Args:
481
479
# output
482
480
if monitor :
483
481
# TODO can we do this without shelling out to 'date'?
484
- ds__start = long (os .popen ("date +%s%N" ).readlines ()[0 ])
482
+ ds__start = int (os .popen ("date +%s%N" ).readlines ()[0 ])
485
483
while (1 ):
486
484
try :
487
485
sleep (duration )
488
486
except KeyboardInterrupt :
489
487
break
490
488
try :
491
- ds__end = long (os .popen ("date +%s%N" ).readlines ()[0 ])
489
+ ds__end = int (os .popen ("date +%s%N" ).readlines ()[0 ])
492
490
ds__delta = ds__end - ds__start
493
491
if not accum :
494
492
ds__start = ds__end
495
493
if args .summary and args .normalize :
496
- helper1 .normalize ("ops" , ds__delta / 1000000000 )
497
- helper3 .normalize ("opst" , ds__delta / 1000000000 )
494
+ helper1 .normalize ("ops" , ds__delta // 1000000000 )
495
+ helper3 .normalize ("opst" , ds__delta // 1000000000 )
498
496
clear_data = not accum
499
497
if args .latsize_hist :
500
498
helper2 .printall (clear_data )
@@ -503,26 +501,26 @@ class Args:
503
501
if args .summary and args .total :
504
502
helper3 .printall (clear_data )
505
503
print ("%-16s\n " % strftime ("%D - %H:%M:%S %Z" ))
506
- except e :
504
+ except Exception as e :
507
505
die (e )
508
506
else :
509
- ds__start = long (os .popen ("date +%s%N" ).readlines ()[0 ])
507
+ ds__start = int (os .popen ("date +%s%N" ).readlines ()[0 ])
510
508
try :
511
509
sleep (duration )
512
510
except KeyboardInterrupt :
513
511
pass
514
512
try :
515
- ds__delta = long (os .popen ("date +%s%N" ).readlines ()[0 ]) - ds__start
513
+ ds__delta = int (os .popen ("date +%s%N" ).readlines ()[0 ]) - ds__start
516
514
if args .summary and args .normalize :
517
- helper1 .normalize ("ops" , ds__delta / 1000000000 )
518
- helper3 .normalize ("opst" , ds__delta / 1000000000 )
515
+ helper1 .normalize ("ops" , ds__delta // 1000000000 )
516
+ helper3 .normalize ("opst" , ds__delta // 1000000000 )
519
517
if args .latsize_hist :
520
518
helper2 .printall ()
521
519
if args .lat_hist or args .size_hist or args .summary :
522
520
helper1 .printall ()
523
521
if args .summary and args .total :
524
522
helper3 .printall ()
525
- except e :
523
+ except Exception as e :
526
524
die (e )
527
525
528
526
#
0 commit comments