sms при липса на ping

Един много полезен скрипт който следи дадени хостове или ip адреси и при отпдането им изпраща email. Благодарение на услугата mail2sms на mtel се модифицира до напомяне по телефона.

#!/bin/bash
# Simple SHELL script for Linux and UNIX system monitoring with
# ping command
# -------------------------------------------------------------------------
# Copyright (c) 2006 nixCraft project <http://www.cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
# Setup email ID below
# See URL for more info:
# http://www.cyberciti.biz/tips/simple-linux-and-unix-system-monitoring-with-ping-command-and-scripts.html
# -------------------------------------------------------------------------

# add ip / hostname separated by white space
HOSTS="dir.bg 192.168.0.1"

# no ping request
COUNT=1

# email report when
SUBJECT="HostDown"
EMAILID="359xxxxxxxxx@sms.mtel.net"
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 at $(date)" | mail -s "$SUBJECT" $EMAILID
  fi
done
С етикет: , , , , , ,
Публикувано в linux, Без категория

Вашият коментар

Вашият имейл адрес няма да бъде публикуван.

*