vim/etc/mail.rc AddSet from=******@163.com smtp=smtp://smtp.163.com:25set smtp-auth-user=******@163.com smtp-auth-password=****** smtp-auth=loginVim check.sh#!/bin/bashsource. Bash_profilepip=101.251.251.92ip= '/sbin/ifconfig eth0 | grep "inet addr" | awk ' {print $} ' | awk-f: ' {print $} 'i= ' ps-ef | grep freeswitch | grep-v grep | wc-l 'date= ' Date 'cpu= ' top-b-N 1 | grep CPU | awk ' {print $} ' | cut-f 1-d "%" 'ping= ' ping-c 3 $pip |awk ' nr==7 {print $4} '
if [$ping-eq 0] Thentext2= "$pip status grashed"Elsetext2= "$pip status Ready"fiif [$i-lt 1] Thentext= ' Freeswitch is down 'echo "Server:" $ip $ ' \ n ' $date $ ' \ n ' "CPU used:" $cpu $ ' \ n ' "$text 2" $ ' \ n ' "$text" | mail-s "$ip Abnormal"-a/home/freeswit Ch/log/freeswitch.log ****** @qq. com#else#text = ' Freeswitch is running ... '#echo "Server:" $ip $ ' \ n ' $date $ ' \ n ' "CPU used:" $cpu $ ' \ n ' "$text 2" $ ' \ n ' "$text" | mail-s "$ip Normal" ****** @qq. com fi
set 8-23 points per day to automatically execute scripts to send messages every hourcrontab-e0 8-23 * * */root/check.sh
Server auto-Send mail monitor FreeSWITCH process