Community discussions

MikroTik App
 
emrecete
just joined
Topic Author
Posts: 1
Joined: Fri Dec 29, 2017 9:04 pm

how to api print range

Wed May 22, 2019 10:30 am

hi
we have mikrotik userman (radius) x86 (20.000 users) and request all data very slowly with use api.
how to request print range per 10 row with api.

ex; RouterOS\Request('/tool user-manager user print RANGE 0-100');
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: how to api print range

Fri May 24, 2019 9:42 am

If there's a way to do it with scripting, there's a way to do it in the API.

That said, I don't think there's a way to do it from scripting... RouterOS does let you scroll items interactively, and there's "no-paging" argument to make it not do that, but run down the screen immediatly. In the API, that argument has no effect, and either way, you're still getting all items.

The closest thing to paging you can do is to use "find" to get all IDs, and then in print, use the from argument to get just a subset of those IDs.

f.e.
$util->setMenu('/tool user-manager user');
$offset = 0;
$limit = 100;

$itemIds = explode(',', $util->find());
foreach ($util->getAll(array('from' => implode(',', array_slice($itemIds, $offset * $limit, $limit))) as $item) {
//Deal with each item here
}
Though this still means getting 20000 IDs, so it's not as optimal as an actual paging option would've been.

Who is online

Users browsing this forum: No registered users and 33 guests