再次执行stap
stap /usr/share/systemtap/examples/io/inodewatch.stp 253 1 4210339 ERROR: module version mismatch (#1 SMP Tue Sep 25 14:32:52 CDT 2018 vs #1 SMP Wed Sep 26 15:12:11 UTC 2018), release 3.10.0-862.14.4.el7.x86_64 WARNING: /usr/bin/staprun exited with status: 1 添加 -v查看详细报错 stap -v /usr/share/systemtap/examples/io/inodewatch.stp 253 1 4210339 Pass 1: parsed user script and 471 library scripts using 240276virt/41896res/3368shr/38600data kb, in 300usr/20sys/320real ms. Pass 2: analyzed script: 2 probes, 12 functions, 8 embeds, 0 globals using 399436virt/196284res/4744shr/197760data kb, in 1540usr/560sys/2106real ms. Pass 3: using cached /root/.systemtap/cache/f5/stap_f5c0cd780e8a2cac973c9e3ee69fba0c_7030.c Pass 4: using cached /root/.systemtap/cache/f5/stap_f5c0cd780e8a2cac973c9e3ee69fba0c_7030.ko Pass 5: starting run. ERROR: module version mismatch (#1 SMP Tue Sep 25 14:32:52 CDT 2018 vs #1 SMP Wed Sep 26 15:12:11 UTC 2018), release 3.10.0-862.14.4.el7.x86_64 WARNING: /usr/bin/staprun exited with status: 1 Pass 5: run completed in 0usr/10sys/38real ms. Pass 5: run failed. [man error::pass5]修改
vim /usr/src/kernels/3.10.0-862.14.4.el7.x86_64/include/generated/compile.h #define UTS_VERSION "#1 SMP Tue Sep 25 14:32:52 CDT 2018" 改为 #define UTS_VERSION "#1 SMP Wed Sep 26 15:12:11 UTC 2018" rm -rf /root/.systemtap/cache/f5/stap_f5c0cd780e8a2cac973c9e3ee69fba0c_7030*参考SystemTap - 安装 https://www.linuxidc.com/Linux/2019-03/157818.htm
再次执行
stap /usr/share/systemtap/examples/io/inodewatch.stp 253 1 4210339
iostat(4671) vfs_write 0xfd00001/4210339 iostat(4671) vfs_write 0xfd00001/4210339 iostat(4671) vfs_write 0xfd00001/4210339 iostat(4671) vfs_write 0xfd00001/4210339 iostat(4671) vfs_write 0xfd00001/4210339 iostat(4671) vfs_write 0xfd00001/4210339 iostat(4671) vfs_write 0xfd00001/4210339 iostat(4671) vfs_write 0xfd00001/4210339 iostat(4671) vfs_write 0xfd00001/4210339 iostat(4671) vfs_write 0xfd00001/4210339 iostat(4677) vfs_write 0xfd00001/4210339 iostat(4677) vfs_write 0xfd00001/4210339 iostat(4677) vfs_write 0xfd00001/4210339 iostat(4677) vfs_write 0xfd00001/4210339 iostat(4677) vfs_write 0xfd00001/4210339 iostat(4677) vfs_write 0xfd00001/4210339 iostat(4677) vfs_write 0xfd00001/4210339 iostat(4677) vfs_write 0xfd00001/4210339 iostat(4677) vfs_write 0xfd00001/4210339 iostat(4677) vfs_write 0xfd00001/4210339 iostat(4683) vfs_write 0xfd00001/4210339 ............可见已经得到了写/tmp/iostat_date +%F 文件的进程号,但进程号一直在打印出来,因为后台进程iostat -dx -m 的在while循环中的,每隔sleep 2s 后就会执行一次iostat 产生新的pid。
***那要怎样才能让iostat -dx -m 停止写/tmp/iostat_date +%F 文件了?除了重启大法好 $_$***
rm -rf 也不能终止后台的while iostat进程写文件,删除了文件后,while循环又会生成新的文件
rm -rf /tmp/iostat_2019-03-1* stat /tmp/iostat_2019-03-1* File: ‘/tmp/iostat_2019-03-13’ Size: 146700 Blocks: 512 IO Block: 4096 regular file Device: fd01h/64769d Inode: 4210339 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2019-03-14 16:07:26.211888899 +0800 Modify: 2019-03-14 16:18:17.854019793 +0800 Change: 2019-03-14 16:18:17.854019793 +0800正确做法
cat>/tmp/iostat.sh<<EOF while [ 1 ];do echo -n \`date +%T\` >>/tmp/iostat_\`date +%F\` 2>& 1 && iostat -dx -m 1 1 >>/tmp/iostat_\`date +%F\` 2>& 1; sleep 2; done & EOF at now + 1 minute today bash /tmp/iostat.sh #这样就能方便的获取到进程号pid了 ps -ef | grep iostat root 8593 1 0 16:16 pts/2 00:00:00 bash /tmp/iostat.shLinux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx