Community discussions

 
thetigerzzz
newbie
Topic Author
Posts: 44
Joined: Tue Nov 16, 2010 11:35 pm

script for interface traffic

Wed Nov 18, 2015 12:56 pm

i need script to current interface bandwidth / traffic in sms

for example

Interface name PPP 86Mbps
some thing like that
need experts suggestion
 
jarda
Forum Guru
Forum Guru
Posts: 7602
Joined: Mon Oct 22, 2012 4:46 pm

Wed Nov 18, 2015 1:37 pm

Have you considered using snmp?
 
User avatar
PaulsMT
MikroTik Support
MikroTik Support
Posts: 283
Joined: Tue Feb 10, 2015 3:21 pm

Re: script for interface traffic

Thu Nov 19, 2015 3:03 pm

If you don't use snmp, you can get these values with scripting. Use this script as an example, modify it to send the output over sms, email or other..:

{
:local iname;
:local monitor;
:local speedRX;
:local speedTX;
:local mbpsRX;
:local mbpsTX;
:foreach interface in=[/interface find] do={
:delay 100ms;
:set $iname [/interface get $interface name];
:set $monitor [/interface monitor-traffic $iname as-value once];
:set $speedRX ($monitor->"rx-bits-per-second");
:set $speedTX ($monitor->"tx-bits-per-second");
:set $mbpsRX (($speedRX/1000)/1000);
:set $mbpsTX (($speedTX/1000)/1000);
:put "$iname RX:$mbpsRX Mbps TX:$mbpsTX Mbps";
}
}
 
thetigerzzz
newbie
Topic Author
Posts: 44
Joined: Tue Nov 16, 2010 11:35 pm

Re: script for interface traffic

Fri Nov 20, 2015 9:16 am

If you don't use snmp, you can get these values with scripting. Use this script as an example, modify it to send the output over sms, email or other..:

{
:local iname;
:local monitor;
:local speedRX;
:local speedTX;
:local mbpsRX;
:local mbpsTX;
:foreach interface in=[/interface find] do={
:delay 100ms;
:set $iname [/interface get $interface name];
:set $monitor [/interface monitor-traffic $iname as-value once];
:set $speedRX ($monitor->"rx-bits-per-second");
:set $speedTX ($monitor->"tx-bits-per-second");
:set $mbpsRX (($speedRX/1000)/1000);
:set $mbpsTX (($speedTX/1000)/1000);
:put "$iname RX:$mbpsRX Mbps TX:$mbpsTX Mbps";
}
}
thx for reply bro im doing this
interface monitor-traffic [/interface find name=Local] once do={
:local tx (tx-bits-per-second / 1000)/1000);
:local rx (rx-bits-per-second / 1000)/1000);
:put $tx;
:put $rx;
/tool e-mail send to=youremail@hotmail.com subject="test" body="Mbps = $tx Mbps = $rx" tls=yes
}
getting result Mbps = 80 Mbps = 9 :)

Who is online

Users browsing this forum: No registered users and 13 guests