主機日常效能資料採集
對於我們日常的維護和分析來說,儲存一份主機日常效能採集的資料是非常有必要的。可以讓我們在事後檢視需要檢視的那段時間的主機資源使用情況,也可以據此,我們來做一份分析報告。
1、AIX平臺
在AIX平臺下,我們可以藉助nmon工具很方便的實現這個需求。我們需要做的就是上傳nmon工具,然後在crontab中部署一個計劃任務。
0 0 * * * cd /home/xigua ; ./nmon_aix53 -x >> nmon.log 2>&1
-x代表每隔15分鐘做一次取樣,當然如果你認為這個頻率太低,可以修改。
例如:
0 0 * * * nmon64 -ft -D -E -I 1 -s 120 -c 720 -m /aixpatch/nmon_out
改成2分鐘採集一次,每天採集720次。
2、HP-UNIX平臺
在hp-unix下面比較麻煩一點,我們需要自己來寫採集的指令碼。指令碼主要是呼叫glance來採集資料。
定義的crontab如下:
0 0 * * * cd /glance; ./glance.sh
/glance# more glance.sh
#
# This scripts use glance plus to monitor the performance .
#
#
#
#!/sbin/sh
HOST=`hostname`
DAY=`date '+%Y%m%d'`
cd /glance/
# NETWORK INTERFACE LOOP
nohup /opt/perf/bin/glance -adviser_only -nosort -iterations 288 -j 300 -syntax ./net.adviser >>./log/net_${HOS
T}_${DAY}.log &
# SYSTEM LOOP
nohup /opt/perf/bin/glance -adviser_only -nosort -iterations 288 -j 300 -syntax ./sys.adviser >>./log/sys_${HOS
T}_${DAY}.log &
#PROCESS LOOP
nohup /opt/perf/bin/glance -adviser_only -nosort -iterations 288 -j 300 -syntax ./process.adviser >>./log/proce
ss_${HOST}_${DAY}.log &
#DISK LOOP
nohup /opt/perf/bin/glance -adviser_only -nosort -iterations 288 -j 300 -syntax ./disk.adviser >>./log/disk_${H
OST}_${DAY}.log &
這個指令碼負責呼叫4個模組的資料採集,採集的頻率是5分鐘。4個模組的採集資料定義如下 :
cat sys.adviser
# This adviser script. prints the global cpu/disk/mem/swap utilization and also
# the network subsystem wait percent for the interval.
headers_printed=headers_printed
IF headers_printed == 0 THEN
{
print " CPU SYS USER DISK PHY_READ PHY_WRITE MEM SWAP Network"
print " Date Time Util Util Util Util RATE RATE Util Util Wait %"
print "------------------------------------------------------------------------------------------------------"
headers_printed=1
}
print GBL_STATDATE," ",GBL_STATTIME," ",
GBL_CPU_TOTAL_UTIL," ",GBL_CPU_SYS_MODE_UTIL," ",GBL_CPU_USER_MODE_UTIL," ",
GBL_DISK_UTIL_PEAK," ",GBL_DISK_PHYS_READ_BYTE_RATE,"KBs ",GBL_DISK_PHYS_WRITE_BYTE_RATE,"KBs ",
GBL_MEM_UTIL," ",
GBL_SWAP_SPACE_UTIL," ",
GBL_NETWORK_SUBSYSTEM_WAIT_PCT
/glance# cat net.adviser
# This version will only work with hp-ux 11.x.If you want it to
# work for 10.20 you need to remove the "BYNETIF_QUEUE," string
# below as that metric is only available from 11.x glance.
# The following string variable should be changed to the interface
# of interest. For example:
# netif_to_examine = "lan0"
# If you want to see all interfaces, leave it an empty string (""):
# netif_to_examine = ""
# initialize variables:
# headers_printed=headers_printed
netif_to_examine=""
# print headers before the loop
print " NetIF NetIn NetOut Net Net"
print " Date Time Name bytes/s bytes/s COLLISION ERROR"
print "----------------------------------------------------------------------------------"
# begin loop
netif loop
{
# print information for the selected interface or if null then all:
IF (BYNETIF_NAME == netif_to_examine) or (netif_to_examine == "") THEN
{
IF BYNETIF_IN_BYTE_RATE > 0 or BYNETIF_OUT_BYTE_RATE > 0 THEN
{
# print one line per interface reported which has byte_rate > 0:
print GBL_STATDATE," ",GBL_STATTIME," ",BYNETIF_NAME," ",
BYNETIF_IN_BYTE_RATE," ",BYNETIF_OUT_BYTE_RATE," ",
BYNETIF_COLLISION," ",BYNETIF_ERROR
}
# (note that some interface types do not report collisions or errors)
}
}
print ""
/glance# cat disk.adviser
#
# This adviser is used for capture the disk infomation .
#
# print headers before the loop
print " Mounted DISK RESPONSE PHY_READ PHY_WRITE DISK "
print " Date Time Filesystem IOPS TIME RATE RATE Util "
print "-------------------------------------------------------------------------------------------------"
DISK LOOP
if BYDSK_DIRNAME != "Unknown" and
(BYDSK_PHYS_READ_BYTE_RATE > 0
OR BYDSK_PHYS_WRITE_BYTE_RATE > 0
OR BYDSK_UTIL > 0)then {
print
GBL_STATDATE," ",GBL_STATTIME," ",
BYDSK_DIRNAME|15|0,BYDSK_PHYS_IO_RATE,BYDSK_AVG_SERVICE_TIME,"ms ",
BYDSK_PHYS_READ_BYTE_RATE,"KBs ",BYDSK_PHYS_WRITE_BYTE_RATE,"KBs",
BYDSK_UTIL
}
/glance# cat process.adviser
#
# This adviser is used to capture the process infomation .
#
# print headers before the loop
print " PROC PROC "
print " PORC PROC PROC PROC PROC LOG PHY PHY_IO PROC "
print " Date Time OWNER ID MEM MEM_HIGH CPU IOPS IOPS RATE NAME "
print "-----------------------------------------------------------------------------------------------------"
PROCESS LOOP
if PROC_MEM_RES > 100000 then {
print
GBL_STATDATE," ",GBL_STATTIME," ",
PROC_USER_NAME,PROC_PROC_ID|7|0," ",PROC_MEM_RES," ",PROC_MEM_RES_HIGH," ",
PROC_CPU_TOTAL_TIME,
PROC_DISK_LOGL_IO_RATE,PROC_DISK_PHYS_IO_RATE,
PROC_IO_BYTE_RATE,"KBs ",
PROC_PROC_NAME
}
1、AIX平臺
在AIX平臺下,我們可以藉助nmon工具很方便的實現這個需求。我們需要做的就是上傳nmon工具,然後在crontab中部署一個計劃任務。
0 0 * * * cd /home/xigua ; ./nmon_aix53 -x >> nmon.log 2>&1
-x代表每隔15分鐘做一次取樣,當然如果你認為這個頻率太低,可以修改。
例如:
0 0 * * * nmon64 -ft -D -E -I 1 -s 120 -c 720 -m /aixpatch/nmon_out
改成2分鐘採集一次,每天採集720次。
2、HP-UNIX平臺
在hp-unix下面比較麻煩一點,我們需要自己來寫採集的指令碼。指令碼主要是呼叫glance來採集資料。
定義的crontab如下:
0 0 * * * cd /glance; ./glance.sh
/glance# more glance.sh
#
# This scripts use glance plus to monitor the performance .
#
#
#
#!/sbin/sh
HOST=`hostname`
DAY=`date '+%Y%m%d'`
cd /glance/
# NETWORK INTERFACE LOOP
nohup /opt/perf/bin/glance -adviser_only -nosort -iterations 288 -j 300 -syntax ./net.adviser >>./log/net_${HOS
T}_${DAY}.log &
# SYSTEM LOOP
nohup /opt/perf/bin/glance -adviser_only -nosort -iterations 288 -j 300 -syntax ./sys.adviser >>./log/sys_${HOS
T}_${DAY}.log &
#PROCESS LOOP
nohup /opt/perf/bin/glance -adviser_only -nosort -iterations 288 -j 300 -syntax ./process.adviser >>./log/proce
ss_${HOST}_${DAY}.log &
#DISK LOOP
nohup /opt/perf/bin/glance -adviser_only -nosort -iterations 288 -j 300 -syntax ./disk.adviser >>./log/disk_${H
OST}_${DAY}.log &
這個指令碼負責呼叫4個模組的資料採集,採集的頻率是5分鐘。4個模組的採集資料定義如下 :
cat sys.adviser
# This adviser script. prints the global cpu/disk/mem/swap utilization and also
# the network subsystem wait percent for the interval.
headers_printed=headers_printed
IF headers_printed == 0 THEN
{
print " CPU SYS USER DISK PHY_READ PHY_WRITE MEM SWAP Network"
print " Date Time Util Util Util Util RATE RATE Util Util Wait %"
print "------------------------------------------------------------------------------------------------------"
headers_printed=1
}
print GBL_STATDATE," ",GBL_STATTIME," ",
GBL_CPU_TOTAL_UTIL," ",GBL_CPU_SYS_MODE_UTIL," ",GBL_CPU_USER_MODE_UTIL," ",
GBL_DISK_UTIL_PEAK," ",GBL_DISK_PHYS_READ_BYTE_RATE,"KBs ",GBL_DISK_PHYS_WRITE_BYTE_RATE,"KBs ",
GBL_MEM_UTIL," ",
GBL_SWAP_SPACE_UTIL," ",
GBL_NETWORK_SUBSYSTEM_WAIT_PCT
/glance# cat net.adviser
# This version will only work with hp-ux 11.x.If you want it to
# work for 10.20 you need to remove the "BYNETIF_QUEUE," string
# below as that metric is only available from 11.x glance.
# The following string variable should be changed to the interface
# of interest. For example:
# netif_to_examine = "lan0"
# If you want to see all interfaces, leave it an empty string (""):
# netif_to_examine = ""
# initialize variables:
# headers_printed=headers_printed
netif_to_examine=""
# print headers before the loop
print " NetIF NetIn NetOut Net Net"
print " Date Time Name bytes/s bytes/s COLLISION ERROR"
print "----------------------------------------------------------------------------------"
# begin loop
netif loop
{
# print information for the selected interface or if null then all:
IF (BYNETIF_NAME == netif_to_examine) or (netif_to_examine == "") THEN
{
IF BYNETIF_IN_BYTE_RATE > 0 or BYNETIF_OUT_BYTE_RATE > 0 THEN
{
# print one line per interface reported which has byte_rate > 0:
print GBL_STATDATE," ",GBL_STATTIME," ",BYNETIF_NAME," ",
BYNETIF_IN_BYTE_RATE," ",BYNETIF_OUT_BYTE_RATE," ",
BYNETIF_COLLISION," ",BYNETIF_ERROR
}
# (note that some interface types do not report collisions or errors)
}
}
print ""
/glance# cat disk.adviser
#
# This adviser is used for capture the disk infomation .
#
# print headers before the loop
print " Mounted DISK RESPONSE PHY_READ PHY_WRITE DISK "
print " Date Time Filesystem IOPS TIME RATE RATE Util "
print "-------------------------------------------------------------------------------------------------"
DISK LOOP
if BYDSK_DIRNAME != "Unknown" and
(BYDSK_PHYS_READ_BYTE_RATE > 0
OR BYDSK_PHYS_WRITE_BYTE_RATE > 0
OR BYDSK_UTIL > 0)then {
GBL_STATDATE," ",GBL_STATTIME," ",
BYDSK_DIRNAME|15|0,BYDSK_PHYS_IO_RATE,BYDSK_AVG_SERVICE_TIME,"ms ",
BYDSK_PHYS_READ_BYTE_RATE,"KBs ",BYDSK_PHYS_WRITE_BYTE_RATE,"KBs",
BYDSK_UTIL
}
/glance# cat process.adviser
#
# This adviser is used to capture the process infomation .
#
# print headers before the loop
print " PROC PROC "
print " PORC PROC PROC PROC PROC LOG PHY PHY_IO PROC "
print " Date Time OWNER ID MEM MEM_HIGH CPU IOPS IOPS RATE NAME "
print "-----------------------------------------------------------------------------------------------------"
PROCESS LOOP
if PROC_MEM_RES > 100000 then {
GBL_STATDATE," ",GBL_STATTIME," ",
PROC_USER_NAME,PROC_PROC_ID|7|0," ",PROC_MEM_RES," ",PROC_MEM_RES_HIGH," ",
PROC_CPU_TOTAL_TIME,
PROC_DISK_LOGL_IO_RATE,PROC_DISK_PHYS_IO_RATE,
PROC_IO_BYTE_RATE,"KBs ",
PROC_PROC_NAME
}
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24237320/viewspace-1774187/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 開源監控軟體WGCLOUD多久採集一次主機資料GCCloud
- PHP 採集程式中日常的引數PHP
- Labview軟體、NI資料採集卡、汽車發動機資料採集學習總結(二)View
- UAV心跳機制與容器、程式資料採集
- 資料採集知識分享|4大資料採集方式都有什麼?大資料
- 工商資訊資料採集思路
- 專注深度學習模型精度和效能提升、資料採集清洗深度學習模型
- 資料採集作業四
- 資料採集作業4
- 資料採集實驗四
- 資料採集作業3
- 資料採集作業2
- 資料採集作業二
- amazon產品採集資料
- phpQuery採集網站資料PHP網站
- 地圖資料採集,包括百度地圖採集,高德地圖採集,360地圖採集地圖
- 業務場景下資料採集機制和策略
- Android 自動化測試及效能資料採集的 Python 指令碼AndroidPython指令碼
- 大資料技術之資料採集篇大資料
- 馬紮克Smooth系列 Smooth c smooth g smooth x 機床資料採集 裝置聯網 cnc資料採集 可跨平臺 免授權 tcp協議 馬紮克smart機床資料採集TCP協議
- 遊戲平臺採集資料遊戲
- 資料採集工具是什麼
- 大資料採集:fillna函式大資料函式
- 資料採集的方法有哪些
- 壓塊機PLC資料採集物聯網解決方案
- 【京東】商品list列表採集+類目下的商品列表資料採集
- 前端埋點資料採集(一)採集系統架構設計前端架構
- [效能測試+資料採集展示分析+告警策略]Jmeter+Collectd+Influxdb+GrafanaJMeterUXGrafana
- 【Python資料採集】國家自然科學基金大資料知識管理服務門戶資料採集Python大資料
- 資料採集實踐作業2
- 爬蟲資料採集的工作原理爬蟲
- 高效採集資料業務更安心
- 電商平臺資料採集介面
- PHP 資料採集的一種思路PHP
- 程式採集裝置資料,不穩定,突然不採集, 程式崩潰
- 效能優化資料庫篇-從單機到叢集優化資料庫
- Oracle資料倉儲的實時資料採集XSOracle
- 抖音商家資訊採集器,抖音小店採集 電話採集
- Linux系統效能監控採集項Linux