对于我们日常的维护和分析来说,保存一份主机日常性能采集的数据是非常有必要的。可以让我们在事后查看需要查看的那段时间的主机资源使用情况,也可以据此,我们来做一份分析报告。
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
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10867315/viewspace-566616/,如需转载,请注明出处,否则将追究法律责任。