以下内容存成chkdesk.sh
<coolcode>
#!/bin/bash DISKUSAGE=$(df -h |awk -F " " '{print $5}'|sort -n -r|sed -n '1s/[^0-9]//p') DIR=$(df -h |awk -F " " '{print $5,$1}' |sort -nr|awk -F " " 'NR==1 {print $2}') NUM=80 (定义的磁盘非分比) function Send_Mail { (sleep 2;echo "helo localhost" sleep 1;echo "auth login" sleep 1;echo "YW5keQ==" (base64后的用户名) sleep 1;echo "MTIzNDU2" (base64后的密码) sleep 1;echo "mail from:<[email protected]>" sleep 1;echo "rcpt to:<[email protected]>" sleep 1;echo "data" sleep 1;echo "From:"disk" <[email protected]>" sleep 1;echo "to:"admin" <[email protected]>" sleep 1;echo "Subject:your web01 disk directory $DIR is full" sleep 1;echo "Content-Type:text/plain;" sleep 1;echo "Content:" sleep 1;echo "web01 disk directory $DIR is full" sleep 1;echo "." sleep 1;echo "quit")| telnet 192.168.1.1 25 >/dev/null 2>&1 } if [ $DISKUSAGE -ge $NUM ] ; thengmail Send_Mail echo "already suuess send alert message" fi
</coolcode>
No Responses (yet)
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.