Skip to content

Instantly share code, notes, and snippets.

@njumaen
Created October 27, 2024 14:41
Show Gist options
  • Save njumaen/d4ce3c0f4d67d86ec0f21979dbf1dcde to your computer and use it in GitHub Desktop.
Save njumaen/d4ce3c0f4d67d86ec0f21979dbf1dcde to your computer and use it in GitHub Desktop.
Mikrotik Scripts
This is a collection of quite useful, at least for me, of mikrotik scripts
@njumaen
Copy link
Author

njumaen commented Oct 27, 2024

Exaple code: Collect some data and send it to my mqtt broker

:local num [/interface/wifiwave2/registration-table/print count-only as-value] 
/iot/mqtt/publish broker=njumqtt topic=mikrotik/router/wifi/clientsconnected message="$num" retain=yes

# show on awrtix
/iot/mqtt/publish broker=njumqtt topic=awtrix_b9315c/custom/rbwifi message="{'text': 'WiFi $num','rainbow': false, 'duration':5}" retain=no

#DHCP leases
:set num [/ip/dhcp-server/lease/print count-only as-value where status="bound"]
/iot/mqtt/publish broker=njumqtt topic=mikrotik/router/dhcp/leases message="$num" retain=yes

#CPU load
:set num [/system/resource get cpu-load]
/iot/mqtt/publish broker=njumqtt topic=mikrotik/router/cpuload message="$num" retain=yes

#Active users
:set num [/user/active/print count-only as-value] 
/iot/mqtt/publish broker=njumqtt topic=mikrotik/router/activeusers message="$num" retain=yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment