dynamic simple queue oid with php

Hello all,
can any one tell me how can i get the oid of simple queues (download-rate)
i can only tell the queue IP for which the queue is created

the queues are created dynamically on user login by radius server

actually i am trying to create mrtg but the queue are dynamic so can’t

Please help

Using the API, according to this part of the spec, when you “print” the simple queues, you can add the name of what you want, followed by “.oid”, to get the OID of that property.

So in other words,

/queue/simple/print
=.proplist=download-rate.oid

should give you something like

!re
=.id=*1
=download-rate.oid=.1.3.6.1.2.1.1.3.0
!re
=.id=*2
=download-rate.oid=.1.3.6.1.2.1.25.3.3.1.2.1
...
!done

Great man
the api is just awesome
Thanks

Got and issue
the following code is not fetching any result
but when i remove the line
$addRequest->setArgument(‘mac-address’, ‘00:1C:BF:C6:33:AF’);
it prints the whole registration table
is there any problem??

<?php
namespace PEAR2\Net\RouterOS;
require_once 'functions/PEAR2/Autoload.php';
$client = new Client('172.31.0.2', 'admin','pass');


$addRequest = new Request('/interface wireless registration-table print');
$addRequest->setArgument('mac-address', '00:1C:BF:C6:33:AF');
$responses = $client->sendSync($addRequest);

foreach ($responses as $response) {
    if ($response->getType() === Response::TYPE_DATA) {
        echo 'IP: ', $response->getArgument('last-ip'),
        ' MAC: ', $response->getArgument('mac-address'),
		' SIGNAL LEVEL: ', $response->getArgument('signal-strength'),
		' PACKET THROUGHPUT: ', $response->getArgument('p-throughput'),
        "\n";
    }
}
echo 'OK';
?>

To filter results, you need to use queries.

The easiest way is at the second argument of the Request constructor, e.g.

$addRequest = new Request('/interface wireless registration-table print', Query::where('mac-address', '00:1C:BF:C6:33:AF'));
$responses = $client->sendSync($addRequest); 

ok it worked
but can you tell which files in the PEAR folder are actually needed
as i don’t want to keep unused files there to avoid confusion

Thanks

is there any way to avoid declaring the name space
as i believe it’s breaking up my code

You need pretty much everything other than the *Exception classes. These are only ever needed if you use the client wrong - like supplying an invalid argument, connecting to a different protocol, etc. Also, you only need the Registry class if you’re using persistent connections.

If you want to minimize the number of files, the best thing you can do is get the “.phar” file, and include it instead. You can’t really go down beyond 1 file :wink: .

As for the namespace, yes, you can instead “use” the namespace. The code becomes a little longer though. For example:

<?php
use PEAR2\Net\RouterOS;
require_once 'functions/PEAR2/Autoload.php';
$client = new RouterOS\Client('172.31.0.2', 'admin','pass');


$addRequest = new RouterOS\Request('/interface wireless registration-table print', RouterOS\Query::where('mac-address', '00:1C:BF:C6:33:AF'));
$responses = $client->sendSync($addRequest); 

foreach ($responses as $response) {
    if ($response->getType() === RouterOS\Response::TYPE_DATA) {
        echo 'IP: ', $response->getArgument('last-ip'),
        ' MAC: ', $response->getArgument('mac-address'),
      ' SIGNAL LEVEL: ', $response->getArgument('signal-strength'),
      ' PACKET THROUGHPUT: ', $response->getArgument('p-throughput'),
        "\n";
    }
}
echo 'OK';
?>

Using this construct, the “use” doesn’t need to be the very first thing in the file - it can be anywhere before the first usage of a class. More importantly though, any custom class/function you have declared in the same file will not be considered part of the package’s namespace, which I’d guess is your actual problem.