Community discussions

 
Zod
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 90
Joined: Mon Apr 23, 2012 11:02 pm

Reset Simple Queue Counters from API ?

Thu Jan 11, 2018 11:59 pm

I'm trying to reset the simple queue counters on a specific queue from the API using PHP (not all queues)

It does not appear to be possible to specify a queue by anything but the queue number, and it doesn't seem to be possible to get the number from the API ?

Anyone else do this ?

Thx
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2386
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: Reset Simple Queue Counters from API ?  [SOLVED]

Fri Jan 12, 2018 1:26 pm

You can use the queue name in place of the number. Same is true for any menu where unique names are required (e.g. interface). In menus that don't support this, you have to use a query to get the ID of the item(s) you want to target.

e.g.
<?php
require_once 'PEAR2_Net_RouterOS-1.0.0b6.phar';
use PEAR2\Net\RouterOS;

$util = new RouterOS\Util($client = new RouterOS\Client('192.168.88.1', 'admin', 'password'));
$util->setMenu('/queue simple');

//Replace "my queue" with the name of the queue you want to reset
$resetRequest = $util->newRequest('reset-counters', array('numbers' => 'my queue'));

//// Or if you want to reset f.e. multiple ones that have the commnet "my comment", plus the "my queue" queue, whatever its comment may be
// $resetRequest = $util->newRequest('reset-counters', array('numbers' => $util->find(RouterOS\Query::where('comment', 'my comment'), 'my queue')));

$client->sendSync($resetRequest);
PEAR2_Net_RouterOS(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)
 
Zod
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 90
Joined: Mon Apr 23, 2012 11:02 pm

Re: Reset Simple Queue Counters from API ?

Sat Jan 13, 2018 12:23 am

You can use the queue name in place of the number. Same is true for any menu where unique names are required (e.g. interface). In menus that don't support this, you have to use a query to get the ID of the item(s) you want to target.

e.g.
<?php
require_once 'PEAR2_Net_RouterOS-1.0.0b6.phar';
use PEAR2\Net\RouterOS;

$util = new RouterOS\Util($client = new RouterOS\Client('192.168.88.1', 'admin', 'password'));
$util->setMenu('/queue simple');

//Replace "my queue" with the name of the queue you want to reset
$resetRequest = $util->newRequest('reset-counters', array('numbers' => 'my queue'));

//// Or if you want to reset f.e. multiple ones that have the commnet "my comment", plus the "my queue" queue, whatever its comment may be
// $resetRequest = $util->newRequest('reset-counters', array('numbers' => $util->find(RouterOS\Query::where('comment', 'my comment'), 'my queue')));

$client->sendSync($resetRequest);

This works perfectly. Thank you Boen - and thanks for the API. I can only wish that I had your skill level !

Who is online

Users browsing this forum: No registered users and 7 guests