Community discussions

MikroTik App
 
User avatar
karo84
Member Candidate
Member Candidate
Topic Author
Posts: 194
Joined: Fri Aug 17, 2007 9:06 am

Please Help Is This a Bug or I made a Mistake ????

Mon Oct 29, 2007 9:10 pm

Hi
On my ROS (PIII) I have written a script which is choosing say better channel
look at My script
[admin@Monument] > system script print 
 0 name="script1" owner="admin" policy=ftp,reboot,read,write,policy,test,winbox,password,(unknown) last-started=oct/30/2007 00:07:31 run-count=1154 
   source=
     :foreach i in=[/interface find name=WiFi-Clients ] do={/interface wireless monitor $i once do {:if ($noise-floor > -100) do {:local tmpfreq [interface wire
less get [/interface wireless find interface=$i] frequency] ; 
     :log info $tmpfreq ;  
     :set tmpfreq ($tmpfreq + 5) ; 
     :log warning $tmpfreq ; 
     :if ($tmpfreq < 2472) do={/interface wireless set $i frequency=$tmpfreq} else={/interface wireless set $i frequency=2412 ;}}}}
[admin@Monument] > 
This one works Fine But On others (They are PIII ROS too) it doesn't work

Why ??
Can anybody help?
Look at logs
[admin@SHIRVANZADE] > :foreach i in=[/interface wireless find name=WiFi-Clients ] do={/interface wireless monitor $i once ; :do {:if ($noise-floor > 100) do {:l
ocal tmpfreq [/interface wireless get [/interface wireless find interface=$i] frequency] ; :log info $tmpfreq ; :set tmpfreq ($tmpfreq + 5) ; :log warning $tmpf
req ; :if ($tmpfreq < 2472) do={/interface wireless set $i frequency=$tmpfreq} else={/interface wireless set $i frequency=2412 ;}}}}
                 status: running-ap
                   band: 2.4ghz-b
              frequency: 2427MHz
            noise-floor: -92dBm
         overall-tx-ccq: 57%
     registered-clients: 14
  authenticated-clients: 14
    current-ack-timeout: 218
       current-distance: 218
                nstreme: no
      current-tx-powers: 1Mbps:28,2Mbps:28,5.5Mbps:28,11Mbps:28
    notify-external-fdb: yes
[admin@SHIRVANZADE] > 
It Runs But nothing is changed when it had to change the frequency as noise-floor was -92


Somebody Help Please
With Regards
Karapet Aznavuryan
 
User avatar
krigevr
Member Candidate
Member Candidate
Posts: 155
Joined: Mon Aug 20, 2007 7:02 pm
Location: South Africa

Re: Please Help Is This a Bug or I made a Mistake ????

Tue Oct 30, 2007 11:24 am

For your FOREACH statement, you return index values based on a search for a Name under Interface, according to your script.

But then you proceed to trigger a Monitor under /interface/wireless.
The index values under Wireless are not the same list as is shown under Interface.

You'll see if you do
/interface print
and
/interface wireless print
It'll give you two different lists, with two different sets of index values.

Quite likely, the index value under /interface for your wireless card does not correspond to the index value for the Wireless card you want to monitor under /interface/wireless.
In my case, this is definitely true.

