Community discussions

MikroTik App
 
tabate47
Long time Member
Long time Member
Topic Author
Posts: 510
Joined: Wed Mar 13, 2013 5:23 am
Location: Los Angeles

Monitoring Script

Sun Dec 15, 2013 6:16 am

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.
 
tabate47
Long time Member
Long time Member
Topic Author
Posts: 510
Joined: Wed Mar 13, 2013 5:23 am
Location: Los Angeles

Re: Monitoring Script

Mon Dec 16, 2013 5:50 am

Any input from anyone?
 
User avatar
nick3dos
Member Candidate
Member Candidate
Posts: 189
Joined: Fri Apr 29, 2011 11:03 pm
Location: Greece

Re: Monitoring Script

Mon Dec 16, 2013 9:33 am

you can use Dude to do it.
 
EdwardKayle
just joined
Posts: 1
Joined: Mon Dec 16, 2013 9:43 am

Re: Monitoring Script

Mon Dec 16, 2013 9:49 am

So how we get output?? I am still in a fix for it's implementations.... Is there any other alternatives of it?
 
User avatar
nick3dos
Member Candidate
Member Candidate
Posts: 189
Joined: Fri Apr 29, 2011 11:03 pm
Location: Greece

Re: Monitoring Script

Mon Dec 16, 2013 12:09 pm

use this: http://forum.mikrotik.com/viewtopic.php ... dude+gmail
I use this over one year and email comes to me when each device is up or down.
 
wcsnet
Frequent Visitor
Frequent Visitor
Posts: 64
Joined: Mon Apr 29, 2013 12:43 pm
Location: South Africa

Re: Monitoring Script

Wed Jul 30, 2014 11:40 am

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 ********************"
 
tabate47
Long time Member
Long time Member
Topic Author
Posts: 510
Joined: Wed Mar 13, 2013 5:23 am
Location: Los Angeles

Re: Monitoring Script

Wed Jul 30, 2014 3:27 pm

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

Can you explain exactly what this does?

Thanks.
 
sc0tt
just joined
Posts: 15
Joined: Thu Sep 25, 2014 5:34 am

Re: Monitoring Script

Sat Oct 04, 2014 3:12 pm

nice
 
tabate47
Long time Member
Long time Member
Topic Author
Posts: 510
Joined: Wed Mar 13, 2013 5:23 am
Location: Los Angeles

Re: Monitoring Script

Sat Oct 04, 2014 5:06 pm

This script does not work. I'm on 6.19. When I paste it in, there are errors.
 
wcsnet
Frequent Visitor
Frequent Visitor
Posts: 64
Joined: Mon Apr 29, 2013 12:43 pm
Location: South Africa

Re: Monitoring Script

Tue Feb 03, 2015 11:11 am

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 ]"
}
 
tabate47
Long time Member
Long time Member
Topic Author
Posts: 510
Joined: Wed Mar 13, 2013 5:23 am
Location: Los Angeles

Re: Monitoring Script

Tue Feb 17, 2015 12:35 am

Can the script be modified to to look at the static ip address table rather than the firewall?
 
tabate47
Long time Member
Long time Member
Topic Author
Posts: 510
Joined: Wed Mar 13, 2013 5:23 am
Location: Los Angeles

Re: Monitoring Script

Sun Feb 22, 2015 11:52 pm

Any answer on this? I would like to use the static ip address table, not the firewall table to run the script.
 
wcsnet
Frequent Visitor
Frequent Visitor
Posts: 64
Joined: Mon Apr 29, 2013 12:43 pm
Location: South Africa

Monitoring Script

Wed Jun 03, 2015 8:13 pm

What do you mean by static ip address table?


Sent from my iPhone using Tapatalk
 
wcsnet
Frequent Visitor
Frequent Visitor
Posts: 64
Joined: Mon Apr 29, 2013 12:43 pm
Location: South Africa

Monitoring Script

Wed Jun 03, 2015 8:14 pm

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


Sent from my iPhone using Tapatalk
 
tabate47
Long time Member
Long time Member
Topic Author
Posts: 510
Joined: Wed Mar 13, 2013 5:23 am
Location: Los Angeles

Re: Monitoring Script

Thu Jun 04, 2015 4:31 am

by static ip's I mean from the dhcp table. Any address that is static in the dhcp table.
 
wcsnet
Frequent Visitor
Frequent Visitor
Posts: 64
Joined: Mon Apr 29, 2013 12:43 pm
Location: South Africa

Monitoring Script

Thu Jun 04, 2015 10:31 am

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
 
wcsnet
Frequent Visitor
Frequent Visitor
Posts: 64
Joined: Mon Apr 29, 2013 12:43 pm
Location: South Africa

Monitoring Script

Thu Jun 04, 2015 10:32 am

The get value might also be different for dhcp leases


Sent from my iPhone using Tapatalk
 
TomosRider
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Nov 20, 2014 1:51 pm

Re: Monitoring Script

Fri Jun 05, 2015 10:38 am

Use the Dude. Its classic.
 
tabate47
Long time Member
Long time Member
Topic Author
Posts: 510
Joined: Wed Mar 13, 2013 5:23 am
Location: Los Angeles

Re: Monitoring Script

Fri Jun 05, 2015 6:05 pm

Can you set up the dude on a remote server and monitor multiple sites at once?
 
jarda
Forum Guru
Forum Guru
Posts: 7756
Joined: Mon Oct 22, 2012 4:46 pm

Fri Jun 05, 2015 6:12 pm

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

Who is online

Users browsing this forum: No registered users and 10 guests