pingping – Verificando conexão com servidores.

25 Jun

Above is my pingping script. This script send a mail alert when some server stop, based on regular ICMP requests. Read it!

# This script send ICMP requests for each server on SERVIDORES list and sends
# emails for emails in LISTA_EMAILS list why one of servers doesn't reply
# You only receive alerts if in last time that script request server we have a success reply
# or if we not tested server yet.
# Author: Felipe Rafael Prenholato -
# IRC: nick chronos at
# Date: 21 de Junho de 2006.
# This script is under GPLv2. Read it at
# Any changes please send me a mail :).

# IP or name of servers to test
SERVIDORES="elise prime odissey"

# emailo to send alerts

# date format to send in email
data=$(date +"%T de %d/%m/%Y")

# this function sends ping
ping_server() {

local pingreturn
local serversts
local server


# Debug
#echo "Server: $server"
#echo "Temp file: $TMPFILE"

# ping and get return
ping -c3 $server &>/dev/null;

# 0 means ok
if [ "$pingreturn" == "0" ]
echo "1" > $TMPFILE

# 1 means problems
if [ "$pingreturn" == "1" ]

if ! [ -e $TMPFILE ]
echo "1" > $TMPFILE

serversts=$(cat $TMPFILE)

# send mail if have problems
if [ "$serversts" == "1" ]

echo "0" > $TMPFILE
msg="Servidor $server fora do ar em $data. Contatar responsavéis."
ass="Servidor $server fora do ar."
LC_ALL="en_US.ISO-8859-1" echo "$msg" | mail -s "$ass" $LISTA_EMAILS



# roda ping_server para cada servidor.
for e in $(echo $SERVIDORES);
ping_server $e;

Install this script in one server that can send ICMP requests to servers in lists. Very old versions of postfix doesn’t works because this script needs -a option in mail command. Use as:


Run in cron and have peace 😀

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)

One Response to “pingping – Verificando conexão com servidores.”

  1. Leandro Miranda November 28, 2008 at %I:%M %p #

    Precisa de algum serviço instalado no servidor para que o email seja enviado, fiz modificaçao no script somente do ip do servidor e dos emails e não ta enviando email, e eu ja tentei muitas coisas, inclusive ja mudei as permiçoes do script com o chmod +x script

    se tiver como me da uma luz favor responde ai.. abraço e otimo post…

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)

Leave a Reply