昇腾社区首页
中文
注册

安装perf、iotop、ltrace工具

安装依赖

  • Ubuntu 18.04操作系统,执行以下命令安装。
    • iotop工具安装方法:
      此处以python3为例进行介绍,若用户使用其他版本Python,请自行适配。
      wget http://guichaz.free.fr/iotop/files/iotop-0.6.tar.bz2
      tar -xvf iotop-0.6.tar.bz2
      cd iotop-0.6
      sed -i 's/itervalues/values/g' setup.py
      python3 setup.py build
      python3 setup.py install
      ln -s /usr/local/python3/sbin/iotop /usr/sbin/iotop
      ln -s /usr/local/python3/bin/iotop /usr/bin/iotop
    • perf工具安装方法:
      apt-get install linux-tools-common
      安装完成后执行perf命令,根据系统提示继续使用apt-get install安装linux-tools-x和linux-cloud-x例如:
      apt-get install linux-tools-5.4.0-77-generic
      apt-get install linux-cloud-tools-5.4.0-77-generic
    • ltrace工具安装方法:
      apt-get install ltrace
  • CentOS 7.6、EulerOS和OpenEuler20.03操作系统,执行以下命令安装。

    yum install perf iotop ltrace

配置用户权限

安装完依赖后,需要给用户配置依赖权限。可参见如下步骤进行配置。

  1. 以root用户登录环境。
  2. 使用如下命令运行perf,iotop,ltrace权限配置脚本。

    Ascend-cann-toolkit安装目录/ascend-toolkit/latest/tools/profiler/scripts/msprof_root_config.sh {安装用户名}

    例如:
    /home/HwHiAiUser/Ascend/toolkit/tools/profiler/scripts/msprof_root_config.sh HwHiAiUser
    执行完成后输出如图1表示执行成功。
    图1 脚本执行成功
  3. 基于安全考虑,配置完以上脚本并完成相应Profiling采集后,请进行配置清除操作:
    1. 检查是否存在“/etc/sudoers.d/{安装用户名}_profiling”文件,若存在则删除该文件。
    2. 检查是否存在“/etc/sudoers”文件,若存在则:
      打开“/etc/sudoers”文件:
      chmod u+w /etc/sudoers
      vi /etc/sudoers
      删除文件内如下内容:
      huawei ALL=(ALL:ALL) NOPASSWD:/usr/bin/msprof_data_collection.sh get-version perf,/usr/bin/msprof_data_collection.sh get-version ltrace,/usr/bin/msprof_data_collection.sh get-version iotop,/usr/bin/msprof_data_collection.sh pkill perf,/usr/bin/msprof_data_collection.sh pkill ltrace,/usr/bin/msprof_data_collection.sh pkill iotop,/usr/bin/msprof_data_collection.sh perf [0-9],/usr/bin/msprof_data_collection.sh ltrace [0-9],/usr/bin/msprof_data_collection.sh iotop [0-9],/usr/bin/msprof_data_collection.sh perf [1-9][0-9],/usr/bin/msprof_data_collection.sh ltrace [1-9][0-9],/usr/bin/msprof_data_collection.sh iotop [1-9][0-9],/usr/bin/msprof_data_collection.sh perf [1-9][0-9][0-9],/usr/bin/msprof_data_collection.sh ltrace [1-9][0-9][0-9],/usr/bin/msprof_data_collection.sh iotop [1-9][0-9][0-9],/usr/bin/msprof_data_collection.sh perf [1-9][0-9][0-9][0-9],/usr/bin/msprof_data_collection.sh ltrace [1-9][0-9][0-9][0-9],/usr/bin/msprof_data_collection.sh iotop [1-9][0-9][0-9][0-9],/usr/bin/msprof_data_collection.sh perf [1-9][0-9][0-9][0-9][0-9],/usr/bin/msprof_data_collection.sh ltrace [1-9][0-9][0-9][0-9][0-9],/usr/bin/msprof_data_collection.sh iotop [1-9][0-9][0-9][0-9][0-9]
      Defaults env_reset
    3. 执行以下命令取消“/etc/sudoers”文件的写权限:
      chmod u-w /etc/sudoers