Skip to content

Instantly share code, notes, and snippets.

@kangarie
Last active September 13, 2024 01:15
Show Gist options
  • Save kangarie/a3c5fcc757cff49d3b92e02d7051ae05 to your computer and use it in GitHub Desktop.
Save kangarie/a3c5fcc757cff49d3b92e02d7051ae05 to your computer and use it in GitHub Desktop.
{
:local iname "ether1-WAN"
:local rate [/interface monitor-traffic $iname once as-value]
:local raterx ($rate->"rx-bits-per-second")
:local ratetx ($rate->"tx-bits-per-second")
:local type [:toarray "bps,Kbps,Mbps,Gbps"]
:local counter 0
:while ($raterx > 1024) do={
:set $raterx ($raterx/1024)
:set $counter ($counter+1)
}
:local satuan [:pick $type $counter]
:set $raterx "$raterx$satuan"
:local counter 0
:while ($ratetx > 1024) do={
:set $ratetx ($ratetx/1024)
:set $counter ($counter+1)
}
:local satuan [:pick $type $counter]
:set $ratetx "$ratetx$satuan"
:local pesan "$iname $raterx $ratetx"
:put $pesan
:log warning "$pesan"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment