Community discussions

MikroTik App
 
bokad
Member Candidate
Member Candidate
Topic Author
Posts: 152
Joined: Tue Oct 18, 2005 7:34 pm

Using "where" and "find" in MikroTik API

Mon Jan 19, 2009 5:58 pm

I am trying to use the MikroTik API to get the same results as the command line command:
/ip hotspot active print where user=bokad

I have tried:
--------------1--------------------------
$API->write('/ip/hotspot/active/print',false);
$API->write('=where=',false);
$API->write('=user=bokad',true);

--------------2--------------------------
$API->write('/ip/hotspot/active/print',false);
$API->write('=where',false);
$API->write('=user=bokad',true);

--------------3--------------------------
$API->write('/ip/hotspot/active/print',false);
$API->write('=where=user=bokad',true);

#1 and #2 just result in "=message=argument error"
#3 returns a list of all the users, not what I want.

Is there a way to use the where and find commands in the API?

I am using the PHP API found at:
http://wiki.mikrotik.com/wiki/API_PHP_class
 
cmit
Forum Guru
Forum Guru
Posts: 1552
Joined: Fri May 28, 2004 12:49 pm
Location: Germany

Re: Using "where" and "find" in MikroTik API

Mon Jan 19, 2009 6:44 pm

There's no "find" command in API.
You have to print/getall everything and search for the right .id yourself (in the results)...
Best regards,
Christian Meis
 
bokad
Member Candidate
Member Candidate
Topic Author
Posts: 152
Joined: Tue Oct 18, 2005 7:34 pm

Re: Using "where" and "find" in MikroTik API

Mon Jan 19, 2009 8:49 pm

Bummer. It's kinda inefficient to transfer an entire list of 1600 logged in users across a slow connection when you just need information on one of them.
Do you know of any plans to implement find or where?
Is there a documentation source for the API with more information than the Wiki?

Thanks.
 
cmit
Forum Guru
Forum Guru
Posts: 1552
Joined: Fri May 28, 2004 12:49 pm
Location: Germany

Re: Using "where" and "find" in MikroTik API

Tue Jan 20, 2009 9:35 am

I don't know of any more information, too. Perhaps writing to support@mikrotik.com can give you more answers...
Best regards,
Christian Meis
 
User avatar
jscoulter
newbie
Posts: 39
Joined: Fri Sep 15, 2006 1:32 am

Re: Using "where" and "find" in MikroTik API

Sat Feb 28, 2009 9:33 am

Anymore information on this?
I found the only way to remove a user is to use the .id field.
This does seem quite silly since you know the user name and the IP address, but not the ID, so why make it so you can only remove a user on a field that is not known to you unless you do a print and filter the results? That just adds overhead to the process, and not really all that logical...to me anyway.

Would love to hear any more about this.

Jeremy
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8397
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Using "where" and "find" in MikroTik API

Wed Apr 01, 2009 12:34 am

since 3.21 one can use queries in 'print' API command - it's analogue of 'fint' in CLI
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Using "where" and "find" in MikroTik API

Wed Apr 01, 2009 12:02 pm

exactly, queries showed up in 3.21 (3.22) and will stay there for long time, if you are using find, or plan using find, use queries and .proplist to get values you need, to avoid additional parsing of output.

look for more info on wiki API article:
http://wiki.mikrotik.com/wiki/API#Command_description

also, there is news about upcoming changes on how to get OIDs.
 
Percanta
newbie
Posts: 39
Joined: Tue Feb 24, 2009 1:00 am

Re: Using "where" and "find" in MikroTik API

Wed Jul 13, 2011 2:08 am

good day
is it possible make this API query /queue simple print where name~"ANDY" ?
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Using "where" and "find" in MikroTik API

Wed Jul 13, 2011 10:12 am

yes
/queue/simple/print
?name=ANDY
just to add - you can use queue name directly as value for .id argument to alter/monitor the queue.
 
Percanta
newbie
Posts: 39
Joined: Tue Feb 24, 2009 1:00 am

Re: Using "where" and "find" in MikroTik API

Wed Jul 13, 2011 3:55 pm

hi
i tryed that but it doesnt show for example "ANDY LEE"

/queue/simple/print
?name=ANDY -------> /queue simple print where name=ANDY


/queue/simple/print

?(?)(?) ------> /queue simple print where name~"ANDY" this works for "ANDY LEE"
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8397
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Using "where" and "find" in MikroTik API

Sat Jul 16, 2011 10:13 am

unfortunately, you cannot use regular expression matching in API
if you need to match by name prefix and don't want to receive all names to process them on client side, ugly workaround coud be like this:
/some/command/print
?>name=begi[u]n[/u]
?<name=begi[u]o[/u]
?#&
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.

Who is online

Users browsing this forum: nocivo and 15 guests