I suggest changing the FOREACH statement to the following:
:foreach i in=[/interface wireless find name=WiFi-Clients ] do={/interface wireless monitor $i once...
 
User avatar
karo84
Member Candidate
Member Candidate
Topic Author
Posts: 194
Joined: Fri Aug 17, 2007 9:06 am

Re: Please Help Is This a Bug or I made a Mistake ????

Tue Oct 30, 2007 3:18 pm

Thanks krigevr Very Much

I tried But It does not work
I don't Understand why?
 
User avatar
jorj
Member
Member
Posts: 397
Joined: Mon Mar 12, 2007 4:34 pm
Location: /dev/null

Re: Please Help Is This a Bug or I made a Mistake ????

Tue Oct 30, 2007 3:52 pm

Do your wireless interfaces have exactly the same name on each router ?
You are using find to locate them by name.
And yes, do use /interface print OR /interface wireless print, only one of them, for consistency.
 
User avatar
karo84
Member Candidate
Member Candidate
Topic Author
Posts: 194
Joined: Fri Aug 17, 2007 9:06 am

Re: Please Help Is This a Bug or I made a Mistake ????

Tue Oct 30, 2007 5:38 pm

Yes I understand that
:foreach i in=[/interface is equal to /interface print
and
:foreach i in=[/interface wireless is equal to /interface wireless print


In Both Case there must be no difference as I use different Interface names on one Router
So My ROS version is 2.9.27,
What you think Can it be a reason for this problem ??
 
User avatar
jorj
Member
Member
Posts: 397
Joined: Mon Mar 12, 2007 4:34 pm
Location: /dev/null

Re: Please Help Is This a Bug or I made a Mistake ????

Tue Oct 30, 2007 7:29 pm

In the first post, you said it works fine on one router. Your script.
If you move it to another router, and you use find to locate the interface, you should look for the exact interface name, case dOeS matter.
 
User avatar
karo84
Member Candidate
Member Candidate
Topic Author
Posts: 194
Joined: Fri Aug 17, 2007 9:06 am

Re: Please Help Is This a Bug or I made a Mistake ????

Wed Oct 31, 2007 2:43 pm

I have writen just the same script and on others and there was no Difference
It doesn't give any errors and doesn't work at all.
Somebody can Help?
 
User avatar
krigevr
Member Candidate
Member Candidate
Posts: 155
Joined: Mon Aug 20, 2007 7:02 pm
Location: South Africa

Re: Please Help Is This a Bug or I made a Mistake ????

Thu Nov 01, 2007 7:58 am

What version of RouterOS are you using?

There are some known errors in the scripting for 2.9.x, which seems to have been solved by 3.0rcX.

Post the script as you have it now, and let's see if we can debug it some more.

-K
 
User avatar
karo84
Member Candidate
Member Candidate
Topic Author
Posts: 194
Joined: Fri Aug 17, 2007 9:06 am

Re: Please Help Is This a Bug or I made a Mistake ????

Thu Nov 01, 2007 6:07 pm

Thanks For Reply
Here My Script
:foreach i in=[/interface find name=WiFi-Clients ] do={/interface wireless monitor $i once do {:if ($noise-floor > -100) do {:local tmpfreq [interface wireless get [/interface wireless find interface=$i] frequency] ; 
:log info $tmpfreq ;  
:set tmpfreq ($tmpfreq + 5) ; 
:log warning $tmpfreq ; 
:if ($tmpfreq < 2472) do={/interface wireless set $i frequency=$tmpfreq} else={/interface wireless set $i frequency=2412 ;}}}}

And We Use 2.9.27 Version of The ROS


Regards
Karapet Aznavuryan
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7056
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Please Help Is This a Bug or I made a Mistake ????

Thu Nov 01, 2007 6:34 pm

[quote="karo84"]
And We Use 2.9.27 Version of The ROS
/quote]

woooh that's too old :)
 
User avatar
karo84
Member Candidate
Member Candidate
Topic Author
Posts: 194
Joined: Fri Aug 17, 2007 9:06 am

Re: Please Help Is This a Bug or I made a Mistake ????

Thu Nov 01, 2007 7:08 pm

MRZ
What You Mean?
What Can I do?
Upgrade?
 
User avatar
jorj
Member
Member
Posts: 397
Joined: Mon Mar 12, 2007 4:34 pm
Location: /dev/null

Re: Please Help Is This a Bug or I made a Mistake ????

Thu Nov 01, 2007 7:27 pm

MRZ
What You Mean?
What Can I do?
Upgrade?
Exactly ! 8)
 
User avatar
karo84
Member Candidate
Member Candidate
Topic Author
Posts: 194
Joined: Fri Aug 17, 2007 9:06 am

Re: Please Help Is This a Bug or I made a Mistake ????

Thu Nov 01, 2007 7:53 pm

Thanks All Very Much :lol: 8) :lol:
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7056
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Please Help Is This a Bug or I made a Mistake ????

Fri Nov 02, 2007 9:46 am

MRZ
What You Mean?
What Can I do?
Upgrade?
Yes, I mean upgrade. This version is so old, there could be 100 bugs related to your script problem :) It is working for us on latest versions.
 
User avatar
karo84
Member Candidate
Member Candidate
Topic Author
Posts: 194
Joined: Fri Aug 17, 2007 9:06 am

Re: Please Help Is This a Bug or I made a Mistake ????

Fri Nov 02, 2007 5:08 pm

OK Thanks I'll try to Upgrade to the latest Version, and then try to run the script. 8)

Who is online

Users browsing this forum: Eriks and 68 guests