Linx監控分享--磁碟空間監控+寄件提醒

來源:互聯網
上載者:User

Linx監控分享--磁碟空間監控+寄件提醒

分享第一個監控指令碼,掛載點磁碟空間使用監控:如果使用空間達到了75%則開始警示,發送警示郵件。

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

 

#!/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=70warn_name=[磁碟]performance_path=/monitor/performancemailtmp=/u01/soft/smonitor/mailtmplet/disktmp.mailmaillist=490073687@qq.com,zhou.xiangxing210@163.comtt=`df  -h|awk '{print $6 "," $2 ","$5","$3","$4 }' |tr '\n' ' '`DT=`date +"%Y-%m-%d %H:%M:%S"`#echo $ttOLD_IFS="$IFS"IFS=" "arr=($tt)IFS="$OLD_IFS"for i in "${!arr[@]}"do         #echo  "$i"   "${arr[$i]}"    if [ $i -ge 1  ]    then        #echo "$i" "${arr[$i]}"disk_pct=`echo "${arr[$i]}"|awk -F',' '{print $3}' | cut -f 1 -d "%"`        #echo "disk_pct=$disk_pct   warn_pct=$warn_pct"if [ $disk_pct -ge $warn_pct ]        #if [ $disk_pct -ge 70 ]then             echo "您好:" >$mailtmp             echo "     [$DT]伺服器:$IP 磁碟: ${arr[$i]} 使用率已經達到$warn_pct%,請及時處理。" #>>"$performance_path"/performance_disk_$(date +%Y%m%d).log             echo "     [$DT]伺服器:$IP 磁碟: ${arr[$i]} 使用率已經達到$warn_pct%,請及時處理。 "  >> $mailtmp                          pp=${tt// /\\n}              echo -e $pp >>$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" $maillistfi    fidone

寄件提醒效果

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.