Community discussions

MikroTik App
 
hermeson
just joined
Topic Author
Posts: 21
Joined: Wed Apr 05, 2017 1:57 am

Simple reading RX TX via API PHP

Tue Aug 17, 2021 11:41 pm

Hello guys, could someone help me:
<?php

require('routeros_api.class.php');
$API = new RouterosAPI();
$API->debug = true;
if ($API->connect('192.168.88.1', 'admin', 'admin')) {

	$arrRXTX=$API->comm("/interface/monitor-traffic",
	array(
	".proplist"=> "rx-bits-per-second,tx-bits-per-second",
	"?interface" => "ether2",));

	print_r($arrRXTX);
		
			
   $API->disconnect();}   
?>
what is wrong on my code?
thanks
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7053
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Simple reading RX TX via API PHP

Wed Aug 18, 2021 9:03 am

Get interface ID with /interface/print command and then call monitor using that ID "?interface=iface_name" will not work.
Also don't know how your particular PHP api wrapper implements it, but for the monitor command you need to run a background listener, or run monitor with =once=
 
hermeson
just joined
Topic Author
Posts: 21
Joined: Wed Apr 05, 2017 1:57 am

Re: Simple reading RX TX via API PHP

Thu Aug 19, 2021 6:13 pm

any chance to help me with this code???
 
hermeson
just joined
Topic Author
Posts: 21
Joined: Wed Apr 05, 2017 1:57 am

Re: Simple reading RX TX via API PHP  [SOLVED]

Thu Aug 26, 2021 3:37 pm

at last I did it with Delphi! thanks to all!
 
avistudio
just joined
Posts: 5
Joined: Sun Apr 28, 2019 9:56 pm

Re: Simple reading RX TX via API PHP

Sat Oct 07, 2023 4:32 am

Here is the solution that worked for me:
$param = ["interface"=>"ether1","once"=>"yes"];
$API->comm("/interface/monitor-traffic", $param);

Who is online

Users browsing this forum: No registered users and 10 guests