The fourth embodiment shell 100

A script designed to monitor a remote machine (assuming that is the ip 192.168.208.1) survival of the state, when found down send an email to your own
#### core elements of
ping -c10 192.168.208.1 be determined by ping each other online
email script https://coding.net/u/aminglinux/p/aminglinux-book/git/blob/master/D22Z/mail.py

#### Answers

#! / bin / the bash
n-= ping -c5 192.168.208.1|grep 'packet' |awk -F '%' '{print $1}' |awk '{print $NF}'
IF [the -Z "n-$"]
the then
echo "script problem."
Python mail.py $ m "machine detects a problem viable script $ 0" "acquisition variable is empty,"
Exit
the else
= N1 echo $n|sed 's/[0-9]//g'
IF [-n "n-$"]
the then
echo "script problem."
Python mail.py $ m "machine detects a problem viable script $ 0" "Get value of the variable is not pure digital"
Exit
Fi
Fi

IF br /> [email protected]
the while:
do
IF [$ n--ge 50]
the then
Python mail.py $ m "machine downtime" "n-% packet loss rate is $"
Fi
SLEEP 30
DONE

Guess you like

Origin blog.51cto.com/9447803/2404065