在之前的博客中,以前写了自己主动化測试程序的实现方法,如今开发人员须要知道被測试的进程(在此指执行在LINUX上的主进程的)在异常退出之前的进程的执行状态,比如内存的使用率、CPU的使用率等.
现用shell脚本实现指定进程的执行状态。
直接上代码。
#!/bin/sh
echo "`date`"
echo "Start $0---------"
echo ""
#每十秒监视一下
sec=10
#取得指定进程名为mainAPP。内存的使用率。进程执行状态,进程名称
eval $(ps | grep "mainApp" | grep -v grep | awk {'printf("memInfo=%s;myStatus=%s;pName=%s",$3,$4,$5)'})
echo $pName $myStatus $memInfo
testPrg=""
while [ -n "$pName" -a "$myStatus" != "Z" ]
do
echo "----------`date`---------------------"
echo $pName $myStatus $memInfo
sleep $sec
####You must initialize them again!!!!!
pName=""
myStatus=""
memInfo=""
eval $(ps | grep "mainApp" | grep -v grep | awk {'printf("memInfo=%s;myStatus=%s;pName=%s",$3,$4,$5)'})
testPrg=`ps | grep "MyTester" | grep -v grep | awk '{print $0}'`
if [ -z "$testPrg" ]; then
break
fi
##注意一定要再次初始化为空
testPrg=""
done
echo "End $0---($pName,$myStatus,$testPrg)-------------------"
if [ -z "$pName" ]; then
###发现測被測试程序异常退出后,停止測试程序
killall MyTester
echo "stop TestProgram MyTester"
fi
echo "`date`"
echo "---------------Current Status------------------"
ps | grep -E "mainApp|SubApp" | grep -v grep
echo ""
这样实现了每10s读取一下进程的状态,然后显示出来。当发现进程存在而且状态非Z(非僵尸)时,继续监视,可是当測试程序执行完成或是异常退出时,该脚本也会退出监视循环。退出循环后
文件差异性 订单列表差异性 列表数据更新 比较
Writing a Time Series Database from Scratch | Fabian Reinartz https://fabxc.org/tsdb/
Prometheus is a system to collect and process metrics, not an event logging system
whisper
New in Prometheus v2.19.0: Memory-mapping of full chunks of the head block reduces memory usage by as much as 40%
使用proxy是实现集中式和分布式监控的最简单方法
t
SSO登录 企业域名
指针分析 Pointer Analysis