Wireless Scan - help needed

I have a wireless script which is scheduled to run overnight but I need to add traffic detection script to prevent the wireless scan from running, In other words if a customer is streaming or downloading
the wireless scan will not run !

:local sub1
:set sub1 ([/system identity get name])
/interface wireless scan 0 duration=180 save-file=“$sub1 wiscan.txt”

You can try something like this:

  1. read number of packets/bytes from interface stats
  2. wait 10 s
  3. read it again, compute difference
  4. If lower than X (some threshold you will have to choose) run the scan

But if your hardware can do it, use background scan. It can run in the background without affecting the traffic.

It would be nice if RouterBOARD LHG 5nD CPE could conduct a background scan?
"Couldn’t start - background scan not supported in this state (6) "

I need help to create a script to monitor wlan interface traffic data and if above a threshold level say 1MB in one minute, the wireless scan does NOT run?

Ok work in progress ! ( I assume someone will say there is a easier method, If so please let me know!)
Just testing one possible solution,
Here is the workflow
(1) 04:07:04 will enable the disabled Traffic_Monitor
(2) if traffic flow is below 10kb - run wireless scan
(3) 30 seconds into wireless scan - disable traffic-monitor ( to prevent scan loops! )
(4) 5mins after scheduler task started - scheduler disables traffic-monitor (this to ensure max time traffic monitor can remain active is 5mins - once again preventing scan loops!)
Screenshot 2020-11-25 at 20.10.28.png