uniapp开发app框架在提升开发效率中的独特优势与应用探索
835
2022-11-16
bcc-tools Linux运维中的要你命3000
目录
1.简介2.安装
2.1.CentOS7 安装2.2.Ubuntu20 安装
3.示例
3.1.execsnoop3.2.opensnoop
4.分享
1.简介
提到 bcc-tools 就不得不提 bpftrace,bpftrace 是基于 BPF 和 BCC 的开源系统跟踪工具。bpftrace 堪称 Linux 性能诊断的屠龙刀,但是不是谁都能用得好。而 bcc-tools 就是牛人写的 bpftrace 脚本,针对不同问题的一个工具包。
如果要详细了解 bpftrace 和性能诊断,可阅读《BPF之巅 洞悉Linux系统和应用性能》和《性能之巅 洞悉系统、企业和云计算》 云盘-见文章最后。
2.安装
2.1.CentOS7 安装
从 RHEL 8 开始,BPF 已放到官方源。
wget -O /etc/yum.repos.d/bpftools.repo --no-check-certificate yum -y install bpftraceyum -y install kernel-headersyum -y install
2.2.Ubuntu20 安装
Ubuntu 已将 BPF 工具放到官方源。
apt install -y bpftraceapt install
3.示例
随便举两个例子,以后有时间会把每个工具介绍一遍。
3.1.execsnoop
通过跟踪每次execve系统调用,打印每个新创建的进程。 我们可以使用这个工具,跟踪一个脚本到底在做什么。虽然阅读代码也能了解,但是不如直接看执行过程更直接。
比如 TDengine 的安装脚本 install.sh 到底做了啥:
grep 56686 56674 0 /usr/bin/grep -qwi debiangrep 56688 56674 0 /usr/bin/grep -qwi Kylingrep 56690 56674 0 /usr/bin/grep -qwi Redgrep 56692 56674 0 /usr/bin/grep -qwi centoshostname 56694 56674 0 /usr/bin/hostnametar 56695 56674 0 /usr/bin/tar -zxf taos.tar.gzgzip 56696 56695 0 /usr/bin/gzip -dsudo 56698 56674 0 /usr/bin/sudo rm -rf /usr/local/taosrm 56699 56698 0 /bin/rm -rf /usr/local/taossudo 56700 56674 0 /usr/bin/sudo mkdir -p /usr/local/taosmkdir 56701 56700 0 /bin/mkdir -p /usr/local/taossudo 56702 56674 0 /usr/bin/sudo mkdir -p /usr/local/taos/cfgmkdir 56703 56702 0 /bin/mkdir -p /usr/local/taos/cfgsudo 56704 56674 0 /usr/bin/sudo mkdir -p /usr/local/taos/binmkdir 56705 56704 0 /bin/mkdir -p /usr/local/taos/binsudo 56706 56674 0 /usr/bin/sudo mkdir -p /usr/local/taos/drivermkdir 56707 56706 0 /bin/mkdir -p /usr/local/taos/driversudo 56708 56674 0 /usr/bin/sudo mkdir -p /usr/local/taos/examplesmkdir 56709 56708 0 /bin/mkdir -p /usr/local/taos/examplessudo 56710 56674 0 /usr/bin/sudo mkdir -p /usr/local/taos/includemkdir 56712 56710 0 /bin/mkdir -p /usr/local/taos/includesudo 56713 56674 0 /usr/bin/sudo mkdir -p /usr/local/nginxdmkdir 56714 56713 0 /bin/mkdir -p /usr/local/nginxdsudo 56715 56674 0 /usr/bin/sudo mkdir -p /var/lib/taosmkdir 56716 56715 0 /bin/mkdir -p /var/lib/taossudo 56717 56674 0 /usr/bin/sudo ln -s /var/lib/taos /usr/local/taos/dataln 56718 56717 0 /bin/ln -s /var/lib/taos /usr/local/taos/datasudo 56719 56674 0 /usr/bin/sudo rm -rf /var/log/taosrm 56720 56719 0 /bin/rm -rf /var/log/taos.....cp 56800 56799 0 /bin/cp -rf /tmp/TDengine-enterprise-server-2.4.0.31/connector/ /usr/local/taos/sudo 56801 56674 0 /usr/bin/sudo cp -rf /tmp/TDengine-enterprise-server-2.4.0.31/examples/c /tmp/TDengine-enterprise-server-2.4.0.31/examples/C# /tmp/TDengine-enterprise-server-2.4.0.31/examples/go /tmp/TDengine-enterprise-server-2.4.0.31/examples/JDBC /tmp/TDengine-enterprise-server-2.4.0.31/examples/matlab /tmp/TDengine-enterprise-server-2.4.0.31/examples/nodejs /tmp/TDengine-enterprise-server-2.4.0.31/examples/python /tmp/TDengine-enterprise-server-2.4.0.31/examples/R /tmp/TDengine-enterprise-server-2.4.0.31/examples/taosbenchmark-json /usr/local/taos/examplescp 56802 56801 0 /bin/cp -rf /tmp/TDengine-enterprise-server-2.4.0.31/examples/c /tmp/TDengine-enterprise-server-2.4.0.31/examples/C# /tmp/TDengine-enterprise-server-2.4.0.31/examples/go /tmp/TDengine-enterprise-server-2.4.0.31/examples/JDBC /tmp/TDengine-enterprise-server-2.4.0.31/examples/matlab /tmp/TDengine-enterprise-server-2.4.0.31/examples/nodejs /tmp/TDengine-enterprise-server-2.4.0.31/examples/python /tmp/TDengine-enterprise-server-2.4.0.31/examples/R /tmp/TDengine-enterprise-server-2.4.0.31/examples/taosbenchmark-json /usr/local/taos/examplessudo 56803 56674 0 /usr/bin/sudo rm -f /usr/bin/taosrm 56805 56803 0 /bin/rm -f /usr/bin/taossudo 56806 56674 0 /usr/bin/sudo rm -f /usr/bin/taosdrm 56807 56806 0 /bin/rm -f /usr/bin/taosdsudo 56808 56674 0 /usr/bin/sudo rm -f /usr/bin/taosadapterrm 56809 56808 0 /bin/rm -f /usr/bin/taosadaptersudo 56810 56674 0 /usr/bin/sudo rm -f /usr/bin/rmtaosrm 56811 56810 0 /bin/rm -f /usr/bin/rmtaossudo 56812 56674 0 /usr/bin/sudo rm -f /usr/bin/tarbitratorrm 56813 56812 0 /bin/rm -f /usr/bin/tarbitratorsudo 56814 56674 0 /usr/bin/sudo rm -f /usr/bin/set_corerm 56815 56814 0 /bin/rm -f /usr/bin/set_coresudo 56816 56674 0 /usr/bin/sudo rm -f /usr/bin/run_taosd_and_taosadapter.shrm 56817 56816 0 /bin/rm -f /usr/bin/run_taosd_and_taosadapter.shsudo 56818 56674 0 /usr/bin/sudo rm -f /usr/bin/TDinsight.shrm 56819 56818 0 /bin/rm -f /usr/bin/TDinsight.shsudo 56820 56674 0 /usr/bin/sudo cp -r /tmp/TDengine-enterprise-server-2.4.0.31/bin/remove.sh /tmp/TDengine-enterprise-server-2.4.0.31/bin/run_taosd_and_taosadapter.sh /tmp/TDengine-enterprise-server-2.4.0.31/bin/set_core.sh /tmp/TDengine-enterprise-server-2.4.0.31/bin/startPre.sh /tmp/TDengine-enterprise-server-2.4.0.31/bin/taos /tmp/TDengine-enterprise-server-2.4.0.31/bin/taosadapter /tmp/TDengine-enterprise-server-2.4.0.31/bin/taosBenchmark /tmp/TDengine-enterprise-server-2.4.0.31/bin/taosd /tmp/TDengine-enterprise-server-2.4.0.31/bin/taosd-dump-cfg.gdb /tmp/TDengine-enterprise-server-2.4.0.31/bin/taosdump /tmp/TDengine-enterprise-server-2.4.0.31/bin/taoskeeper /tmp/TDengine-enterprise-server-2.4.0.31/bin/tarbitrator /tmp/TDengine-enterprise-server-2.4.0.31/bin/tdengine-datasource-3.2.5.zip /tmp/TDengine-enterprise-server-2.4.0.31/bin/TDinsight-15167.json /tmp/TDengine-enterprise-server-2.4.0.31/bin/TDinsight.sh /usr/local/taos/bin.....
3.2.opensnoop
通过跟踪每次open系统调用,打印进程名和文件名。 也以 TDengine 为例,查看进程启动时,打开了哪些文件:
57439 taosd 3 0 /etc/ld.so.cache57439 taosd 3 0 /usr/local/lib/libjemalloc.so.257439 taosd 3 0 /lib64/libdl.so.257439 taosd 3 0 /lib/libtaos.so.157439 taosd 3 0 /lib64/libm.so.657439 taosd 3 0 /lib64/librt.so.157439 taosd 3 0 /lib64/libpthread.so.057439 taosd 3 0 /lib64/libc.so.657439 taosd 3 0 /lib64/libstdc++.so.657439 taosd 3 0 /lib64/libgcc_s.so.157439 taosd 3 0 /proc/sys/vm/overcommit_memory57439 taosd 3 0 /sys/kernel/mm/transparent_hugepage/enabled57439 taosd 4 0 /etc/localtime57439 taosd 4 0 /dev/urandom57439 taosd 4 0 /etc/taos/taos.cfg57439 taosd 4 0 /proc/cpuinfo57439 taosd 4 0 /taos/log/taosdlog.057439 taosd 5 0 /etc/taos/taos.cfg......57439 taosd 5 0 /taos/log/taosinfo.057439 taosd 6 0 /tmp/57439 taosd 6 0 /sys/devices/system/cpu/online57439 taosd 6 0 /proc/meminfo57439 taosd 6 0 /proc/meminfo57439 taosd 6 0 /proc/57439/status57439 taosd 6 0 /proc/net/dev57439 taosd 6 0 /proc/stat57439 taosd 6 0 /proc/57439/stat57439 taosd 6 0 /proc/57439/io57439 taosd -1 2 /etc/timezone57439 taosd 6 0 /usr/lib/locale/locale-archive57439 taosd 6 0 /usr/lib64/gconv/gconv-modules.cache57439 taosd 6 0 /taos/data/vnode_bak/.staging57439 taosd 6 0 /taos/data/dnode/.running57439 taosd 7 0 /taos/data/dnode/dnodeCfg.json57439 taosd 7 0 /taos/data/dnode/dnodeCfg.json57439 taosd 7 0 /taos/data/dnode/dnodeEps.json57439 taosd 7 0 /taos/data/dnode/mnodeEpSet.json57439 taosd 9 0 /proc/meminfo57439 taosd 15 0 /taos/data/vnode57439 dnodeOpenVnode 15 0 /taos/data/vnode/vnode9/config.json57439 dnodeOpenVnode 15 0 /taos/data/vnode/vnode4/config.json57439 dnodeOpenVnode 16 0 /taos/data/vnode/vnode9/version.json57439 dnodeOpenVnode 15 0 /taos/data/vnode/vnode4/version.json57439 dnodeOpenVnode 15 0 /taos/data/vnode/vnode4/tsdb/current57439 dnodeOpenVnode 15 0 /taos/data/vnode/vnode4/tsdb/data/v4f1736.head57439 dnodeOpenVnode 16 0 /taos/data/vnode/vnode4/tsdb/data/v4f1736.data57439 dnodeOpenVnode 17 0
4.分享
提取码: 3hcc
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~