Page 1 of 1

Problem with finding logging options

Posted: Wed Sep 11, 2019 5:22 pm
by danielrlbnco

I'm experiencing a problem trying to find current logging options in order to update them.

We currently have a large number of routers in the field, and only some of them are configured to send the logging topic "info" to the remote server.
I want to add that stanza to the routers that don't have it, but not add it to the routers that already have it.
We have a configuration system in place that can push commands to every router in our network, which has been successfully used in the past to push firewall updates to all routers.

The command that I expect to work is as follows:
if ([:len [/system logging find where action=remote and topics=info]]=0) do={/system logging add action=remote topics=info}

But I've checked the intermediate sections of the script, and the segment "/system logging find" doesn't work.

The below commands are run on a router which has the intended config stanza "/system logging add action=remote topics=info"
If I run the command "/system logging print where action=remote", the result is all of the logging actions configured with the action "remote", as expected.
But if I run the command "/system logging print where topics=info", I get no output, which is unexpected as there are two stanzas configured with the topic "info": memory (default config) and remote (added config)

Thanks in advance for any replies

Re: Problem with finding logging options

Posted: Wed Sep 11, 2019 5:36 pm
by danielrlbnco
I've figured out the solution. Apologies for the original post, I'm kinda drunk and the Mikrotik scripting language doesn't provide verbose errors.

The problem is that the "topics" option needs its variables to be quoted. So, the corrected command is as follows:
:if ([:len [/system logging find where action=remote and topics="info"]]=0) do={/system logging add action=remote topics="info"}

Moderators, you can close this topic/mark as solved