#!/bin/bash
# Simple SHELL script for Linux and UNIX system monitoring with
# ping command
# add ip / hostname separated by while space
HOSTS="host-ip"
# no ping request
COUNT=1
# email report when
SUBJECT="Ping failed"
EMAILID=""
for myHost in $HOSTS
do
count=$(ping -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
if [ $count -eq 0 ]; then
# 100% failed
echo "Host : $myHost is down (ping failed) at $(date)" | mail -s "$SUBJECT" $EMAILID
else
echo "$1 is up "
fi
done
阅读(1394) | 评论(1) | 转发(0) |