Monitoring Script

I would like to know if it’s possible to create a script using netwatch or something similar that would ping all devices on my network, and send me an email if any of the devices goes up or down. Maybe it would try to ping several times before sending the email. I would like it to use the comments in the subject and body of the email for identification. For example, if I have a static ip on a lan device with a comment of “printer”, the email would say something like:

“Printer is down”

Is this possible?

Thanks.

Any input from anyone?

you can use Dude to do it.

So how we get output?? I am still in a fix for it’s implementations… Is there any other alternatives of it?

use this: http://forum.mikrotik.com/t/dude-email-notifications-through-gmail-on-windows-via-blat/28399/1
I use this over one year and email comes to me when each device is up or down.

I use this

My warring log I set to action email so I get mailed for warning log entries

The address list entry should look like this

add address=10.0.0.175 comment=wcsnet-ps1*100 list=“router ping”


:global scriptemail
:global lastping

:local content
:local checkip
:local checklaststatus
:local checknewstatus
:local checkcomment

:local difference

:local list
:local alerts 0

:log info “******************** starting - ip ping report********************”
:log info “-”

:foreach i in=[/ip firewall address-list find] do={

:set list ([/ip firewall address-list get $i list] )
:if ($list = “router ping”) do={

:set checkip ([/ip firewall address-list get $i address] )
:set content ([/ip firewall address-list get $i comment] )

:if ([:find $content “*”] != “”) do={

:local pos1 [:find $content “*”]
:local pos2 [:len $content]

:set checklaststatus ([:pick $content ($pos1+1) $pos2])
:set checkcomment ([:pick $content 0 ($pos1)])

:local perc ([/ping $checkip count=10] * 10)

:set checknewstatus “$perc”

:set difference (checknewstatus - $checklaststatus)

:if ($difference < 0) do={
:set difference ($difference * -1)
} else={
:set difference ($difference * 1)
}

:if (difference >= 50 ) do={
/ip firewall address-list set $i comment=“$checkcomment*$checknewstatus”
:set alerts ($alerts + 1)

:log warning “$[/system identity get name] connectively test state changed [ $checkcomment ] $checklaststatus → $checknewstatus state difference: $difference”

}

}
}
}

:set lastping “$[/system clock get date] $[/system clock get time]”

:log info “******************** ending - ip ping report ********************”

Do you need to be on a certain os for this to work?

Can you explain exactly what this does?

Thanks.

nice

This script does not work. I’m on 6.19. When I paste it in, there are errors.

This is a newer version it runs on 6.25

For this to work you have to add address list items and then these are pinged
Example:
/ip firewall address-list
add address=8.8.8.8 comment=“google dns1*100” list=“router ping”

The comment field is used to store the ping result as well as a friendly name

wcsnet, copyright © 2010. all rights reserved

script version : 1.0

:do {

:global lastping

:local content

:local checkip
:local checklaststatus
:local checknewstatus
:local checkcomment

:local difference

:log info “******************** starting - ip ping report********************”
:log info “-”

:foreach i in=[/ip firewall address-list find list=“router ping” and disabled=no] do={

:set checkip ([/ip firewall address-list get $i address] )
:set content ([/ip firewall address-list get $i comment] )

:if ([:find $content “*”] != “”) do={

:local pos1 [:find $content “*”]
:local pos2 [:len $content]

:set checklaststatus ([:pick $content ($pos1+1) $pos2])
:set checkcomment ([:pick $content 0 ($pos1)])

:local perc ([/ping $checkip count=10] * 10)

:set checknewstatus “$perc”

:set difference (checknewstatus - $checklaststatus)

:if ($difference < 0) do={
:set difference ($difference * -1)
} else={
:set difference ($difference * 1)
}

/ip firewall address-list set $i comment=“$checkcomment*$checknewstatus”

:if (difference >= 50 ) do={

:log warning “$[/system identity get name] connectively test state changed [ $checkcomment ] $checklaststatus → $checknewstatus state difference: $difference”

}
}
}

:set lastping “$[/system clock get date] $[/system clock get time]”

:log info “******************** ending - ip ping report ********************”


} on-error={
:log error “script failure [ ip - ping ]”
}

Can the script be modified to to look at the static ip address table rather than the firewall?

Any answer on this? I would like to use the static ip address table, not the firewall table to run the script.

What do you mean by static ip address table?


Sent from my iPhone using Tapatalk

The firewall address list items that aren’t dynamic is static


Sent from my iPhone using Tapatalk

by static ip’s I mean from the dhcp table. Any address that is static in the dhcp table.

Yep you can do that but remember only static leases has a comment filed which i use in the acrip


Sent from my iPhone using Tapatalk

The get value might also be different for dhcp leases


Sent from my iPhone using Tapatalk

Use the Dude. Its classic.

Can you set up the dude on a remote server and monitor multiple sites at once?

Yes, it is possible. You just need to reach the devices you want to monitor.