利用shell脚本监控公司内网机器
# cat check_ip_all.sh#!/bin/bash
BASE=/root/sh
for ip in `cat $BASE/iplist.txt`
do
ping $ip -c 2 > /dev/null 2>&1
if [ ! $? -eq 0 ];then
echo "The company server $ip down,please solved the problem as soon as possible!" > /root/sh/mail.txt
mail -s "The server $ip is down now"shifeng_zhang88@163.com< /root/sh/mail.txt
fi
done
#添加crontab,每2分钟自动检测
*/5 * * * * /bin/bash /root/sh/check_ip_all.sh > /dev/null 2>&1
页:
[1]