php api help

hi
i am using the following code to get the queue transfer rate for graphing purpose
if ($API->connect(‘ip’, ‘user’, ‘pass’))
{
$API->write(‘/queue/simple/print’,false);
$API->write(‘=rate=’);
$READ = $API->read(false);
$output =$API->parse_response($READ);
$API->disconnect();
}
what i want is rather than displaying all the details it should only display the target and the rate field
also it should show the rate in kbps only

can any one help??

you can look here:
http://wiki.mikrotik.com/wiki/API#Command_description

on how .proplist works, so you can filter out what fields you want to see.

and you can use queries to limit what entries you want to see.

what about forcing the rate to show in kbps only

AFAIK, you can’t.

You need to recalculate those from the bps values.

This should be trivial to do: Just take the value and divide by 1024 on the PHP end.





P.S. Out of curiosity… was switching to a “.phar” file too difficult that you tried the other client or what?

i know
but think some time it’s in bps some timein kbps and some time in mbps

I thought the API values are always in bps :open_mouth: .

Is there an indication letter (K, M) at least? I mean, if there is, parsing the value on PHP’s end shouldn’t be too difficult either.

i know i can parse it in php
but still it should be great if there is any native solution

or mikrotik guys please tell me what is the expected formats like bps/kbps/mbps or is there something like MBps also??