Script help - if check?

Hi guys
I need a bit command help for 2 cases…

  1. I need to check interface speed in a script but can’t find a proper function. I need to check interface speed.
  • example:
  if interface speed=10 mbit => execute script
  1. How to check if the firewall rules with certain comments are active with else for next level?
  • example:
 if "1" is enabled => run script_1,
              else if "2" is enabled => run script_2,
                else if 3 "is" enabled => run script_3

Thank You for help

  1. Use Traffic Monitor Tool >> http://wiki.mikrotik.com/wiki/Manual:Tools/Traffic_Monitor

{:local i [/ip firewall filter get value-name=disabled number=[find comment=""]];
 : if (i=false) do={} else={ if () do={} else={} }

Notice that for check each firewall rule status(enable or disable), You must get the value like first one.

It’s my code and maybe others come and correct or improve it.

I will try to make it work. I’ll post results :slight_smile:
But for case 1, i didn’t meant for traffic, I meant interface connection status like 1Gbit, 100mbit, 10mbit :frowning:

Thanks

:local i [/interface  ethernet get value-name=speed number=ether2 ]; :if (i="XXX") do={"everything you want"};

XXX can be:
1Gbps, 100Mbps, 10Mbps.
Must put them in “”.

I’ve manage script to work… after each run, it’s moving to next NAT setting.

{:local i [/ip firewall nat get value-name=disabled number=[find comment="1"]];
: if (i=false) do={[/system script run "enable-2"] }  else={
{:local i [/ip firewall nat get value-name=disabled number=[find comment="2"]];
: if (i=false) do={[/system script run "enable-3"] } else={ 
{:local i [/ip firewall nat get value-name=disabled number=[find comment="3"]];
: if (i=false) do={[/system script run "enable-4"] } else={
{:local i [/ip firewall nat get value-name=disabled number=[find comment="4"]];
: if (i=false) do={[/system script run "enable-5"] } else={
{:local i [/ip firewall nat get value-name=disabled number=[find comment="5"]];
: if (i=false) do={[/system script run "enable-6"] } else={
{:local i [/ip firewall nat get value-name=disabled number=[find comment="6"]];
: if (i=false) do={[/system script run "enable-mass"] } else={
/system script run "enable-1"
}} }} }} }} }} }} }}

Script runs are like this with changed enabled and disabled parts

/ip firewall nat enable [find comment="1"]
/ip firewall nat enable [find comment="1a"]

/ip firewall nat disable [find comment="2"]
/ip firewall nat disable [find comment="2a"]

/ip firewall nat disable [find comment="3"]
/ip firewall nat disable [find comment="3a"]

/ip firewall nat disable [find comment="4"]
/ip firewall nat disable [find comment="4a"]

/ip firewall nat disable [find comment="5"]
/ip firewall nat disable [find comment="5a"]

/ip firewall nat disable [find comment="6"]
/ip firewall nat disable [find comment="6a"]

First part done :sunglasses:

Nice job! Don’t forget to five karma :laughing:

So, I had to put value that I need need to check into a local variable. That was a problem.
Thank you a lot… I will try :sunglasses:

PS… Karma added