rewrite of biosnoop to use BPF_PERF_OUTPUT
Hi
I have made a start at re-writing the biosnoop tool to use the bpf_perf_output, it is located here. https://github.com/mcaleavya/bcc-scripts/blob/master/biosnoop.py I have still to run pep8 against it and having a slight moment figuring out the timestamp part. The other difference is that when it does not find a command the original prints -1 for the sector, setting this to -1 doesn't print out correctly so it sets the value to zero please see below.
TIME(s) COMM PID DISK T SECTOR BYTES LAT(ms) 0.000000000 dd 24852 sda W 26236512 8192 3.00 0.000000000 dd 24852 sda W 26236528 8192 1.00 0.000000000 dd 24852 sda W 26236544 8192 1.00 0.000000000 dd 24852 sda W 26236560 8192 1.00 0.000000000 dd 24852 sda W 26236576 8192 1.00 0.000000000 dd 24852 sda W 26236592 8192 1.00 0.000000000 dd 24852 sda W 26236608 8192 1.00 0.000000000 dd 24852 sda W 26236624 8192 1.00 0.000000000 dd 24852 sda W 10991744 8192 184.00 0.000000000 dd 24852 sda W 10991760 8192 10.00 0.000000000 ? 0 R 0 8 2.00 0.000000000 ? 0 R 0 8 4.00 0.000000000 ? 0 R 0 8 4.00 0.000000000 jbd2/dm-0-8 190 sda W 13532576 24576 3.00 0.000000000 kworker/0:2 23934 sda W 13532624 4096 2.00 0.000000000 bash 24017 sda R 1168552 131072 839.00 0.000000000 bash 24017 sda R 1168808 110592 16.00 0.000000000 ? 0 R 0 8 4.00 0.000000000 rs:main Q:Reg 546 sda R 25674496 4096 824.00 0.000000000 rs:main Q:Reg 546 sda R 25674504 4096 826.00 0.000000000 rs:main Q:Reg 546 sda R 25674536 4096 3.00
this was with a dd if=/dev/zero of=./a bs=8192 oflag=direct count=10 followed by a echo 1 > drop_caches
original TIME(s) COMM PID DISK T SECTOR BYTES LAT(ms) 0.000064000 ? 0 R -1 8 0.41 0.736979000 bash 24856 sda R 17589504 16384 74.91 0.739399000 dd 24856 sda R 17589536 45056 0.98 0.742619000 dd 24856 sda W 26236640 8192 0.17 0.743276000 dd 24856 sda W 26236656 8192 0.15 0.743838000 dd 24856 sda W 26236672 8192 0.13 0.744364000 dd 24856 sda W 26236688 8192 0.13 0.744942000 dd 24856 sda W 26236704 8192 0.16 0.745535000 dd 24856 sda W 26236720 8192 0.13 0.746152000 dd 24856 sda W 26236736 8192 0.15 0.746700000 dd 24856 sda W 26236752 8192 0.13 0.764079000 dd 24856 sda W 10991616 8192 16.94 0.765439000 dd 24856 sda W 10991632 8192 0.80 0.781495000 dd 24856 sda R 9156168 4096 15.46 0.795653000 dd 24856 sda R 13705440 16384 13.14 0.805274000 dd 24856 sda R 13706432 4096 8.85 2.003256000 ? 0 R -1 8 0.41 4.006548000 ? 0 R -1 8 0.29 5.110285000 rs:main 546 sda R 614512 Q:Reg 0.19 5.111323000 rs:main 546 sda R 601768 Q:Reg 0.19
Any thoughts on the -1, I could parse for ? for the comm in the python and print -1..
Thanks Al
I have updated this (pep8) etc , however could use a steer on what to do with the timestamps.
I have this working now closing to create pull req