#!/bin/bash
#
# ip_check This shell script takes care of checking all IPAddress.
#
# Create by Xuekun
# date 2015-12-6
# Beijing Open Source
# 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} < br> Else
echo "10.150.33.${i}" >>${DOWN_IP_LIST}
fi
Done
This article is from the "Beijing Open source people Linux operation and Maintenance" blog, please be sure to keep this source http://76543211234567.blog.51cto.com/7961566/1769091
IDC production environment detects if IP is in use in shell scripts