IDC生产环境检测IP是否在用的Shell脚本
2016-04-29 18:35
579 查看
#!/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
本文出自 “北京开源人Linux运维实战” 博客,请务必保留此出处http://bdkyr.blog.51cto.com/7961566/1769091
#
# 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
本文出自 “北京开源人Linux运维实战” 博客,请务必保留此出处http://bdkyr.blog.51cto.com/7961566/1769091
相关文章推荐
- Windows的cmd终端连接android手机运行adb shell脚本命令
- -bash: pod: command not found
- 关于node.js配置 Git Bash中node-v 显示command not found
- Shell数组的增删改查
- Linux系统的负载与CPU、内存、硬盘、用户数监控的shell脚本
- PowerShell Remove all user defined variable in PowerShell
- shell中date做循环变量,以及date简单解析
- linux shell 变量
- mysql shell 查看 所有用户的 授权列表
- shell调用sftp实现自动批量上传or下载
- 【Linux】执行shell脚本出现异常:bad interpreter: No such file or directory如何解决
- 关于PowerShell中的OutputType方法属性
- shell参数扩展
- shell参数扩展
- Linux命令 + Shell
- shell script笔记
- shell中不可不知的叹号
- Shell编程基础
- shell数组处理
- shell数组处理