Skip to content


linux 磁盘空间监控脚本 smtp邮件通知

以下内容存成chkdesk.sh

 

#!/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:" sleep 1;echo "rcpt to:" sleep 1;echo "data" sleep 1;echo "From:"disk" " sleep 1;echo "to:"admin" " 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
 ] ; then
gmail         Send_Mail         echo "already suuess send alert message" fi

Posted in shell, 技术.

Tagged with , .


No Responses (yet)

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.