系统运维

检测主机是否存活的shell脚本

vim checkip.sh

#!/bin/bash
# 加载系统函数
. /etc/init.d/functions # centos
#. /lib/lsb/init-functions # ubuntu
CMD="ping -W 2 -c 2"
IP="192.168.31."
for n in `seq 254`;
do
  $CMD $IP$n > /dev/null 2>&1
  if [ $? -eq 0 ];then
    action "$IP$n is online" /bin/true
  else
    action "$IP$n is not online" /bin/false
  fi
done

留言

您的电子邮箱地址不会被公开。 必填项已用*标注

闽ICP备20008591号-1