7.1beta4 monitor-traffic restApi

Is it possible to get the following information through the rest api?:

tx-bits-per-second
rx-bits-per-second

The command would be: /interface/monitor-traffic wlan1 once but I could not get to run in through the api. I think id have to do it through the POST methode as it is descriped in the documentation https://help.mikrotik.com/docs/display/ROS/REST+API

I think: ip/rest/interface/monitor-traffic?interface=wlan1 is the way to do it but it needs somehow the once param…

Does someone know how to do that?

Check “Timeout” section in that manual. It has an example on how to use similar commands to “monitor-traffic”

Mmm thats a thing but not exactly what im trying to do. I can messure the bandwith between 2 tiks but i want to know the traffic of the interface wlan1 for exampe…

Is there another solution to that?

It is not clear what you are not able to do.

Have you tried to run
POST ‘https://x.x.x.x/rest/tool/traffic-monitor’ -data ‘{“interface”:“wlan1”,“duration”:“2s”}’

Yes i already tried that on multiple tiks but it didnt work :frowning:

Be more specific what exaclty is not working what errors you get and so on.

Here is an example of traffic monitor, it works as expected:

$ curl -k -u admin: -X POST 'https://10.155.101.214/rest/interface/monitor-traffic'   --data '{"interface":"sfp12","duration":"2s"}' -H "content-type: application/json"

[{".section":"0","fp-rx-bits-per-second":"45176","fp-rx-packets-per-second":"49","fp-tx-bits-per-second":"222160","fp-tx-packets-per-second":"30","name":"sfp12","rx-bits-per-second":"45176","rx-drops-per-second":"0","rx-errors-per-second":"0","rx-packets-per-second":"49","tx-bits-per-second":"222160","tx-drops-per-second":"0","tx-errors-per-second":"0","tx-packets-per-second":"30","tx-queue-drops-per-second":"0"},{".section":"1","fp-rx-bits-per-second":"24184","fp-rx-packets-per-second":"27","fp-tx-bits-per-second":"214616","fp-tx-packets-per-second":"31","name":"sfp12","rx-bits-per-second":"24184","rx-drops-per-second":"0","rx-errors-per-second":"0","rx-packets-per-second":"27","tx-bits-per-second":"214616","tx-drops-per-second":"0","tx-errors-per-second":"0","tx-packets-per-second":"31","tx-queue-drops-per-second":"0"}]

I tried it with curl and it worked right away. Well I guess I have to look at my not properly working tools.

Thank you for your answeres!

I was also looking for an answer to the OPs exact question and I found a few additional things that I thought could be good to know.

  1. Using “duration”: “2s” will perform two one second measurements and return them in a list (indexed by the .section key). So, if we only want one measurement we set “duration”: “1s”.
  2. We can use the .proplist property to filter out the exact information we want: rx-bits-per-second and tx-bits-per-second.


curl -k -u admin:password123 -X POST https://10.0.0.1/rest/interface/monitor-traffic \
  --data '{"interface": "ether1", "duration": "1s", ".proplist": ["name","rx-bits-per-second","tx-bits-per-second"]}'\
  -H "content-type: application/json"

# Result:
[{".section":"0","name":"ether1","rx-bits-per-second":"1486248","tx-bits-per-second":"4241672"}]

@bitcanon: I think you could also use “once”: true instead of “duration”, which also removes the “.section” value in the result (ROS 7.13.4 here):

--data '{"interface": "ether1","once": true,".proplist": ["name","rx-bits-per-second","tx-bits-per-second"]}'