IBM_MQ_queue_depth_chk.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #Whritted: dufs
  2. #E-mail: fengshan.du@zznode.com
  3. #Date: 2017-03-04 12:00
  4. #queue depth check
  5. SH_NAME=`basename $0`
  6. SH_HOME=$HOME/zsjk
  7. SH_Log=$SH_HOME/log/${0%\.sh*}.log
  8. function outlog {
  9. echo "`date '+%Y-%m-%d %T'` : " "$*" >> $SH_Log
  10. logSize=`ls -lrt $SH_Log|awk '{print $5}'`
  11. if [ $logSize -gt 10240000 ]
  12. then
  13. cp -rp $SH_Log $SH_Log.`date '+%Y-%m-%d'`
  14. gzip $SH_Log.`date '+%Y-%m-%d'`
  15. cat /dev/null>$SH_Log
  16. fi
  17. }
  18. outlog =============================================================
  19. outlog start check
  20. sysapp="【MQ队列监测】"
  21. DepThrd=10000
  22. msg=""
  23. ip_list=$SH_HOME/conf/depthChk.conf
  24. if [ ! -f $ip_list ]
  25. then
  26. outlog can not find $ip_list, please check !!!
  27. exit 0
  28. fi
  29. cd $SH_HOME/
  30. for line in `cat $ip_list`
  31. do
  32. sharppos=$(echo $line|awk '{print index($1,"#")}')
  33. if [ $sharppos = 1 ]
  34. then
  35. #echo remarked line,ignore
  36. continue
  37. fi
  38. outlog -------------------------------------------------------------
  39. mqsc=`echo $line | awk -F"," '{print $1}'`
  40. queName=`echo $line | awk -F"," '{print $2}'`
  41. outlog read config: mqsc $mqsc
  42. outlog read config: queue $queName
  43. Depth=`echo "DISPLAY QLOCAL($queName)"|runmqsc $mqsc|grep CURDEPTH|awk -F'[()]' '{print $2}'`
  44. #echo $Depth
  45. if [ "$Depth" = "" ]
  46. then
  47. outlog $mqsc $queName depth not get , please check !!!
  48. msg=$msg" $mqsc $queName:未获取到队列深度"
  49. elif [ $Depth -gt $DepThrd ]
  50. then
  51. outlog $mqsc $queName depth is $Depth , more than $DepThrd please check !!!
  52. msg="$mqsc $queName:$Depth"
  53. else
  54. outlog $mqsc $queName depth is $Depth , less than $DepThrd ,it is ok.
  55. fi
  56. outlog -------------------------------------------------------------
  57. done
  58. if [ "$msg" != "" ]
  59. then
  60. Date=`date '+%Y%m%d%H%M%S'`
  61. msg=$sysapp"监测到以下队列异常:$msg,请尽快处理,巡检时间:`date '+%Y-%m-%d %T'`"
  62. outlog send message $msg
  63. sendFile=$SH_NAME.$Date
  64. echo $msg >$sendFile
  65. #outlog `./sendMsg.sh $sendFile`
  66. outlog `./sendMsg.sh $sendFile tnms2 tn15ms! 10.101.129.8 applications/bin/zsjk/data/`
  67. rm $sendFile
  68. fi
  69. outlog =============================================================
  70. exit 0