亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
12下一頁(yè)
最近訪(fǎng)問(wèn)板塊 發(fā)新帖
查看: 7348 | 回復(fù): 14
打印 上一主題 下一主題

關(guān)于監(jiān)控oracle的alert文件的問(wèn)題 [原創(chuàng)] [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2004-06-16 14:31 |只看該作者 |倒序?yàn)g覽
正好有人討論監(jiān)控oracle的alert問(wèn)題.

我寫(xiě)了幾個(gè)腳本. 拿出來(lái)大家討論

論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2004-06-16 14:36 |只看該作者

關(guān)于監(jiān)控oracle的alert文件的問(wèn)題 [原創(chuàng)]

思路一, 使用sed的模式空間和保持空間處理獲取特定關(guān)鍵字上面行的問(wèn)題

以下未sed腳本文件, 保存成scr1 (注意, 清除每行末尾的空格)
自己改一下第一個(gè)時(shí)間字段


  1. /^Wed Jan.*$/ {
  2. x
  3. /ORA/b go
  4. d
  5. x
  6. d
  7. b
  8. :go
  9. p
  10. d
  11. x
  12. d
  13. }

  14. /^.*$/ {
  15. H
  16. }
復(fù)制代碼


使用以下命令處理alert文件
  1. sed -f scr1 alert*.log
復(fù)制代碼

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2004-06-16 14:40 |只看該作者

關(guān)于監(jiān)控oracle的alert文件的問(wèn)題 [原創(chuàng)]

思路2,使用awk等進(jìn)行shell編程

下面這個(gè)版本是集中監(jiān)控的版本.
程序運(yùn)行在各個(gè)oracle主機(jī)上(后臺(tái)方式), 處理結(jié)果放到集中監(jiān)控的機(jī)器上,
在監(jiān)控機(jī)器上可以用tail命令查看結(jié)果.

