Sie sind auf Seite 1von 2

##################################################

##
## Redes Brasil - Especializada em treinamentos de redes.
##
## www.redesbrasil.com
##
##################################################

########### Altere conforme sua necessidade ################


:global iptest 10.7.7.120
:global latenciAceitavel 30
:global tempoEntrePings 2
:global NumPings 5

##################################################

:global msg
:global status
:global oldstatus $status
:global somaLatencia 0
:global somaRecebidos 0
##################################################

for i from=1 to=$NumPings do={


/tool flood-ping $iptest size=100 count=1 do={
:if ($received = 1) do={
:set somaLatencia ($somaLatencia + $"avg-rtt")
}
:set somaRecebidos ($somaRecebidos + $received)
}
delay $tempoEntrePings
}

#################################### AÇOES TOMADA SE HOST ESTIVER FORA DE ALCANCE


#############################
:if ($somaRecebidos = 0 ) do={
:global status "HOST $iptest FORA DE ALCANCE"
:if ($oldstatus = $status) do={quit} else={

:log warning $status


:global msg
/system script run envia-email
quit
}
}

#################################### CALCULA LATENCIA E PERDA DE PACOTES


#############################

:global media ($somaLatencia/$somaRecebidos)


:global percaPacotes (100 - (($somaRecebidos * 100) / $NumPings))

:global msg ("Média de PING para o IP $iptest foi de ".[:tostr $media]."ms e PERDA
DE PACOTES foi de ". [:tostr $percaPacotes]."%. Foram ".$NumPings." PINGs enviados
e ".$somaRecebidos." recebidos.")
#################################### AÇOES TOMADA SE A LATENCIA ESTIVER ABAIXO OU
ACIMA DO ESPECIFICADO #############################
:if ($media < $latenciAceitavel ) do={
:global status "LATENCIA OK"
:if ($oldstatus = $status) do={quit} else={

:log warning $msg


:log warning $status
/system script run envia-email

}
} else={
:global status "LATENCIA TA UMA MERDA"
:if ($oldstatus = $status) do={quit} else={

:log error $msg


:log error $status
/system script run envia-email

Das könnte Ihnen auch gefallen