免费注册 查看新帖 |

Chinaunix

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

怎么在crontab里面定时用glance收集数据 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-11-01 13:39 |只看该作者 |倒序浏览
我需要监控系统里面哪些进程的IO用的比较多,现在准备用glance,写了一个脚本如下:

$ cat io_mon.ksh
host=`hostname`
tag=`date \'+%Y%m%d\'`
BaseDir=`dirname $0`
mkdir -p ${BaseDir}/log

/opt/perf/bin/glance -j 3 -g -maxpages 3 -iterations 3 -f ${BaseDir}/log/process_list.txt
cat ${BaseDir}/log/process_list.txt >> ${BaseDir}/log/process_by_IO$tag.log

现在问题是这个脚本手工执行是可以的,但是放在crontab里之后生成的process_list.txt 永远都是空的,不知道怎么解决啊。

论坛徽章:
0
2 [报告]
发表于 2006-11-01 14:06 |只看该作者
看了一下文档,可以用glance的metrics解决
我写了两个脚本

第一个:

$ cat runstat.ksh
host=`hostname`
tag=`date \'+%Y%m%d\'`
BaseDir=`dirname $0`
mkdir -p ${BaseDir}/log

/opt/perf/bin/glance -adviser_only -nosort -iterations 10 -j 3 -syntax ${BaseDir}/proc_IO.ksh >>${BaseDir}/log/proc_disk$tag.log 2 >&1&

第二个:
$ cat proc_IO.ksh
IF GBL_DISK_UTIL_PEAK > 80 THEN{
highestIO = 10
process loop {
IF PROC_DISK_PHYS_IO_RATE > highestIO THEN{
highestpid = proc_proc_id
highestname = proc_proc_name
highestIO = PROC_DISK_PHYS_IO_RATE
}
}
print \"--- High PHYS IO rate = \",GBL_DISK_UTIL_PEAK, \" at \",
gbl_stattime, \" ---\"print \" Process with highest IO was pid \", highestpid, \", name: \", highestname
print \" which had \", highestIO, \" physical IO of Proc\", \"utilization\"
}

运行runstat.ksh,得到的log是:
$ cat proc_disk20061031.log
--- High PHYS IO rate =  100.0 at 23:01:39 ---
Process with highest IO was pid    16554, name:          extract
which had1494.5 physical IO of Procutilization
--- High PHYS IO rate =  100.0 at 23:01:42 ---
Process with highest IO was pid    16554, name:          extract
which had2507.6 physical IO of Procutilization
--- High PHYS IO rate =  100.0 at 23:01:45 ---
Process with highest IO was pid    16554, name:          extract
which had1041.0 physical IO of Procutilization
--- High PHYS IO rate =  100.0 at 23:01:48 ---
Process with highest IO was pid     8691, name:   oracleSCCOAPRD
which had 446.3 physical IO of Procutilization
--- High PHYS IO rate =  100.0 at 23:01:51 ---
Process with highest IO was pid     8691, name:   oracleSCCOAPRD
which had 442.4 physical IO of Procutilization
--- High PHYS IO rate =  100.0 at 23:01:54 ---
Process with highest IO was pid     8691, name:   oracleSCCOAPRD
which had 496.3 physical IO of Procutilization
--- High PHYS IO rate =  100.0 at 23:01:57 ---
Process with highest IO was pid     8691, name:   oracleSCCOAPRD
which had 431.6 physical IO of Procutilization
--- High PHYS IO rate =  100.0 at 23:02:00 ---
Process with highest IO was pid     5334, name:     oracleMMSPRD
which had 915.1 physical IO of Procutilization
--- High PHYS IO rate =  100.0 at 23:02:03 ---
Process with highest IO was pid     5334, name:     oracleMMSPRD
which had 368.9 physical IO of Procutilization
--- High PHYS IO rate =  100.0 at 23:02:06 ---
Process with highest IO was pid     8691, name:   oracleSCCOAPRD
which had 453.6 physical IO of Procutilization
--- High PHYS IO rate =  100.0 at 23:03:01 ---
Process with highest IO was pid     5334, name:     oracleMMSPRD
which had  254.2 physical IO of Procutilization
--- High PHYS IO rate =  100.0 at 23:03:04 ---
Process with highest IO was pid     5334, name:     oracleMMSPRD
which had  469.6 physical IO of Procutilization
--- High PHYS IO rate =  100.0 at 23:03:07 ---
Process with highest IO was pid     5334, name:     oracleMMSPRD
which had  412.3 physical IO of Procutilization
--- High PHYS IO rate =  100.0 at 23:03:10 ---
Process with highest IO was pid     5334, name:     oracleMMSPRD
which had  451.0 physical IO of Procutilization
--- High PHYS IO rate =  100.0 at 23:03:13 ---
Process with highest IO was pid     5334, name:     oracleMMSPRD
which had  410.6 physical IO of Procutilization
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP