Community discussions

 
User avatar
tomasi
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 71
Joined: Fri Oct 03, 2014 6:40 pm
Location: Brazil
Contact:

Alerts based on throughput threshold

Mon Sep 11, 2017 5:09 am

Hi,

Is it possible to generate alerts based on throughput thresholds?

e.g.: my upstream providers give us 1 Gbps each one.
I want to receive alerts when traffic is too high or low.

:D
 
User avatar
jspool
Member
Member
Posts: 389
Joined: Sun Oct 04, 2009 4:06 am
Location: Oregon

Re: Alerts based on throughput threshold

Mon Sep 11, 2017 5:31 am

Hi,

Is it possible to generate alerts based on throughput thresholds?

e.g.: my upstream providers give us 1 Gbps each one.
I want to receive alerts when traffic is too high or low.

:D
/tool traffic-monitor
https://wiki.mikrotik.com/wiki/Manual:T ... ic_Monitor
http://bfy.tw/Dr12

Just setup a script to email you and place it in the "on event"

https://wiki.mikrotik.com/wiki/Manual:Tools/email
 
User avatar
tomasi
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 71
Joined: Fri Oct 03, 2014 6:40 pm
Location: Brazil
Contact:

Re: Alerts based on throughput threshold

Tue Sep 12, 2017 8:36 pm

Thank you! This tool helps a lot :)

The only problem I see is:
the tool doesn't have a delay parameter to avoid congestion of alerts.

I've tried to generate a warning log every time interface traffic crosses thresholds (above 960M or below 1M).
The logs were generated correctly, but my Slack channel was overflowed.

Is there a way to improve the usage of this tool?
Which method do you use to send alerts to smartphone when traffic crosses these thresholds?

:D
 
User avatar
jspool
Member
Member
Posts: 389
Joined: Sun Oct 04, 2009 4:06 am
Location: Oregon

Re: Alerts based on throughput threshold

Tue Sep 12, 2017 9:42 pm

With scripting on Mikrotik's you can generally accomplish anything if you are willing to dive in and experiment a bit.

Just off the top of my head - Probably could do better with more time
You could place the following in your monitor script area:
Add your alerting code where indicated or call a script whatever method you prefer.

This code will check to see if it has already ran and if so it will discard the alert until the global variable is set to "Normal"
If the global is "Normal" and the bandwidth alert is triggered after executing will set the global to "Alerting" thus preventing additional runs until the scheduler makes its rotation and resets the global to "Normal" thus enabling alerts again.
:global lastbwStatus

# check to see if global exists and if not create default value
:if (($lastbwStatus != "Normal") && ($lastbwStatus != "Alerting")) do={
:set $lastbwStatus Normal
}

# check to see if it has already alerted this cycle & if so discard alert
:if ($lastbwStatus = "Normal") do={
# alert script here
:log warning "Bandwidth Alert"
:set $lastbwStatus Alerting
} else={
:log info "System already has already alerted - discarding alert"
}

Now you can run system scheduler at the desired interval to clear the "Alerting" status and enable another alert.
/system scheduler
add interval=15m name=Bandwidth-Alerting-Interval on-event=":global lastbwStatus\r\
    \n:set \$lastbwStatus Normal;" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon start-time=startup
 
User avatar
LatinSuD
Member Candidate
Member Candidate
Posts: 174
Joined: Wed Jun 29, 2005 1:05 pm
Location: Spain
Contact:

Re: Alerts based on throughput threshold

Wed Apr 17, 2019 3:13 pm

It does not work on 6.39.2

Nor does this:
https://wiki.mikrotik.com/wiki/Manual:S ... imitations

Who is online

Users browsing this forum: No registered users and 5 guests