I cant seem to figure this out, what im looking for is to get the API in php to give me the same output as /ip hotspot host print bytes but I cant get the api to do this?
Does anyone know how this might be achieved?
I cant seem to figure this out, what im looking for is to get the API in php to give me the same output as /ip hotspot host print bytes but I cant get the api to do this?
Does anyone know how this might be achieved?
Assuming you’re using PEAR2_Net_RouterOS:
new RouterOS\Request('/ip hotspot host print bytes=""');
(the first argument MUST have a value, even if it’s an empty one)
With other clients, it’s basically the same deal - simply type it as an argument, not as part of the command.
Im using the RouterOS PHP API class v1.4 whats would the syntax be for that?
Thank you in advance for your help.
$API->comm('/ip/hotspot/host/print', array('bytes'=>''));
Works brilliantly, Thank you!
for others here is what I ended up with.
function ByteSize($bytes)
{
$size = $bytes / 1024;
if($size < 1024)
{
$size = number_format($size, 2);
$size .= ' KB';
}
else
{
if($size / 1024 < 1024)
{
$size = number_format($size / 1024, 2);
$size .= ' MB';
}
else if ($size / 1024 / 1024 < 1024)
{
$size = number_format($size / 1024 / 1024, 2);
$size .= ' GB';
}
}
return $size;
}
$ARRAY = $API->comm("/ip/hotspot/host/print", array('bytes'=>''));
for ($i=0; $i<250; $i++)
{
$mac = $load['mac-address'];
$ip = $load['address'];
$bytesin = $load['bytes-in'];
$bytesout = $load['bytes-out'];
$load = $ARRAY[$i];
$datain = ByteSize($bytesin);
$dataout = ByteSize($bytesout);
echo $datain;
echo $dataout;
}