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<${num};i++))
do
  echo "#--------------------------------------#" >>${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

你可能感兴趣的:(IDC,生产环境,检测IP)