博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
test-definitions/blob/master/auto-test/dstat/dstat.sh
阅读量:4214 次
发布时间:2019-05-26

本文共 1713 字,大约阅读时间需要 5 分钟。

#!/bin/sh#回显执行的命令和参数set -x#cd到目录执行脚本,然后通过cd -返回到当前目录cd ../../utils    . ./sys_info.shcd -#检查是否是root用户# Test user idif [ `whoami` != 'root' ] ; then    echo "You must be the superuser to run this script" >&2    exit 1fi#根据不同发行版安装不同的包case $distro in    "debian|ubuntu")        apt-get install dstat -y        print_info $? install-dstat         ;;    "centos")        yum install dstat -y        print_info $? install-dstatesac#输出默认监控,报表 输出时间间隔为3s,输出10个结果dstat 3 10  2>&1 | tee dstat.logprint_info $? dstat#查看内存占用情况dstat -g -l -m -s --top-mem 3 10 2>&1 | tee -a dstat.logprint_info $? dstat-g#显示一些关于cpu资源损耗的数据dstat -c -y -l --proc-count --top-cpu 3 10 2>&1 | tee -a dstat.logprint_info $? dstat-c#查看当前占用I/O,cpu,内存等最高的进程信息dstat --top-mem --top-io --top-cpu 3 10 2>&1 | tee -a dstat.logprint_info $? dstat-top#查看某个cpu状态信息dstat -c 0,1 3 10 2>&1 | tee -a dstat.logprint_info $? dstat-c-01#查看系统的磁盘的读写数据大小dstat -d 3 10 2>&1 | tee -a dstat.log#查看系统网络状态dstat -n 3 10 2>&1 | tee -a dstat.logprint_info $? dstat-n#查看系统负载情况dstat -l 3 10 2>&1 | tee -a dstat.logprint_info $? dstat-l#查看系统进程信息dstat -p 3 10 2>&1 | tee -a dstat.logprint_info $? dstat-p#查看系统tcp,udp端口情况dstat --socket 3 10 2>&1 | tee -a dstat.logprint_info $? dstat-socket#查看I/o请求情况dstat -r 3 10 2>&1 | tee -a dstat.logprint_info $? dstat-r#由于前面执行了很多次dstat ,因此此时可能有多个dstat 进程存在,这个#找到所有的dstat进程的个数count=`ps -aux | grep dstat | wc -l`if [ $count -gt 0 ]; then	#通过pidof 根据进程name得到进程pid,然后通过kill 杀掉这些进程。这里的9是强制终止进程    kill -9 $(pidof dstat)     print_info $? kill-dstatfi测试完成后,根据发行版删除dstat包case $distro in    "ubuntu|debian")     apt-get remove dstat -y     print_info $? remove-dstat     ;;    "centos")     yum remove dstat -y     print_info $? remove-dstat    ;;esac

转载地址:http://oznmi.baihongyu.com/

你可能感兴趣的文章
Conclusion for Accustoming Yourself to C++
查看>>
面试题1:赋值运算函数(offer)
查看>>
Mark : MessagePack简介及使用
查看>>
Mark : Hadoop Raid-实战经验总结
查看>>
Structured Streaming 实现思路与实现概述
查看>>
Apache Spark 2.2.0 中文文档 - Structured Streaming 编程指南 | ApacheCN
查看>>
Mark:大数据最佳学习路线
查看>>
Spark 多线程模型
查看>>
编程第一性原则
查看>>
Mark : SpringBoot核心-非关系型数据库NoSQL
查看>>
Mark : hive文件存储格式
查看>>
mark : hadoop 四种压缩格式
查看>>
Mark : hive snappy的数据是否支持split的测试
查看>>
Hadoop 压缩格式
查看>>
Mark : Spark Streaming vs. Kafka Stream 哪个更适合你
查看>>
Mark : spark streaming去重
查看>>
Mark : RCFile和ORCFile
查看>>
Linux学习之/etc/init.d/functions详解
查看>>
【Big Data 每日一题20180821】Spark中ml和mllib的区别
查看>>
【Big Data 每日一题20181111】为什么有栈内存和堆内存之分
查看>>