The traffic monitor tool is used to execute console scripts on when interface traffic crosses some given thresholds.
For details on scripting, consult respective manual
Traffic monitor feature is included in the 'system' package. No installation is needed for this feature
There is no other significant resource usage.
Each item in traffic monitor list consists of its name (which is useful if you want to disable or change properties of this item from another script), some parameters specifying traffic condition and the pointer to a script or scheduled event to execute when this condition is met.
Events (monitor items) are managed under tool traffic-monitor submenu:
[admin@MikroTik] tool> traffic-monitor print Flags: X - disabled, I - invalid # NAME INTERFACE TRAFFIC TRIGGER THRESHOLD ON-EVENT 0 turn_on ether1 received above 15000 eth-up 1 turn_off ether1 received below 12000 eth-down
Argument description for traffic monitoring tool:
name - Name of traffic monitor item
interface - Interface to monitor
threshold - Traffic threshold, in bits per second
trigger - Condition on which to execute script (above, always, below)
traffic - Type of traffic to monitor (transmitted, received)
on-event - Script source. Must be present under /system script
You should specify the interface on which to monitor the traffic, the type of traffic to monitor (transmitted or received), the threshold (bits per second). The script is started, when traffic exceeds the threshold in direction given by the trigger argument. above means that script will be run each time traffic exceeds the threshold, i.e. goes from being less than threshold to being more than threshold value. below triggers script in the opposite condition, when traffic drops under the threshold. always triggers script on both above and below conditions.
The example monitor enables the interface ether2, if the received traffic exceeds 15kbps on ether1, and disables the interface ether2, if the received traffic falls below 12kbps on ether1.
[admin@MikroTik] system script> add name=eth-up source={/interface enable ether2}
[admin@MikroTik] system script> add name=eth-down source={/interface disable ether2}
[admin@MikroTik] system script> /tool traffic-monitor
[admin@MikroTik] tool traffic-monitor> add name=turn_on interface=ether1 \
\... on-event=eth-up threshold=15000 trigger=above traffic=received
[admin@MikroTik] tool traffic-monitor> add name=turn_off interface=ether1 \
\... on-event=eth-down threshold=12000 trigger=below traffic=received
[admin@MikroTik] tool traffic-monitor> print
Flags: X - disabled, I - invalid
# NAME INTERFACE TRAFFIC TRIGGER THRESHOLD ON-EVENT
0 turn_on ether1 received above 15000 eth-up
1 turn_off ether1 received below 12000 eth-down
[admin@MikroTik] tool traffic-monitor>