How to monitor through api?

How API is used to gather information like

/interface wireless scan

/interface wireless frequency-monitor

… and others?


For instance, /interface/ethernet/monitor =numbers=0 =once= returns proper value but there commands just return error.

I tried

/interface/wireless/frequency-monitor =number=0 =once=
/interface/wireless/frequency-monitor =numbers=0 =once=
/interface/wireless/frequency-monitor =interface=wlan =once=

last time I checked monitor and scan commands were not supported by API.

You sure can do frequency-monitor and scan from API. API “commands” are based on console commands, e.g. “frequency-monitor” does not have “once” parameter, therefore you have to start it and stop it over API:

 <<< /interface/wireless/print
 <<<                          
 >>> !re                      
 >>> =.id=*3                  
 >>> =comment=                
 >>> =name=wlan1
 >>> =mtu=1500
...
 <<< /interface/wireless/frequency-monitor
 <<< =.id=*3                              
 <<<                                      
 >>> !re                                  
 >>> =.id=*1                              
 >>> =freq=5180                           
 >>> =use=192                             
 >>> =nf=-101                             
 >>>                                      
 >>> !re                                  
 >>> =.id=*2                              
 >>> =freq=5200                           
 >>> =use=0                               
 >>> =nf=-101                             
...
 <<< /cancel
 <<<
 >>> !trap
 >>> =category=2
 >>> =message=interrupted
 >>>
 >>> !done
 >>>
 >>> !done

Another thing - “numbers” argument is not accepted everywhere and even where accepted not advised - use “.id” argument to specify the object (interface in this case) you refer to - use “print” command to find it out if not known.

You can use most of commands available in console from API (that are not console scripting related) with the same arguments as in console. There are some commands where you currently will not get meaningful results (such as traceroute), but there are only a few like this. You can even run bandwidth-test from API.