PATH=/usr/local/mysql/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin export PATH if [ $# -lt 2 ] then echo "usage: [mail]" echo -e "example:\n 10.0.153.118 web " exit 1 fi if [ = "10.0.153.126" ] then _ssh="ssh -1" else _ssh=ssh fi
_ip= _mail= _net="TIME_WAIT|ESTABLISHED|LAST_ACK|CLOSING|FIN_WAIT|CLOSE_WAIT|SYN_RECEVED|SYN_SENT" _HOST_TYPE=`$_ssh $_ip -- uname` TMPFILE=/tmp/server.tmp _DATE=`date` Subject="!** ldfsys: $_ip net status Report **!" To="lg@.com" function db { if [ $_HOST_TYPE = "Linux" ] then
_STATUS=`$_ssh $_ip -- netstat -an | grep -iE $_net | awk '{if(~"'$_ip'" && ~/10.0.153.*:3306/) print }' | sed 's#:[0-9]*$##' | sort | uniq -c | sort -r` else _STATUS=`$_ssh $_ip -- netstat -an | grep -iE $_net | awk '{if(~"'$_ip'" && ~/10.0.153.*.3306/) print }' | sed 's#.[0-9]*$##' | sort | uniq -c | sort -r` fi echo -e "From $_ip -->To under DB status:">$TMPFILE echo -e " num DB server list">>$TMPFILE echo -e "$_STATUS">>$TMPFILE
} function web { if [ $_HOST_TYPE = "Linux" ] then _STATUS=`$_ssh $_ip -- netstat -an | grep -iE $_net | awk '{if(~"'$_ip'" && ~/10.0.153.*:3306/) print }' | sed 's#:[0-9]*$##' | sort | uniq -c | sort -r` _STATUS_WEB=`$_ssh $_ip -- netstat -an | grep -iE $_net | awk '{if(~"'$_ip':80") print }' | sed 's#:[0-9]*$##' | sort | uniq -c | sort -r` else _STATUS=`ssh $_ip -- netstat -an | grep -iE $_net | awk '{if(~"'$_ip'" && ~/10.0.153.*.3306/) print }' | sed 's#.[0-9]*$##' | sort | uniq -c | sort -r` _STATUS_WEB=`ssh $_ip -- netstat -an | grep -iE $_net | awk '{if(~"'$_ip'.80") print }' | sed 's#.[0-9]*$##' | sort | uniq -c | sort -r` fi echo -e "From $_ip -->To under DB status:" >$TMPFILE echo -e " num DB server list" >>$TMPFILE echo -e "$_STATUS">>$TMPFILE echo -e "From under server -->To $_ip:80">>$TMPFILE echo -e " num remote server list">>$TMPFILE echo -e "$_STATUS_WEB">>$TMPFILE }
if [ = "db" ] then db else web fi cat $TMPFILE if [ $_mail = "mail" ] >/dev/null 2>&1 then mail -s "$Subject" $To <$TMPFILE fi
PATH=/usr/local/mysql/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin export PATH if [ $# -lt 2 ] then echo "usage: [mail]" echo -e "example:\n 10.0.153.118 web " exit 1 fi if [ = "10.0.153.126" ] then _ssh="ssh -1" else _ssh=ssh fi
_ip= _mail= _net="TIME_WAIT|ESTABLISHED|LAST_ACK|CLOSING|FIN_WAIT|CLOSE_WAIT|SYN_RECEVED|SYN_SENT" _HOST_TYPE=`$_ssh $_ip -- uname` TMPFILE=/tmp/server.tmp _DATE=`date` Subject="!** ldfsys: $_ip net status Report **!" To="lg@.com" function db { if [ $_HOST_TYPE = "Linux" ] then
_STATUS=`$_ssh $_ip -- netstat -an | grep -iE $_net | awk '{if(~"'$_ip'" && ~/10.0.153.*:3306/) print }' | sed 's#:[0-9]*$##' | sort | uniq -c | sort -r` else _STATUS=`$_ssh $_ip -- netstat -an | grep -iE $_net | awk '{if(~"'$_ip'" && ~/10.0.153.*.3306/) print }' | sed 's#.[0-9]*$##' | sort | uniq -c | sort -r` fi echo -e "From $_ip -->To under DB status:">$TMPFILE echo -e " num DB server list">>$TMPFILE echo -e "$_STATUS">>$TMPFILE
} function web { if [ $_HOST_TYPE = "Linux" ] then _STATUS=`$_ssh $_ip -- netstat -an | grep -iE $_net | awk '{if(~"'$_ip'" && ~/10.0.153.*:3306/) print }' | sed 's#:[0-9]*$##' | sort | uniq -c | sort -r` _STATUS_WEB=`$_ssh $_ip -- netstat -an | grep -iE $_net | awk '{if(~"'$_ip':80") print }' | sed 's#:[0-9]*$##' | sort | uniq -c | sort -r` else _STATUS=`ssh $_ip -- netstat -an | grep -iE $_net | awk '{if(~"'$_ip'" && ~/10.0.153.*.3306/) print }' | sed 's#.[0-9]*$##' | sort | uniq -c | sort -r` _STATUS_WEB=`ssh $_ip -- netstat -an | grep -iE $_net | awk '{if(~"'$_ip'.80") print }' | sed 's#.[0-9]*$##' | sort | uniq -c | sort -r` fi echo -e "From $_ip -->To under DB status:" >$TMPFILE echo -e " num DB server list" >>$TMPFILE echo -e "$_STATUS">>$TMPFILE echo -e "From under server -->To $_ip:80">>$TMPFILE echo -e " num remote server list">>$TMPFILE echo -e "$_STATUS_WEB">>$TMPFILE }
if [ = "db" ] then db else web fi cat $TMPFILE if [ $_mail = "mail" ] >/dev/null 2>&1 then mail -s "$Subject" $To <$TMPFILE fi
10.0.153.118 web " exit 1 fi if [ = "10.0.153.126" ] then _ssh="ssh -1" else _ssh=ssh fi
_ip= _mail= _net="TIME_WAIT|ESTABLISHED|LAST_ACK|CLOSING|FIN_WAIT|CLOSE_WAIT|SYN_RECEVED|SYN_SENT" _HOST_TYPE=`$_ssh $_ip -- uname` TMPFILE=/tmp/server.tmp _DATE=`date` Subject="!** ldfsys: $_ip net status Report **!" To="lg@.com" function db { if [ $_HOST_TYPE = "Linux" ] then
_STATUS=`$_ssh $_ip -- netstat -an | grep -iE $_net | awk '{if(~"'$_ip'" && ~/10.0.153.*:3306/) print }' | sed 's#:[0-9]*$##' | sort | uniq -c | sort -r` else _STATUS=`$_ssh $_ip -- netstat -an | grep -iE $_net | awk '{if(~"'$_ip'" && ~/10.0.153.*.3306/) print }' | sed 's#.[0-9]*$##' | sort | uniq -c | sort -r` fi echo -e "From $_ip -->To under DB status:">$TMPFILE echo -e " num DB server list">>$TMPFILE echo -e "$_STATUS">>$TMPFILE
} function web { if [ $_HOST_TYPE = "Linux" ] then _STATUS=`$_ssh $_ip -- netstat -an | grep -iE $_net | awk '{if(~"'$_ip'" && ~/10.0.153.*:3306/) print }' | sed 's#:[0-9]*$##' | sort | uniq -c | sort -r` _STATUS_WEB=`$_ssh $_ip -- netstat -an | grep -iE $_net | awk '{if(~"'$_ip':80") print }' | sed 's#:[0-9]*$##' | sort | uniq -c | sort -r` else _STATUS=`ssh $_ip -- netstat -an | grep -iE $_net | awk '{if(~"'$_ip'" && ~/10.0.153.*.3306/) print }' | sed 's#.[0-9]*$##' | sort | uniq -c | sort -r` _STATUS_WEB=`ssh $_ip -- netstat -an | grep -iE $_net | awk '{if(~"'$_ip'.80") print }' | sed 's#.[0-9]*$##' | sort | uniq -c | sort -r` fi echo -e "From $_ip -->To under DB status:" >$TMPFILE echo -e " num DB server list" >>$TMPFILE echo -e "$_STATUS">>$TMPFILE echo -e "From under server -->To $_ip:80">>$TMPFILE echo -e " num remote server list">>$TMPFILE echo -e "$_STATUS_WEB">>$TMPFILE }
if [ = "db" ] then db else web fi cat $TMPFILE if [ $_mail = "mail" ] >/dev/null 2>&1 then mail -s "$Subject" $To <$TMPFILE fi