#!/bin/bash
ip_list=/opt/shell/ip.txt
email=xxxxx@163.com
status_log=/opt/shell/status.log
sendmail (){
       echo " ---------------- `date  +%F_%H:%M` ------------------
              主机:$1  无法访问
                                            " > $status_log
       mail -s "主机状态"  $email < $status_log
}

  for i in `cat "$ip_list"`
  do
    host_status=`nmap -n -sn $i|grep -wc 'Host is up'`
    if [ $host_status -eq 0 ];then
       sendmail $i
    fi
  done

 

相关文章:

  • 2021-11-29
  • 2022-01-19
  • 2021-12-01
  • 2022-12-23
  • 2022-02-04
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
猜你喜欢
  • 2021-11-26
  • 2021-08-22
  • 2022-02-05
  • 2021-06-28
  • 2022-12-23
  • 2022-12-23
  • 2022-01-12
相关资源
相似解决方案