LoadRunner监控Linux的三种方法
生活随笔
收集整理的這篇文章主要介紹了
LoadRunner监控Linux的三种方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
方法一、LR + SiteScope/nmon方法二、使用rstatd包1、下載rpc.rstatd-4.0.1.tar.gz2、解壓縮tar -zxvf rpc.rstatd-4.0.1.tar.gz3、配置./configure4、編譯make5、安裝make install6、啟動rpc.rstatd7、在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=2HTYPE=$(uname -s)genStat()
{now=$( date +%S )while [ "$now" -ne "30" ]dosleep 1now=$( date +%S )donewhile :;dodat=$(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 $SLEEPdone
}mkcsv()
{dat=$1if [ "$HTYPE" == "SunOS" ]then#IO CSVecho date,time,device,r/s,w/s,kr/s,kw/s,wait,actv,wsvc_t,asvc_t,%w,%b > ${LOG}/io.${dat}.csvcat ${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 csvecho 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}.csvcat ${LOG}/vm.${dat}.log | awk '{for(l=1;l<23;l++) { printf("%s,", $l) }; print $23 }' >> ${LOG}/vm.${dat}.csv#uptime csvecho time,users,5min,10min,15min > ${LOG}/uptime.${dat}.csvcat ${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}.csvelif [ "$HTYPE" == "Linux" ]then#IO CSVecho "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}.csvcat ${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 csvecho date,time,r,b,swp,free,buff,cache,si,so,bi,bo,in,cs,us,sy,id,wa > ${LOG}/vm.${dat}.csvcat ${LOG}/vm.${dat}.log | awk '{for(l=1;l<17;l++) { printf("%s,", $l) }; print $17 }' >> ${LOG}/vm.${dat}.csv#uptime csvecho time,users,5min,10min,15min > ${LOG}/uptime.${dat}.csvcat ${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}.csvelseecho "Hmmm - An unexpected error occured. Have you change the host type?"fi}if [ "$HTYPE" != "SunOS" -a "$HTYPE" != "Linux" ]
thenecho "Error - This script has no knowlege of the System $HTYPE"echo " You will need to do some tweaking."exit
ficase $1 in run)genStat;;csv)if [ $# -lt 2 ]thenecho "Error - You must supply a date in the form YYYYMMDD"exitfimkcsv $2;;*)echo -e ":::: Usage ::::"echo -e "$0 run : Collect stats"echo -e "$0 csv YYYYMMDD : Generate CSV from stats"echo "";;
esac
?
總結
以上是生活随笔為你收集整理的LoadRunner监控Linux的三种方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python之抽象一
- 下一篇: 怎样保证客户端和服务器端数据的一致性(数