已經(jīng)在生產(chǎn)環(huán)境中運(yùn)行半年了. 小bug, 不影響使用
環(huán)境: oracle 9i RAC (4node) for hpux


  1. #!/usr/bin/ksh
  2. # #############################################################################
  3. # purpose  : auto check oracle alert file
  4. # filename : check.sh
  5. # author   : dntadm2 (steven)
  6. # version  : 2004/03/04 print line num can modify like this :
  7. #                       echo `sed -n '/date/=;$=' log` |sed 's/ /:/'
  8. # version  : 2004/02/25 fix bugs (trap a NULL i value)
  9. # version  : 2004/02/13 send error to a centrala host to display
  10. # version  : 2004/02/10 fix bugs (last line problem)
  11. #                       fix bugs (cannot compare with * in filename by create datetime)
  12. #                       fix bugs (chinese date)
  13. #                       fix bugs for linux & hpux
  14. # version  : 2004/01/30 modified u can interrupt it and then continue it
  15. #                       modified this script to run with oracle RAC
  16. # version  : 2004/01/20 first release
  17. # #############################################################################

  18. unset LANG
  19. unset LANGUAGE

  20. localhost=`hostname`
  21. mon_host="center_3"
  22. mon_file="../../../data/syslog/alert.log"
  23. orasid=`grep -v ^# /etc/oratab |sort -u |tail -1 |cut -d: -f1`
  24. orahome=`grep -v ^# /etc/oratab |sort -u |tail -1 |cut -d: -f2`
  25. alertfile=$orahome/../../admin/$orasid/bdump/alert_${orasid}.log
  26. tagfile=dnt_tag
  27. day=`date |cut -c1-10`
  28. first=`awk -v var1="$day" '$0 ~ var1 {print NR}' $alertfile |head -1`
  29. begin_num=`wc -l $alertfile |sed 's/^  *//' |cut -d" " -f1` # an all-purpose for linux and hpux

  30. if [[ -z $first ]]; then
  31. echo "no log for today"
  32. fi

  33. while true
  34. do
  35.   day=`date |cut -c1-10`
  36.   output=/tmp/check_alert.$$

  37.   if [[ ! -f $tagfile ]]; then
  38.     #echo "new a file"
  39.     unset IFS
  40.     line_num=`echo \`cat $alertfile |awk -v var1="$day" '$0 ~ var1 {print NR} END {print NR}'\` |sed 's/ /:/g'`
  41.     # echo $line_num
  42.     touch $tagfile
  43.     chmod 666 $tagfile
  44.     begin_num=${line_num%%:*}
  45.     line_num=${line_num#*:}
  46.   elif [[ $alertfile -nt $tagfile ]]; then
  47.     #echo " alert is newer than tagfile"
  48.     unset IFS
  49.     line_num=`echo \`cat $alertfile |awk -v var1="$day" '$0 ~ var1 {print NR} END {print NR}'\` |sed 's/ /:/g'`
  50.     # echo $line_num
  51.     touch $tagfile
  52.     chmod 666 $tagfile
  53.     line_num=${line_num##*$begin_num}
  54.     begin_num=$((begin_num+1))
  55.     line_num=${line_num##*$begin_num:}
  56.   else
  57.     #echo "alert file is older than tagfile"
  58.     #echo ".\c"
  59.     sleep 30
  60.     #trap 'wait; rm -fr $tagfile; exit 2' 2
  61.     continue
  62.   fi

  63.   export IFS=:
  64.   # echo
  65.   # echo "begin_num="$begin_num
  66.   # echo "line_num="$line_num
  67.   for i in $line_num
  68.   do
  69.     if [ "$i" -eq "" ]; then
  70.       continue
  71.     fi
  72.     if [[ $i = ${line_num##*:} ]]; then
  73.       sed -n "$begin_num,${i}p" $alertfile |grep ^ORA- 1>/dev/null 2>&1
  74.       if [[ $? = 0 ]]; then
  75.         # echo "$begin_num to $i"
  76.         echo "=====" > $output
  77.         sed -n "$begin_num,${i}p" $alertfile |sed "s/^/$localhost: /" >> $output
  78.       fi
  79.     else
  80.       sed -n "$begin_num,$((i-1))p" $alertfile |grep ^ORA- 1>/dev/null 2>&1
  81.       if [[ $? = 0 ]]; then
  82.         # echo "$begin_num to $i"
  83.         echo "=====" > $output
  84.         sed -n "$begin_num,$((i-1))p" $alertfile |sed "s/^/$localhost: /" >> $output
  85.       fi
  86.     fi

  87.     if [ -f $output ]; then
  88.       while read sline; do
  89.         sline="'"$sline"'"
  90.         remsh $mon_host -n "echo $sline >> $mon_file"
  91.       done < $output
  92.       /sbin/rm -f $output
  93.     fi

  94.     begin_num=$i
  95.     # echo $begin_num
  96.   done
  97. done

復(fù)制代碼

論壇徽章:
0
4 [報(bào)告]
發(fā)表于 2004-09-13 22:12 |只看該作者

關(guān)于監(jiān)控oracle的alert文件的問(wèn)題 [原創(chuàng)]

這樣的東西竟然回帖? 真?zhèn)?br /> 大家沒(méi)有這樣的需求嗎?

論壇徽章:
0
5 [報(bào)告]
發(fā)表于 2004-09-14 08:43 |只看該作者

關(guān)于監(jiān)控oracle的alert文件的問(wèn)題 [原創(chuàng)]

好東西,頂.

論壇徽章:
0
6 [報(bào)告]
發(fā)表于 2004-09-14 10:43 |只看該作者

關(guān)于監(jiān)控oracle的alert文件的問(wèn)題 [原創(chuàng)]

頂先,呵呵!

論壇徽章:
0
7 [報(bào)告]
發(fā)表于 2004-11-16 16:53 |只看該作者

關(guān)于監(jiān)控oracle的alert文件的問(wèn)題 [原創(chuàng)]

有人看就頂上來(lái)

論壇徽章:
0
8 [報(bào)告]
發(fā)表于 2004-11-17 11:27 |只看該作者

關(guān)于監(jiān)控oracle的alert文件的問(wèn)題 [原創(chuàng)]

太太太感謝了,自己寫(xiě)了一個(gè)太簡(jiǎn)單了,這個(gè)根本不用改就能直接拿來(lái)用了。不過(guò),我這里還有很多系統(tǒng)用8i,還要改下,呵。
感謝

論壇徽章:
0
9 [報(bào)告]
發(fā)表于 2004-11-17 11:39 |只看該作者

關(guān)于監(jiān)控oracle的alert文件的問(wèn)題 [原創(chuàng)]

我們這里曾經(jīng)出現(xiàn)過(guò)系統(tǒng)當(dāng)機(jī)后,oracle起不起來(lái),oracle工程師排障后判斷是有人對(duì)底層的alert文件進(jìn)行監(jiān)控導(dǎo)致,摟住能說(shuō)說(shuō)是什么原因嗎?

論壇徽章:
0
10 [報(bào)告]
發(fā)表于 2004-11-17 12:06 |只看該作者

關(guān)于監(jiān)控oracle的alert文件的問(wèn)題 [原創(chuàng)]

原帖由 "hawkli" 發(fā)表:
太太太感謝了,自己寫(xiě)了一個(gè)太簡(jiǎn)單了,這個(gè)根本不用改就能直接拿來(lái)用了。不過(guò),我這里還有很多系統(tǒng)用8i,還要改下,呵。
感謝


原來(lái)真的有人需要. hoho. 這個(gè)帖子沉了半年了吧. 貼一個(gè)新版本. 監(jiān)控效率提高n倍

  1. #!/usr/bin/ksh
  2. # #############################################################################
  3. # purpose  : auto check oracle alert file
  4. # filename : checkalert.sh
  5. # author   : steven
  6. # date     : 2004/10/23
  7. # #############################################################################

  8. HOSTNAME=`hostname`
  9. BASEDIR=/var/tmp
  10. MONHOST="xxxx"
  11. MONFILE="../../../data/syslog/alert.log"
  12. TAGFILE=$BASEDIR/alertcheck_tagfile
  13. STATFILE=$BASEDIR/alertcheck_statusfile
  14. OUTPUT=$BASEDIR/alertcheck_outputfile
  15. TMPFILE=$BASEDIR/alertcheck_tmpfile
  16. ALERTFILE=/data11/bak/bdump/sid.log

  17. CUR=`ll $ALERTFILE |awk '{print $5}'`
  18. if [ ! -f $STATFILE ] || [ `cat $STATFILE` -gt $CUR ]; then
  19.   ll $ALERTFILE |awk '{print $5}' > $STATFILE
  20. fi

  21. if [ ! -f $TAGFILE ]; then
  22.   touch $TAGFILE
  23. fi

  24. if [ ! -f $OUTPUT ]; then
  25.   touch $OUTPUT
  26. fi

  27. CNT=`cat $STATFILE`

  28. while true ; do
  29.   sleep 3
  30.   if [ $ALERTFILE -nt $TAGFILE ]; then
  31.     NEWSTAT=`ll $ALERTFILE |awk '{print $5}'`
  32.     dd if=$ALERTFILE of=$TMPFILE bs=1 skip=$CNT 1>/dev/null 2>&1
  33.     CHECKSTAT=`ll $ALERTFILE |awk '{print $5}'`
  34.     if [ ! $NEWSTAT -eq $CHECKSTAT ]; then
  35.       continue
  36.     fi
  37.     touch $TAGFILE
  38.     LINE=`cat -n $TMPFILE |awk '/... ... .. ..:..:.. 200./ {print $1} END { print NR }' |xargs`
  39.     echo $LINE |awk '{printf("%s %s\n",$(NF-1),$NF)}' |read L1 L2
  40.     if [ $L1 -eq $L2 ]; then
  41.       LINE=${LINE% *}
  42.       CNT=$((NEWSTAT-25))
  43.     else
  44.       LINE=${LINE% *}" $((L2+1))"
  45.       CNT=$NEWSTAT
  46.     fi
  47.     echo $CNT > $STATFILE

  48.     BEGIN=1
  49.     for i in $LINE ; do
  50.       if [ ! $((i-1)) -gt 1 ]; then
  51.         continue
  52.       fi
  53.       sed -n "$BEGIN,$((i-1))p" $TMPFILE |\
  54.         grep -i -e Reconfig -e Start -e Shut -e ^ORA -e error -e Instance 1>/dev/null 2>&1
  55.       if [ $? -eq 0 ]; then
  56.         sed -n "$BEGIN,$((i-1))p" $TMPFILE |sed "s/^/$HOSTNAME: /" >> $OUTPUT
  57.       fi
  58.       BEGIN=$i
  59.     done

  60.     while read sline; do
  61.       sline="'"$sline"'"
  62.       remsh $MONHOST -n "echo $sline >> $MONFILE"
  63.     done < $OUTPUT

  64. #    > $TMPFILE
  65.     > $OUTPUT

  66.   else
  67.     continue
  68.   fi
  69. done
復(fù)制代碼
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專(zhuān)區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP