Community discussions

MikroTik App
 
onezeroart
just joined
Topic Author
Posts: 1
Joined: Sun Feb 03, 2019 9:23 pm

Net_RouterOS interface monitor-traffic

Sun Feb 03, 2019 9:56 pm

Hi,

I am trying to get real-time traffic data from PPPoE interface.
Tried this below code but it seems I am doing it wrong.
Tried a few ways but no luck.

$request = new RouterOS\Request('/interface/monitor-traffic');
$request->setArgument('interface', '<pppoe-user>');
$return = $client->sendSync($request);

It's giving me HTTP ERROR 500

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

Re: Net_RouterOS interface monitor-traffic  [SOLVED]

Mon Mar 25, 2019 12:04 am

sendSync() waits for the command to finish executing. However, "/interface/monitor-traffic" is a continuous command - it never finishes executing until you manually stop it.

You either have to pass the "once" argument to get just one sample in the $return, or use sendAsync() and loop()/completeRequest() in some fashion (e.g. with a callback function, and a loop() with a timer, to get the callback called for however many replies RouterOS returns for the specified number of seconds).

Who is online

Users browsing this forum: No registered users and 16 guests