1 Star 2 Fork 1

hxsaj/tools_shell

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
monitornet.sh 879 Bytes
一键复制 编辑 原始数据 按行查看 历史
gohou 提交于 2024-01-31 20:53 . 新修改删除共享的函数
#!/bin/sh
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/hadoop/bin:/root/bin:/usr/bin:/usr/sbin:/sbin:/bin:.
export LC_ALL=en_US.UTF-8
umask 0022
logdir=$1
hostlist=$2
# avoid ping outside website and localhost
ping_host_list=$(cat /etc/hosts|grep "^[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*"|grep -v '127.0.0.1'|grep -v "com\|net\|org\|cn\|gov\|org\|biz\|top\|pub\|info\|edu\|int\|pro\|name\|mil$" | head -n 8)
if [ "x${hostlist}" != "x" ];then
# read ping host from file
if [ -f ${hostlist} ]; then
ping_host_list=$(cat ${hostlist})
fi
fi
echo "${ping_host_list}" | while read line
do
ip=$(echo $line|awk '{print $1}')
host=$(echo $line|awk '{print $2}')
if [ "x${ip}" != "x" ] && [ "x${host}" != "x" ]; then
logname=${logdir}/ping_${ip}_${host}.log.$(date '+%Y%m%d')
nohup ping -D -W 1 ${ip} >> ${logname} 2>&1 &
fi
done
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/hxsaj/tools_shell.git
git@gitee.com:hxsaj/tools_shell.git
hxsaj
tools_shell
tools_shell
master

搜索帮助