Get current TX / RX speed via script

this is a really simplified script of what I’m trying to do, but the first two lines don’t work, and I can’t figure out how to do a get on this figure… I don’t care if I need to use a few extra lines to pull the tx/rx speeds, I simply can’t figure out how to get just the rx/tx values into variables. Is there another way besides /interface monitor-traffic? the only thing I can think of is /interface ethernet print stats from=ether1 but that doesn’t give current bits per second rate info…

:set ULSP [/interface monitor-traffic ether1 once get rx-bits-per-second]
:set DLSP [/interface monitor-traffic ether1 once get Tx-bits-per-second]
:log info “Current DL speed is $ULSP”
:log info “Current UL speed is $DLSP”

monitor-traffic isn’t an object with items in it, it’s more a script. Try entering the following:

:put (“foo” . [/interface/monitor-traffic 1-WAN] . “bar”)

You will see there is no real item there, just an interactive action.

Unlike total number of bytes, rates are not stored as items inside an object, they are computed on the fly by apps/processes/jobs such as Winbox, the Dude, and monitor-traffic. I don’t even think there’s an SNMP OID for them.

In DUDE, if there is no automatic label on the SNMP monitored link for the TP-link R480T…

RX: [bitrate(round(diff32(oid_raw(“1.3.6.1.2.1.2.2.1.10.5”, 0, 0, “192.168.x.y”, “v1-public”))))]
TX: [bitrate(round(diff32(oid_raw(“1.3.6.1.2.1.2.2.1.16.5”, 0, 0, “192.168.x.y”, “v1-public”))))]

With x.y the IP address

So indeed, you take the counters and calculate the difference over an interval.
Used SNMPwalk in DUDE to find the OID.

For a Mikrotik, DUDE sets it automatically (even for an ethernet interface) to:

[snmp_wireless_link_info()]Rx: [Interface.InBitRate][snmp_wireless_link_rx_rate()]
Tx: [Interface.OutBitRate][snmp_wireless_link_tx_rate()]

there is no DUDE installation here, and unless there’s a way to pull the OID via the MT script that won’t work. the actual goal here is to set a traffic monitor script to perform a web call when traffic throughput exceeds a certain threshold, and if possible include the current mbps ul/dl in the data passed via the fetch command.

I can pull the tx/rx data via the API and that works fine, but I need something that is an outbound push from the router at the time of occurrence, not a inbound pull that looks on a schedule

Sorry only use DUDE existing stuff … not my own scripts.

But still , this might be close:

"Code to check wireless transmit speed:

ros_command(“:put ((([/interface monitor-traffic wlan1 once as-value]->"tx-bits-per-second")/1000)/100);”) "

from: https://wiki.mikrotik.com/wiki/Manual:The_Dude_v6/Charts#Data_sources
Klembord-2.jpg

This this:

:local tx ([/interface get [find name=ether1] tx-byte)

I’m using this for converting to GBs:
:local tx (([/interface get [find name=ether1] tx-byte])/1073741824);

same applies for rx-byte on ether1

or:
:local txp ([/interface ethernet get ether1 driver-tx-byte]);
:local rxp ([/interface ethernet get ether1 driver-rx-byte]);