xy123321 发表于 2018-8-28 08:38:16

IDC生产环境检测IP是否在用的Shell脚本

  #!/bin/bash
  #
  # ip_check    This shell script takes care of checking all ipaddress.
  #
  # create by xuekun
  # date 2015-12-6
  # 北京开源人
  # Source function library.
  . /etc/rc.d/init.d/functions
  APP_PATH=`pwd`
  LOG_PATH=${APP_PATH}/ip_check.log
  UP_IP_LIST=${APP_PATH}/up_ip_list.log
  DOWN_IP_LIST=${APP_PATH}/down_ip_list.log
  #init log file
  >${LOG_PATH}
  >${UP_IP_LIST}
  >${DOWN_IP_LIST}
  #judge arg
  #num ip range
  num=${1}
  #main
  for((i=1;i>${LOG_PATH}
  ping 10.150.33.${i} -c 3 >>${LOG_PATH}
  if [[ $? -eq 0 ]];then
  echo "10.150.33.${i}" >>${UP_IP_LIST}
  else
  echo "10.150.33.${i}" >>${DOWN_IP_LIST}
  fi
  done

页: [1]
查看完整版本: IDC生产环境检测IP是否在用的Shell脚本