Community discussions

MikroTik App
 
alissonx
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Tue Oct 06, 2009 4:12 pm

Torch via API

Wed Sep 28, 2011 5:19 pm

Hi.. its possible to do torch via APi?
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Torch via API

Thu Sep 29, 2011 8:43 am

yes, something along these lines:
/tool/torch
=interface=ether2
result looks like this:
!re
=tx=4104
=rx=1904
=tx-packets=5
=rx-packets=3

!re
=tx=4104
=rx=1904
=tx-packets=5
=rx-packets=1904

!re
=tx=3536
=rx=3120
=tx-packets=4
=rx-packets=4
adding more parameters will expand the output.
 
alissonx
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Tue Oct 06, 2009 4:12 pm

Re: Torch via API

Thu Sep 29, 2011 3:11 pm

I used

/tool/torch
=interface=<pppoe-customer>

but doesn't work... on mikrotik api php
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Torch via API

Fri Sep 30, 2011 10:55 am

what was the result of the command (actual output returned by the router on command?
 
alissonx
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Tue Oct 06, 2009 4:12 pm

Re: Torch via API

Fri Sep 30, 2011 3:18 pm

nothing... dont return anything...
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Torch via API

Mon Oct 03, 2011 10:05 am

it should return at least !re or !trap if some settings are not correctly sent.

if there are no return mean, that your command itself is not complete and RouterOS expects trailing 0x00.

Check you have current version installed, this is one that i tried this on.
 
alissonx
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Tue Oct 06, 2009 4:12 pm

Re: Torch via API

Mon Oct 03, 2011 9:40 pm

My Code
$API->write('/tool/torch');
$API->write("=interface=<pppoe-$UserName>");
$ARRAY= $API->read(false);
print_r($ARRAY);
now its working... but look the return
Array 
( 
 [0] => !trap 
 [1] => =message=no such command prefix 
 [2] => !done 
 [3] => !trap 
 [4] => =message=failure: interface not up and running 
 [5] => !done 
) 
I'm on mikrotik... and the pppoe works
/tool torch interface=<pppoe-teste> 
the return
   TX         RX TX-PACKETS RX-PACKETS
      0bps     360bps          0          1
      0bps     360bps          0          1
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Torch via API

Tue Oct 04, 2011 10:16 am

apparently there is no such interface named
$API->write("=interface=<pppoe-$UserName>");
torch works fine as long as there is traffic passing through the link

/tool/torch
=interface=<pppoe-uuu>
and this is the output:
!re
=tx=448
=rx=448
=tx-packets=1
=rx-packets=1

!re
=tx=448
=rx=448
=tx-packets=1
=rx-packets=1

!re
=tx=448
=rx=448
=tx-packets=1
=rx-packets=1
just pinging the other end
 
alissonx
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Tue Oct 06, 2009 4:12 pm

Re: Torch via API

Tue Oct 04, 2011 3:25 pm

if I execute this line on mikrotik... it works
/tool/torch
=interface=<pppoe-teste>
but... if I execute this on API... show the message
Array 
( 
  [0] => !trap 
  [1] => =message=failure: interface not up and running 
  [2] => !done 
)
Why by the mikrotik works? and API don't?


On mikrotik in /ip services, the API its allowed.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Torch via API

Tue Oct 04, 2011 3:34 pm

check what command exactly is being sent to the router. At this moment i had enabled and working pppoe interface and torch returned valid data.

try to set exact interface name in the command, not substitute value.
 
alissonx
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Tue Oct 06, 2009 4:12 pm

Re: Torch via API

Tue Oct 04, 2011 3:42 pm

how to check in mikrotik the command that was sent?
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Torch via API

Tue Oct 04, 2011 3:52 pm

use /tool sniffer on the router filter for connection ip addresses and API port.
 
alissonx
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Tue Oct 06, 2009 4:12 pm

Re: Torch via API

Tue Oct 04, 2011 4:01 pm

ok...

I set

/tool sniffer

set filter-address1=0.0.0.0/0:8728

but don't shows anything...
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Torch via API

Wed Oct 05, 2011 9:05 am

if you use 5.7 then use this:
/tool sniffer set filter-port=8728
/tool sniffer start

or
/tool sniffer quick port=8728
 
alissonx
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Tue Oct 06, 2009 4:12 pm

Re: Torch via API

Wed Oct 05, 2011 3:07 pm

Hi.. my version is 5.6

my mikrotik don't have

/tool sniffer set filter-port=8728


and don't have too /tool sniffer quick port=8728

=S
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Torch via API

Wed Oct 05, 2011 3:11 pm

then maybe update?

all my replies are checked on 5.7 ppc (powerpc) or mipsbe board.
 
alissonx
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Tue Oct 06, 2009 4:12 pm

Re: Torch via API

Wed Oct 05, 2011 8:08 pm

ok...

now its 5.7 version...

on log shows conected on api...

but on sniffer i'm not getting nothing..
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Torch via API

Thu Oct 06, 2011 9:31 am

that mean that you have wrong sniffer settings. anyway, from your previous posts you had wrong value for .id attribute that is why you got the message you where getting and no result.
 
alissonx
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Tue Oct 06, 2009 4:12 pm

Re: Torch via API

Thu Oct 06, 2011 4:15 pm

I get to use the sniffer, and I see some connections with api port... but don't have any information about the commands sent to mikrotik via api
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Torch via API

Fri Oct 07, 2011 8:51 am

you should look into packet contents. Sniffer is general tool to capture and check header information, packet content etc.
 
alissonx
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Tue Oct 06, 2009 4:12 pm

Re: Torch via API

Fri Oct 07, 2011 3:32 pm

ok...

my code its right?
	
$API->write('/tool/torch',false);
$API->write('=interface=<pppoe-test>');	
I get the information of the packates

firts packet
#./tool/torch
second packet
'!=interface=
<pppoe-test>.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Torch via API

Mon Oct 10, 2011 2:02 pm

i wonder why second part is with newline in the middle, but generally it looks good, what is the response of the router, taking in account, that interface exists.
 
alissonx
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Tue Oct 06, 2009 4:12 pm

Re: Torch via API

Mon Oct 10, 2011 3:16 pm

shows same error
Array 
(
 [0] => !trap
 [1] => =message=failure: interface not up and running
 [2] => !done
)
 
alissonx
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Tue Oct 06, 2009 4:12 pm

Re: Torch via API

Sat Oct 15, 2011 12:23 am

this code its right?
$API->write('/tool/torch');
$API->write("=interface=<pppoe-test>");
$ARRAY= $API->read(false);
print_r($ARRAY);
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Torch via API

Mon Oct 17, 2011 2:45 pm

check this PHP implementation docs,it might be that you have to add additional argument to indicate that there will be additional lines for the command. like this
$API->write('/tool/torch', false);
 
alissonx
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Tue Oct 06, 2009 4:12 pm

Re: Torch via API

Mon Oct 17, 2011 4:19 pm

If i use this code
$API->write('/tool/torch',false);
$API->write("=interface=<pppoe-$UserName>");
the page stay loading... and don't show anything...
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Torch via API

Tue Oct 18, 2011 10:01 am

is there any traffic on the interface?

also, you can try to run this on python API client to see raw output.
 
alissonx
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Tue Oct 06, 2009 4:12 pm

Re: Torch via API

Wed Oct 19, 2011 4:41 pm

yes... has traffic...

I never used the python api =\
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Torch via API

Wed Oct 19, 2011 8:00 pm

I have tried to use torch through API on 5.7 looking for packets on pppoe interface. Check in trafficflow. Maybe tere is some problem with your configuration

Sent from my GT-I9100 using Tapatalk
 
alissonx
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Tue Oct 06, 2009 4:12 pm

Re: Torch via API

Tue Oct 25, 2011 4:00 pm

Hi..

I just configure

address: 192.168.1.1 (ip logged on api?)
port: 8728

just it?
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Torch via API

Tue Oct 25, 2011 4:29 pm

if you mean by what you have to set up for it to work - just enable it, do not add address restrictions.
 
alissonx
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Tue Oct 06, 2009 4:12 pm

Re: Torch via API

Tue Oct 25, 2011 7:27 pm

I enabled the traffic flow..

and now?

I have to create a "new traffic flow target"? and set the port of api?
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Torch via API

Wed Oct 26, 2011 10:04 am

what exactly are you doing?

what in common does API and '/ip traffic-flow' have?

Or torch, while at it.

At this moment it is not clear what exactly you are trying to achieve. You want to run torch over API or you want to set up traffic-flow to monitor flows or what?
 
alissonx
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Tue Oct 06, 2009 4:12 pm

Re: Torch via API

Tue Nov 01, 2011 8:10 pm

i'm just trying to run torch over api... just it
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Torch via API

Thu Nov 03, 2011 12:17 pm

traffic flow works in the same way through API as it does through CLI, using same settings in both places yields same results. You do not need anything additional to use torch over API compared to torch over CLI
 
alissonx
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Tue Oct 06, 2009 4:12 pm

Re: Torch via API

Thu Nov 03, 2011 7:28 pm

ok...

the code stays:
$API->write('/ip/traffic flow',false);
$API->write("=interface=<pppoe-$UserName>");
?
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Torch via API

Fri Nov 04, 2011 8:43 am

that is not torch

but here is example of torch:

 > tool torch interface=ether2-Out 
        TX         RX TX-PACKETS RX-PACKETS
   2.1kbps     688bps          1          1
   2.1kbps     688bps          1          1
/tool/torch
=interface=ether2-Out
!re
=tx=688
=rx=0
=tx-packets=1
=rx-packets=0

!re
=tx=688
=rx=0
=tx-packets=1
=rx-packets=0
results from 5.8

Who is online

Users browsing this forum: No registered users and 85 guests