LoadRunner監控Linux的三種方法
方法一、LR + SiteScope
方法二、使用rstatd包
1、下載rpc.rstatd-4.0.1.tar.gz
2、解壓縮
tar -zxvf rpc.rstatd-4.0.1.tar.gz
3、配置
./configure
4、編譯
make
5、安裝
make install
6、啟動
rpc.rstatd
7、在LoadRunner中新增計數器
average load :在過去的1分鐘,的平均負載
cpu utilization: cpu的使用率
disk traffic: disk傳輸率
paging rate: 每秒從磁碟讀到實體記憶體,或者從實體記憶體寫到頁面檔案的記憶體頁數
Swap-in rate: 每秒交換到記憶體的程式數
Swap-out rate: 每秒從記憶體交換出來的程式
8、將服務設定為自動啟動(Linux啟動時自動啟動這些服務):
vi /etc/rc.d/rc.local
如:
#rpc.rstatd--絕對路徑
/usr/local/sbin/rpc.rstatd
方法3、使用Shell指令碼
使用Shell指令碼收集Linux資源寫入csv檔案,再通過LR的Analysis匯入csv檔案(Tools - Extenal Monitors - Import Data... )
Shell指令碼如下所示:
#!/bin/bash
# (C) 2006 Mark Boddington, http://www.badpenguin.co.uk
# Licensed under the GNU GPL Version 2.
# ***** Version 0.2 *****
# TODO -- Create CSV parsing rules for the netstat.
# ***** Configuration *****
# set LOG to the directory you want to write the performance data to.
# set SLEEP to the number of seconds you want to sleep between samples
# set HDD to the number of had disks in your machine.
LOG=/home/mark/PerfMon/LIVE
SLEEP=10
HDD=2
HTYPE=$(uname -s)
genStat()
{
now=$( date +%S )
while [ "$now" -ne "30" ]
do
sleep 1
now=$( date +%S )
done
while :;
do
dat=$(date +%Y%m%d,%H:%M:%S)
day=$(date +%Y%m%d )
iostat -x 1 2 | sed -e"s/^/(.*/)/$dat /1/" | grep "[0-9]/." | tail -${HDD} >> ${LOG}/io.${day}.log &
vmstat 1 2 | awk "{ print /"$dat/", /$0 }" | tail -1 >> ${LOG}/vm.${day}.log &
netstat -i | grep -v Iface | awk "{ print /"$dat/", /$0 }" >> ${LOG}/netstat.${day}.log &
uptime >> ${LOG}/uptime.${day}.log &
sleep $SLEEP
done
}
mkcsv()
{
dat=$1
if [ "$HTYPE" == "SunOS" ]
then
#IO CSV
echo date,time,device,r/s,w/s,kr/s,kw/s,wait,actv,wsvc_t,asvc_t,%w,%b > ${LOG}/io.${dat}.csv
cat ${LOG}/io.${dat}.log | egrep -v "extended|device" | awk '{ OFS=","; print $1,$12,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11 }' >> ${LOG}/io.${dat}.csv
#VM csv
echo date,time,k[r],k[b],k[w],swap,free,pg[re],pg[mf],pg[pi],pg[po],pg[fr],pg[de],pg[sr],m0,m1,m2,m1,interupt,syscall,ctxswt,cpu[us],cpu[sys],cpu[idl] > ${LOG}/vm.${dat}.csv
cat ${LOG}/vm.${dat}.log | awk '{for(l=1;l<23;l++) { printf("%s,", $l) }; print $23 }' >> ${LOG}/vm.${dat}.csv
#uptime csv
echo time,users,5min,10min,15min > ${LOG}/uptime.${dat}.csv
cat ${LOG}/uptime.${dat}.log | awk '{ OFS=","; if ( $6 ~ /^[hm][ri]/) { print $1,$7,$11$12$13 } else if ( $6 ~/^user/) { print $1,$5,$9$10$11} else { print $1,$6,$10$11$12} }' >> ${LOG}/uptime.${dat}.csv
elif [ "$HTYPE" == "Linux" ]
then
#IO CSV
echo "date,time,device,rrqm/s,wrqm/s,r/s,w/s,rsec/s,wsec/s,rkB/s,wkB/s,avgrq-sz,avgqu-sz,await,svctm,%util" > ${LOG}/io.${dat}.csv
cat ${LOG}/io.${dat}.log | egrep -v "extended|device" | awk '{for(l=1;l<15;l++) { printf("%s,", $l) }; print $15}' >> ${LOG}/io.${dat}.csv
#VM csv
echo date,time,r,b,swp,free,buff,cache,si,so,bi,bo,in,cs,us,sy,id,wa > ${LOG}/vm.${dat}.csv
cat ${LOG}/vm.${dat}.log | awk '{for(l=1;l<17;l++) { printf("%s,", $l) }; print $17 }' >> ${LOG}/vm.${dat}.csv
#uptime csv
echo time,users,5min,10min,15min > ${LOG}/uptime.${dat}.csv
cat ${LOG}/uptime.${dat}.log | awk '{ OFS=","; if ( $4 ~ /^min/) { print $1,$5,$9$10$11 } else { print $1,$4,$8$9$10} }' >> ${LOG}/uptime.${dat}.csv
else
echo "Hmmm - An unexpected error occured. Have you change the host type?"
fi
}
if [ "$HTYPE" != "SunOS" -a "$HTYPE" != "Linux" ]
then
echo "Error - This script has no knowlege of the System $HTYPE"
echo " You will need to do some tweaking."
exit
fi
case $1 in
run)
genStat
;;
csv)
if [ $# -lt 2 ]
then
echo "Error - You must supply a date in the form YYYYMMDD"
exit
fi
mkcsv $2
;;
*)
echo -e ":::: Usage ::::"
echo -e "$0 run : Collect stats"
echo -e "$0 csv YYYYMMDD : Generate CSV from stats"
echo ""
;;
esac
參考:
http://www.loadrunnertnt.com/tools/local-unix-monitoring-made-possible/
http://www.badpenguin.co.uk/main/content/view/43/35/
相關文章
- LoadRunner監控Unix、Windows方法及常用效能指標Windows指標
- 一種對雲主機進行效能監控的監控系統及其監控方法
- Linux下監控流量常用的三大工具!Linux
- Linux 監控Linux
- Linux 上截圖的三種方法Linux
- Linux 效能監控工具Linux
- linux監控工具auditLinux
- 監控Kubernetes叢集證書過期時間的三種方案
- 2021年的3種IT監控趨勢
- Linux 系統監控指南Linux
- Linux 流量監控工具 iftopLinux
- linux監控平臺搭建Linux
- 一種基於KVO的頁面載入,渲染耗時監控方法
- 使用命令檢視Linux核心版本的三種方法Linux
- Linux中執行Shell指令碼的方式(三種方法)Linux指令碼
- Linux常用的監控軟體介紹!Linux
- linux下cacti監控平臺的搭建Linux
- jvisualvm遠端監控Linux下的tomcatLVMLinuxTomcat
- 幾個常用的linux效能監控命令Linux
- 網站安全監控的方法講解,網站安全監控技術網站
- Linux程式管理與效能監控Linux
- linux系統 物理硬碟監控Linux硬碟
- 進行Linux效能監控的命令介紹Linux
- Linux中監控系統效能常用的命令!Linux
- 在Linux中,如何監控系統的效能?Linux
- 監控Ubuntu Linux中的CPU/GPU 溫度UbuntuLinuxGPU
- Linux 中CPU 和 GPU 的行為監控LinuxGPU
- Prometheus多叢集監控的3種方案,你選哪種?Prometheus
- 監控雲流量的七種QoS最佳實踐
- 使用CloudStats監控Linux伺服器CloudLinux伺服器
- Linux伺服器---流量監控ntopLinux伺服器
- Linux伺服器---流量監控webalizerLinux伺服器Web
- Linux伺服器---流量監控MRTGLinux伺服器
- linux安裝Arthas監控java程式LinuxJava
- Linux伺服器---流量監控bandwidthdLinux伺服器
- 10多個 Linux 系統管理員必備的監控工具、常用的網站監控工具Linux網站
- 哪種代理適合價格監控?
- 推薦4款好用的Linux監控軟體!Linux
- 【合集】Linux運維常用的服務監控工具Linux運維