1、安装方式
wget http://10.8.225.126/wsmonitor/install.sh;sh install.sh test@test.com
2、install.sh
#!/bin/sh if [ $# -ne 1 ]; then echo "########################################################" echo "# 用法:sh install_monitor.sh 邮箱地址; #" echo "# 如:sh install_monitor.sh chenjy@wangsu.com #" echo "# 若邮箱地址多个用英文逗号分隔 #" echo "########################################################" exit 1 fi #对应目录放开权限,安装sendmail /usr/bin/chattr -i /etc/shadow /etc/passwd /etc/gshadow /etc/group /etc/group- mkdir /var/spool/clientmqueue;chmod 777 /var/spool/clientmqueue for i in `seq 1 3` do echo $i rpm -q --quiet sendmail if [ $? == 1 ]; then yum install -y sendmail if [ $? == 1 ]; then echo "######ERROR!sendmail install fail!######" echo "######Please try [yum install -y sendmail]######" exit fi fi rpm -q --quiet sendmail if [ $? == 0 ]; then service sendmail restart if [ $? == 1 ]; then echo "######ERROR!sendmail start fail!######" echo "######Please try [service sendmail restart]######" exit fi chkconfig --add sendmail break fi done #下载监控脚本及启动后台执行 current=`date "+%Y-%m-%d %H:%M:%S"` timestamp=`date -d "$current" +%s` mkdir -p /usr/local/wsmonitor mkdir -p /usr/local/wsmonitor/bak for i in `seq 1 3` do echo $i # if [ -f wsmonitor.sh ];then # mv /usr/local/wsmonitor/wsmonitor.sh /usr/local/wsmonitor/bak/wsmonitor.sh.$timestamp # fi wget http://10.8.225.126/wsmonitor/wsmonitor.sh -O /usr/local/wsmonitor/wsmonitor.sh wget http://10.8.225.126/wsmonitor/wsmonitor -O /etc/init.d/wsmonitor wget http://10.8.225.126/wsmonitor/ReadMe_wsmonitor.txt -O /usr/local/wsmonitor/ReadMe_wsmonitor.txt #替换监控脚本中的邮箱地址 sed -i 's/MAILTO=chenjy@wangsu.com/MAILTO='$1'/g' /usr/local/wsmonitor/wsmonitor.sh #启动服务 chmo