免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3220 | 回复: 4
打印 上一主题 下一主题

[性能调优] 那里有监控主机性能(内存、i/o、cpu)使用情况的脚本?谢谢! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-07-12 22:23 |只看该作者 |倒序浏览
那里有监控主机性能(内存、i/o、cpu)使用情况的脚本?谢谢!
每个月要生成日志报表!。

论坛徽章:
0
2 [报告]
发表于 2004-07-13 08:02 |只看该作者

那里有监控主机性能(内存、i/o、cpu)使用情况的脚本?谢谢!

vmstat, iostat, sar + perl, 你可以自己来写,可以针对你自己的业务和主机使用情况来做出很好的统计和报表。

论坛徽章:
0
3 [报告]
发表于 2004-07-13 14:00 |只看该作者

那里有监控主机性能(内存、i/o、cpu)使用情况的脚本?谢谢!

有没有现成的啊?谢谢,

论坛徽章:
0
4 [报告]
发表于 2004-07-14 11:53 |只看该作者

那里有监控主机性能(内存、i/o、cpu)使用情况的脚本?谢谢!

#! /bin/sh
Month=`date "+%m"`
Day=`date "+%d"`
Year=`date "+%y"`
YEAR=`date "+%Y"`
Num=5

LogDir=/tmp/peak/TT

CPULog=$LogDir/CPU_MEM_$YEAR$Month$Day.txt
CRITICAL=$LogDir/CRITICAL_CPU_MEM_$YEAR$Month$Day.txt
WARNING=$LogDir/WARNING_CPU_MEM_$YEAR$Month$Day.txt

#####Monitor CPU & Memory#####
vmstat -t 2 $Num >;>; $CPULog

CNT=`tail -$Num $CPULog|awk '$1 ~ /^[0-9]/ {if($14+$15>;94 || $16<6){print $0}}' | wc -l`

if [ $CNT -gt 0 ] ; then
  echo "***********CRITICAL***********" >;>; $CRITICAL
  date >;>; $CRITICAL
  head -3 $CPULog >;>; $CRITICAL
  tail -$Num $CPULog|awk '$1 ~ /^[0-9]/ {if($14+$15>;94 || $16<6){print $0}}' >;>; $CRITICAL
fi

CNT=`tail -$Num $CPULog |awk '$1 ~ /^[0-9]/ {if($6+$7>;0){print $0}}' | wc -l`

if [ $CNT -gt 0 ] ; then
  echo "***********WARNING***********" >;>; $WARNING
  date >;>; $WARNING
  head -3 $CPULog >;>; $WARNING
  tail -$Num $CPULog |awk '$1 ~ /^[0-9]/ {if($6+$7>;0){print $0}}' >;>; $WARNING
fi


#####Monitor HW ERROR#####
CNT=`errpt -d H -s $Month$Day"0000"$Year |wc -l`

if [ $CNT -gt 0 ] ; then
  HWERR=$LogDir/HW_ERROR_$YEAR$Month$Day.txt
  echo "***********HW_ERROR***********" >;>; $HWERR
  date >;>; $HWERR
  errpt -d H -s $Month$Day"0000"$Year >;>; $HWERR
fi


#####Monitor Memory#####
lsps -a >;>; $CPULog

CNT=`tail -1 $CPULog |awk '{if($5>;20){print $0}}'| wc -l`

if [ $CNT -gt 0 ] ; then
  echo "***********CRITICAL***********" >;>; $CRITICAL
  date >;>; $CRITICAL
  tail -2 $CPULog >;>; $CRITICAL
fi

svmon -G >;>; $CPULog

CNT=`tail -7 $CPULog |grep memory |awk '{if($3/$2*100>;80){print $0}}'| wc -l`

if [ $CNT -gt 0 ] ; then
  echo "***********CRITICAL***********" >;>; $CRITICAL
  date >;>; $CRITICAL
  tail -7 $CPULog >;>; $CRITICAL
fi


你自己试一下,有些地方可能要更改

论坛徽章:
0
5 [报告]
发表于 2004-07-14 13:30 |只看该作者

那里有监控主机性能(内存、i/o、cpu)使用情况的脚本?谢谢!

可以使用nmon工具,省去写脚本的麻烦了,并且可以通过excel出图形分析:

For Data-Collect-Mode = spreadsheet format (comma separated values)
        Note: use only one of f,F,z,x or X and make it the first argument
        -f            spreadsheet output format [note: default -s300 -c288]
                         output file is <hostname>;_YYYYMMDD_HHMM.nmon
        -F <filename>; same as -f but user supplied filename
        -r <runname>;  goes into spreadsheet file [default hostname]
        -t            include top processes in the output
        -T            as -t plus saves command line arguments in UARG section
        -s <seconds>;  between snap shots
        -c <number>;   of refreshes
        -l <dpl>;      disks/line default 150 to avoid spreadsheet issues. EMC=64
.
        -g <filename>; User decided Disk Groups (see above -g)
        -D            Skip disk configuration sections
        -E            Skip ESS  configuration sections
        -W            Include WLM sections
        -I <percent>;  Ignore process percent threshold (default 0.1)
                      don't save TOP stats if proc using less CPU than this %
        -A            Include Async I/O Section
        -m <dir>;      nmon changes to this directory before saving data to a fil
e
        example: collect for 1 hour at 30 second intervals with top procs
                 nmon64 -f -t -r Test1 -s30 -c120
        To load into a spreadsheet like Lotus 1-2-3:
        sort -A *nmon >;stats.csv
        transfer the stats.csv file to your PC
        Start 1-2-3 and then Open <char-separated-value ASCII file>;
Capacity planning mode - use cron to run each day
        -x            sensible spreadsheet output for CP =  one day
                      every 15 mins for 1 day ( i.e. -ft -s 900 -c 96)
        -X            sensible spreadsheet output for CP = busy hour
                      every 30 secs for 1 hour ( i.e. -ft -s 30 -c 120)
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP