国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > Linux Shell > 正文

Linux shell腳本實現(xiàn)CPU預(yù)警

2020-07-27 19:07:41
字體:
供稿:網(wǎng)友

如果CPU占用率持續(xù)達到80以上則調(diào)用打印java線程占用率堆棧的腳本,見https://github.com/oldratlee/useful-shells/blob/master/show-busy-java-threads.sh,具體用法見他的github wiki!

#!/bin/bash#cpu idle percentcpu_idle=`top -b -d 1 -n 2 | grep Cpu | awk 'NR>1{print $5}' | cut -f 1 -d "."` if [ -d "/opt/scripts/log" ]then  cd /opt/scriptselse  mkdir /opt/scripts/logfi count=0condition=truewhile conditiondo    if [ $cpu_idle -le 20 ]    then      pids=`top -b -d 1 -n 1 | grep java | awk '{if($9 > 80) print $1}'`      for ((a = 1; a < 10; a++))      do       for pid in $pids       doi         #involve jdk existence check later         date=`date +%Y%m%d%H%M`         sh showstack.sh -c 30 -p $pid > log/stack_$pid_$date.log         jstat -gcutil $pid > log/gc_$pid_$date.log       done      done      for pid in $pids      do       date=`date +%Y%m%d%H%M`       jmap -heap $pid > log/heap_$pid_$date.log      done      count++      cpu_idle=`top -b -d 1 -n 2 | grep Cpu | awk 'NR>1{print $5}' | cut -f 1 -d "."`      if [ $count -ge 3]      then       #send emaili       #server ip address       ip=`ifconfig eth0 | grep "inet addr" | cut -f 2 -d ":" | cut -f 1 -d " "`       condition=false       count=0      fi    else      condition=false      count=0    fidone

以上所述就是本文給大家分享的全部內(nèi)容了,希望大家能夠喜歡。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 红原县| 孟州市| 瑞丽市| 阳春市| 道真| 渝中区| 鹿泉市| 镇赉县| 怀仁县| 义乌市| 佳木斯市| 宁城县| 安义县| 礼泉县| 寿光市| 汉川市| 启东市| 深圳市| 泊头市| 鄂州市| 开化县| 格尔木市| 芮城县| 中牟县| 秭归县| 额敏县| 上林县| 贵溪市| 丹巴县| 宁武县| 兴山县| 绵阳市| 永春县| 交城县| 云梦县| 达孜县| 万安县| 福贡县| 潜山县| 双城市| 博罗县|