test-definitions/blob/master/auto-test/iostat/iostat.sh

#!/bin/sh
#命令和参数回显
set -x

cd ../../utils
    . ./sys_info.sh
cd -
#检查是否是root用户
# Test user id
if [ `whoami` != 'root' ] ; then
    echo "You must be the superuser to run this script" >&2
    exit 1
fi
#安装iostat的安装包,在centos中,这个安装包的名字这么奇怪
case $distro in
    "centos")
        yum install pcp-import-iostat2pcp -y
        print_info $? pcp-import-iostat2pcp
        ;;
    "ubuntu |debian")
        apt-get install sysstat -y
        print_info $? sysstat
         ;;
esac

#显示所有设备负载情况
iostat 2>&1 | tee iostat.log
print_info $? iostat

#定时显示所有信息每隔2秒刷新显示,且显示3次
iostat 2 3  2>&1 | tee iostat1.log
print_info $? iostat-on-time

#显示指定磁盘信息
iostat -d sda1 2>&1 | tee iostat-d.log
print_info $? iostat-d

#显示tty和CPu信息
iostat -t 2>&1 | tee iostat-t.log
print_info $? iostat-t

#以M为单位显示所有信息
iostat -m 2>&1 | tee iostat-m.log
print_info $? iostat-m

#查看TPS和吞吐量信息
iostat -d -k 1 1  2>&1 | tee iostat-d.log
print_info $? iostat-d

#查看设备使用率,相应时间
iostat -d -x -k 1 1 2>&1 | tee iostat-x.log
print_info $? iostat-x

#查看cpu状态
iostat -c 1 3 2>&1 | tee iostat-c.log
pirnt_info $? iostat-c
#根据进程名杀掉进程,其实这里可以直接用pkill 代替
count=`ps -aux | grep iostat | wc -l`
if [ $count -gt 0 ]; then
    kill -9 $(pidof iostat)
     print_info $? kill-iostat
fi
#测试完成后根据发行版删除包
case $distro in
    "ubuntu|debian")
     apt-get remove systat -y
     print_info $? remove-systat
     ;;
 "centos")
    yum remove pcp-import-iostat2pcp -y
    print_info $? remove-pcp-import-iostat2pcp
    ;;
esac

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值