Comments as variables?

Hello Mikrotik Scriptors,

Not sure if any one has done this but I was just thinking of applications for using the comment fields as variables. I am sure some one else has already thought of this but I thought it would be a really great way to hold a few variables.

My question is; how big can a comment field be?

Application would be that of having a CPE scan as a workstation and dump its scan to a comment field. This would make it searchable via a get I am not sure how to do this from a file that is why I would use a comment field. This could then scan for a stronger allowed connection or report info to a WISP about what a CPE sees remotely.

Any thoughts would be appreciated. Thank you.

-Sincerely,
DesertAdmin

I know it’s been talked about before (link 1, link 2)…

In winbox, the comment box is limited to 30,000 characters, which ends up being at 30KB. Writing to a file is limited to 4KB.

How much data will a scan generate?

I tried setting a simple queue comment with this number of characters, and it saved ok, but when I tried to do this in the terminal,

:put [/queue simple get queue1 comment]

it locked up the router, and even a reboot didn’t fix it, lol. In Tools > Profile, the Management cpu usage was 90%+ until I reset config.

Reading/writing to a file can be done like this:

# create the file
/file print file=myFile
# set file contents
/file set myFile.txt contents="some text";
# get file contents, save as variable
:local myVar [/file get myFile.txt contents]

Curious what kind of board were you using? I didn.t think about CPU use but yeah if it is a MT 1XX series board its CPU would be shot, for a 4XX series it should be ok. Which one were you testing on. I will be only using this on a 4XX series and greater; even though I do have a ton of RB 133C and 112’s on my network :laughing:

-Sincerely,
DesertAdmin

I was using a 450G.

I probably shouldn’t have maxed out the comment field on my first test… probably should have started small and worked up to larger strings.

if you use excessively large comments you can run into trouble when you use CLI or winbox that have to show that comment. If you do not use some menu or work around to not to use that, you can “comment” a lot.

for example, create empty file and add a “comment” to it. Just save configuration, if comment is very large, you can run into problems and will have to reset configuration to clear the comment field. As temporary storage that is quite usable - read something, “comment” use the data for a while then remove.


edit: in the end i ended up with API tool to do/store everything off-site with small sqlite DB as backend. of course i am not connecting to router via wireless and not disconnecting the link :slight_smile: