Linx監控分享--重點進程監控(mysqld)+寄件提醒

來源:互聯網
上載者:User

Linx監控分享--重點進程監控(mysqld)+寄件提醒

重點進程監控

mysqld:進程退出了,警示。沒有退出則監控mysqld的(cpu(>=100%)|| mem(>=80%))開始提醒,同時收集和分析mysql狀態資訊;串連數(>=max_connections * 0.8)開始提醒;開啟的控制代碼數(>=8192*0.8?)開始提醒。

待完善。。。

如果是單機多執行個體的話,只需要增加一個for迴圈就好了。

在手機上安裝網易的郵件用戶端,就可以達到即時提醒的效果。

#!/bin/shsource /etc/profileIP=`/sbin/ifconfig|sed -n '/inet addr/s/^[^:]*:\([0-9.]\{7,15\}\) .*/\1/p'|grep -v '127.0.0.1'`warn_pct=1 #75warn_name=[mysqld]performance_path=/monitor/performancemailtmp=/u01/soft/smonitor/mailtmplet/"$warn_name"tmp.mailinfotmp=/u01/soft/smonitor/mailtmplet/"$warn_name"tmp.tmpmaillist=490073687@qq.com,zhou.xiangxing210@163.com DT=`date +"%Y-%m-%d %H:%M:%S"`mysqld_pid=`ps -ef|grep  mysqld|grep -E "basedir|datadir" |grep -vE "mysqld_|grep"|awk '{print $2}'`#mysqld_pid=`ps -ef|grep  mysqld|grep -E "basedir|datadir" |grep -vE "mysqld_|grep|mysqld"|awk '{print $2}'`if [ "0" = "0$mysqld_pid" ]then              echo "您好:" >$mailtmp             echo "     [$DT]伺服器:$IP mysqld進程已經退出,請注意。" #>>"$performance_path"/performance_$warn_name_$(date +%Y%m%d).log             echo "     [$DT]伺服器:$IP mysqld進程已經退出,請注意。"  >> $mailtmp                          ps -ef|grep mysql  >>$mailtmp             echo -e "[$DT]$p1" >>$mailtmp             echo -e "\nBest Wishes! \n------------------------------------ \nCA system Monitor \n$DT" >> $mailtmp             cat $mailtmp| mailx -s "$warn_name[警示]:伺服器:$IP" $maillistelse       echo "mysqld_pid=$mysqld_pid"      top -b -n 1 -p  $mysqld_pid >$infotmp      #cpu >= 100% 或者 mem >=80%  ##這裡是約等於      over_pct_flag=`cat $infotmp | grep "^ *[1-9]" | awk '{ if($9 > 99 || $10 > 79) {print 1} else {print 2}}'`      echo "over_pct_flag==$over_pct_flag"      if [ 1 -eq "$over_pct_flag" ]      then             echo "您好:" >$mailtmp             echo "     [$DT]伺服器:$IP mysqld進程CPU和Mem超過警戒值(cpu >= 100% 或者 mem >=80%),請注意。" #>>"$performance_path"/performance_$warn_name_$(date +%Y%m%d).log             echo "     [$DT]伺服器:$IP mysqld進程CPU和Mem超過警戒值(cpu >= 100% 或者 mem >=80%),請注意。"  >> $mailtmp                          echo -e "[$DT]$p1" >>$mailtmp             cat $infotmp  >>$mailtmp             DT=`date +"%Y-%m-%d %H:%M:%S"`             echo -e "\nBest Wishes! \n------------------------------------ \nCA system Monitor \n$DT" >> $mailtmp             cat $mailtmp| mailx -s "$warn_name[警示]:伺服器:$IP" $maillist      fifi

 

寄件提醒


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.