Hello everyone, I have this script that he does a test for an ip, if he is off he disables the interface if he is on he activates the interface.
So far so good, this is a sample script, what I’m actually going to use is to send email. The problem is that if he checked and the ip is working, he sends me an email, in the next execution if he is online he sends me another email and so on.
I would like to make it so that it only sends an email when the ping stops working and only sends me an email again when the link returns and the opposite is the same thing. That is, just an email that fell and another email that came back, not one each time it runs, could someone help me.
:global IPsParaTeste "10.0.0.187"
:global Intervalo 00:00:00.5
:global EstadoAnterior 0
:local PingResponse [/ping count=1 interval=$Intervalo $IPsParaTeste]
:if ($PingResponse = 0) do={
:if ($EstadoAnterior = 1) do={
/interface ethernet disable ether1
}
:set EstadoAnterior 0
} else {
:if ($EstadoAnterior = 0) do={
/interface ethernet enable ether1
}
:set EstadoAnterior 1
}