Works on my end.
What is the error you are getting when running it in the terminal?
I did have a few issues with the file content not being written at first because the file took a second to be created, which is why I added the “:delay 1” call.
700 queues? O_O
Well, what is the error message when you paste the script into the terminal?
The HDD writes every 1.5s, so if you’re using 1s, you’re gambling on exactly when the HDD read and writes are going to be. The other router is on a lucky streak, but it would eventually start to fail as well with 1s.
hAP lite with 700 queues? No wonder it’s failing… The script is probably resorting to using the HDD as RAM (“swap”), but by then it becomes so slow that the script times out.
EDT: Oh wait, you’re saying that one is working… But is it one with just 20 queues? And the CCR has 700 queues? Well, either way…
I suggest you rethink your approach to the problem. The API seems to be the way to go - from a remote device, just call “print” (as Deantwo showed), and write the results to wherever in whatever format you want. If you insist on storing them at the router, that’s fine too, just use the API to actually traverse and generate the thing. This will consume much less memory at the router, and instead consume that memory at the device where the API application is running.
Neither the installation nor the code needed is (too) complicated. The only real downside is the presence of an additional device in the overall scheme of things.
well, actually i was working with different approach. i was storing information with simple command "/queue simple print stats file=$filename " and sending the file to remote linux machine for further processing with the help of perl and php . it would be easy for me if i can sent only required information in one line .
i never tried mikrotik api . what u think ? should i study api or sending raw file to linux machine is ok .. ?
This sounds like a billing issue - why not play with RADIUS accounting, since that naturally sends you statistics such as how much data the user transferred…
few times in googling i found documentation about radius+mikrtoik is for pppoe or hotspot. i am using static ip addresses for each client. is it possible to collect download upload data regularly from simple queue with queue name and ip address through radius server ??
No - RADIUS is for session authentication and accounting, so a static-assigned interface wouldn’t be able to do anything with RADIUS.
Probably an SNMP-based solution would be helpful if each user has their own interface that you can poll - or it might be possible that the queues’ statistics are available as SNMP-readable OIDs…
I know this is the old thread but I did find this script useful to export queue stats every months (and then reset them). BUT this script was (and still is) limited due to variable size 4096 bytes (see here http://forum.mikrotik.com/t/how-to-write-string-to-a-file-using-script/99624/1 ). That is why if you try to export more than ~20 queues it does not work - the $message variable cannot hold so much strings . So I was thinking if I could write every queue stats separately one by one and append it to the file (the same like /log print append file= … does), but it is probably still not available (ROS 6.49.2 or ROS 7.2RC3) ? Otherwise you have to always read current content of the file first and it is the same problem
Maybe read every queue to separate message variables (message1, message2…) and then somehow write to file all these messages (i.e. 500) one by one to that output file? Is there any solution to this task in 2022? Thanks.
You can send each data line to syslog server instead of a file. Then you can use an external server to examine logs.
Should be easy to implement to my Splunk/Mikrotik prosjekt. See signature.
Thanks for reply! Could you be please more specific and put here the whole line with :log info message command? i have probably some syntax error there, does not work.