一、shell脚本for循环(nmon监控)2
需求:/home/cg/hmf_app
1、需要做性能测试10分钟执行一次(不同的算法),
2、同时需要监控服务器资源(使用nmon监控)
初始监控是每10分钟监控。
手动执行:
10.1.1.110
cd /home/cg/hmf_app
$./nmon_x86_64_centos7 -s10 -c60 -f -m ./report
其中:for a in ${algo[@]}; //遍历算法
脚本如下:
#!/bin/bash
algo=(sm4_gcm sm4_ecb)for a in ${algo[@]};
do
./nmon_x86_64_centos7 -s10 -c60 -f -F ${a}_0001.nmon -m ./report
sleep 600
done
sleep 1 睡眠1秒
sleep 1s 睡眠1秒
sleep 1m 睡眠1分
sleep 1h 睡眠1小时
其他参考:
https://blog.csdn.net/fen_fen/article/details/112314025
二、循环使用Top监控
需求:每个算法运行10分钟,需要top监控Java程序的CPU和内存
10分钟top监控(60秒1次,10次),并存入数据到文件
#!/bin/bash
algo=(sm4_gcm_1 sm4_gcm_4 sm4_gcm_8 sm4_gcm_16)for a in ${algo[@]};
do
top -d 60 -n 2|grep java | tee java_${a}.txt
sleep 120
done
手动:top -d 5 |grep java | tee java.txt
top -d 5 -n 10|grep java | tee java.txt
top -d 60 -n 10|grep java | tee java.txt