Hi! Nice work :) but I can say for sure that API definitely does not allow that kind of comparison :/ In any case, my problem is that I want to be able to find rules that match "SetID:443" /OR/ "RuleID:538" The way API works is a bit like a database query - we run something like a query on the router configuration, and the API sends back a list of 'ID' values identifying the matching configuration entries which we can then use to apply some action (modify/delete) My main issue is that I don't know how they calculate > or < with these string match evaluations. It might just match a string length, or it might be some kind of hash algorithm... nobody can tell me for sure, so I guess I'm just going to have to work it out by empirical process :-} Cheers! Mike.
-----Original Message----- From: Public [mailto:public-bounces@talk.mikrotik.com.au] On Behalf Of Steve at Digitronics Sent: Thursday, 15 May 2014 11:32 AM To: 'MikroTik Australia Public List' Subject: Re: [MT-AU Public] API Wildcard search
Have I missed the point?
:tobool ([:find ("|"."Managed by DuxAdmin SetID:443 RuleID:538") "Managed by DuxAdmin SetID:443"] > 0)] gives true and :tobool ([:find ("|"."Managed by DuxAdmin SetID:443 RuleID:538") "Managed by DuxAdmin SetID:444"] > 0)] gives false
Which should act as a match conditional.
Steve.
-----Original Message----- From: Public [mailto:public-bounces@talk.mikrotik.com.au] On Behalf Of Mike Everest Sent: Thursday, 15 May 2014 08:40 To: 'MikroTik Australia Public List' Subject: Re: [MT-AU Public] API Wildcard search
Hi Andrew! Thanks for your response :-)
That is all fine, but our rule comments will actually look something like:
"Managed by DuxAdmin SetID:443 RuleID:534" "Managed by DuxAdmin SetID:443 RuleID:535" "Managed by DuxAdmin SetID:443 RuleID:536" "Managed by DuxAdmin SetID:443 RuleID:537" "Managed by DuxAdmin SetID:441 RuleID:538" "Managed by DuxAdmin SetID:441 RuleID:539" "Managed by DuxAdmin SetID:441 RuleID:540" "Managed by DuxAdmin SetID:446 RuleID:541"
So potentially we will want to search for either a specific RuleID OR a specific SetID (or perhaps both, if an explicit single item is searched)
The problem for us right now is that there appears to be no way to match a partial string, i.e. [:find $rulecomment "Managed by DuxAdmin SetID:443*"]
The '>' operator appears to work, but without understanding HOW that operator is actually evaluated, we can't be certain that it is generally correct ;)
Cheers!
Mike.
-----Original Message----- From: Public [mailto:public-bounces@talk.mikrotik.com.au] On Behalf Of Andrew Cox Sent: Wednesday, 14 May 2014 11:01 PM To: MikroTik Australia Public List Subject: Re: [MT-AU Public] API Wildcard search
Going from my head on this one, but the CLI way for this to work for this would be
:foreach counter in=[/ip firewall filter find] do={ :local rulecomment [/ip firewall filter get $counter comment] :if ([:find $rulecomment "Managed by DuxAdmin SetID:443"] != "") do={ *#code you want to run goes here, using $counter to pick the line you're editing* } }
- Andrew
On 14 May 2014 21:42, Paul Julian <paul@oxygennetworks.com.au> wrote:
Hey Mike, does this syntax actually work when doing the find in the CLI on the router itself ?
Regards Paul
-----Original Message----- From: Public [mailto:public-bounces@talk.mikrotik.com.au] On Behalf Of Mike Everest Sent: Wednesday, 14 May 2014 9:29 PM To: 'MikroTik Australia Public List' Subject: Re: [MT-AU Public] API Wildcard search
Hi folks!
Further to my original post (below) I have had some further correspondence with MT (Janis K) regarding these questions, but really getting nowhere useful yet ;-)
At least I have been able to confirm that there is no wildcard or regex feature in API query structure (apparently 'regex is not available via API in any form' ;-) and the suggested approach is to download the entire data to the client and parse client side, which is quite a PITA for the implementation that we are building here :(
I am yet to get any sensible description of how the operators '<' and '>' actually work on text at all (i.e. is it like strcmp kind of functionality, or something else?) but taking my usual tack when dealing with MT support and just repeating the question over and over until they offer an answer that addresses the actual question! :-D
When I get such a result, I will post again to this thread for prosperity of all!
Cheers, Mike.
-----Original Message----- From: Public [mailto:public-bounces@talk.mikrotik.com.au] On Behalf Of Mike Everest Sent: Sunday, 27 April 2014 10:37 AM To: public@talk.mikrotik.com.au Subject: [MT-AU Public] API Wildcard search
Hi folks,
Anyone have some experience using routerOS API?
I've been extending the configuration group functionality of our DuxTel Commander, and come up against a challenge in filtering API query (http://wiki.mikrotik.com/wiki/API#Queries)
The deal is that I use 'comment' field as a way to cross-reference router configuration entries with the configuration database items. For example, a firewall rule might look like:
ip firewall filter add chain=forward src-address-list=blocked action=drop comment='Managed by DuxAdmin SetID:443 ItemID:27'
So when I want to find all the firewall rules with SetID:443, I can do this:
/ip/firewall/filter/find ?>comment=Managed by DuxAdmin SetID:443
Which seems to work OK, but I can't work out how to return just those entries that include 'ItemID:27'
I'll put the question to MT support and post a solution (if there is one) if/when they respond, but if anyone has some suggestions, I'm 'all ears'! ;-)
Cheers, Mike.
_______________________________________________ Public mailing list Public@talk.mikrotik.com.au http://talk.mikrotik.com.au/mailman/listinfo/public_talk.mikrotik.com. au
----- No virus found in this message. Checked by AVG - www.avg.com Version: 2014.0.4570 / Virus Database: 3931/7437 - Release Date: 05/03/14 Internal Virus Database is out of date.
_______________________________________________ Public mailing list Public@talk.mikrotik.com.au http://talk.mikrotik.com.au/mailman/listinfo/public_talk.mikrotik.com. au
_______________________________________________ Public mailing list Public@talk.mikrotik.com.au http://talk.mikrotik.com.au/mailman/listinfo/public_talk.mikrotik.com. au
_______________________________________________ Public mailing list Public@talk.mikrotik.com.au http://talk.mikrotik.com.au/mailman/listinfo/public_talk.mikrotik.com.au
_______________________________________________ Public mailing list Public@talk.mikrotik.com.au http://talk.mikrotik.com.au/mailman/listinfo/public_talk.mikrotik.com.au