How to return 'tx-bits-per-second' and 'rx-bits-per-second' with PEAR2_Net_RouterOS-1.0.0b6.phar

help me please. My coding can’t return “rx-bits-per-second” and “tx-bits-per-second” by hotspot user.

<?php use PEAR2\Net\RouterOS; require_once 'PEAR2_Net_RouterOS-1.0.0b6.phar'; try { $client = new RouterOS\Client('192.168.88.1', 'admin', ''); } catch (Exception $e) { die('Unable to connect to the router.'); } // "monitor-traffice interface=bridge1-office" can to return "rx-bits-per-second" and "tx-bits-per-second" $requests = new RouterOS\Request('/interface monitor-traffic interface=bridge1-office'); $requests->setArgument('once'); $result = $client->sendSync($requests)->current(); echo json_encode( array( 'rx' => $result('rx-bits-per-second'), 'tx' => $result('tx-bits-per-second') ) ); // This code can't return "rx-bits-per-second" and "tx-bits-per-second" $printRequest = new RouterOS\Request('/ip/hotspot/host/print'); $printRequest->setArgument('.proplist', 'address,user,.id,rx-bits-per-second'); $id = $client->sendSync($printRequest)->getAllOfType(RouterOS\Response::TYPE_DATA); foreach ($id as $response) { echo $response('.id'), '--', $response('user'), '--', $response('address'), $response('rx-bits-per-second'), "
"; } // This code can't return "rx-bits-per-second" and "tx-bits-per-second" $gethosts = $client->sendSync(new RouterOS\Request('/ip/hotspot/active/print detail=""')); foreach ($gethosts as $gethosts){ if ($gethosts->getType() === RouterOS\Response::TYPE_DATA) { echo ' ID : ', $gethosts->getProperty('.id'), ' USER : ', $gethosts->getProperty('user'), ' IP : ', $gethosts->getProperty('address'), ' TX : ', $gethosts->getProperty('tx-bits-per-second'), ' RX : ', $gethosts->getProperty('rx-bits-per-second'), "
"; } }?>

If you want to get just one probe per HTTP request, then you should define a queue for the hotspot user profile, and then get the “rate” property of the generated queue.

if you want to monitor the rate continuously, then you should instead use “/tool torch”, and use the hotspot subnet as src-address to be monitored.


The properties you’ve tried aren’t supported by RouterOS on the command line, and by extension, they are not supported by the API protocol either. I wish they were though, if not through a print property, at least with a dedicated command (ala “/interface monitor-traffic”), but alas, they aren’t.