Community discussions

MikroTik App
Forum Veteran
Forum Veteran
Topic Author
Posts: 980
Joined: Fri May 26, 2006 1:25 am

add new log Topic for Dhcp Script logging vs normal scripts logging

Fri Nov 20, 2020 9:39 pm

Goal: Have an extra Log -> "Topics" tag added to dhcp-server run scripts. (ie like "dhcp" , so that we can distinguish them in /system logging action vs normal log entries from /sys script , scripts).

we have a script under /ip dhcp-server that makes a log of the "Active Host Name" of every dhcp-client (so that we retain this info in our remote logging system, as some customers want this data).

We also have several standard scripts ie /sys script with various :log info "xyz" entries for logging the status of when scripts are trigged by scheduler.

the issue is with a /system logging add action=scriptDiskLOG topics=script , our logs get filled up with all the /ip dhcp-server logs. (and there is no way to distinguish/sort them in /system logging action, as they both only have the log Topics of "script,info" - thus if you exclude one, you exclude both, in terms of /system logging action topics=script ).

(i hope im explaining this well, if not i can rephrase)
:beep :beep :beep
Forum Guru
Forum Guru
Posts: 6643
Joined: Mon Dec 04, 2017 9:19 pm

Re: add new log Topic for Dhcp Script logging vs normal scripts logging

Sat Nov 21, 2020 11:14 am

For feature requests, the official channel is your distributor, or you can find a dedicated topic here on the forum, created by Mikrotik staff for feature requesting.

As a quick help, you can use /log warning (or /log error) rather than /log info in your DHCP script, and set /system logging add topics=script,warning action=scriptDiskLOG.

Since you seem to forward the data from the log file to the remote logging system by means of another script, rather than to use /system logging action add target=remote name=remote-log-server directly, you could also misuse e.g an address-list for the purpose of appending the information to a dedicated file:
/ip firewall address list add list=dhcp-lease address=some.ip.add.ress comment="the real info you want to log" timeout=10s
/ip firewall address-list print file=leaseLOG append where list=dhcp-lease
/ip firewall address-list remove [find list=dhcp-lease]

But it is 6 lines per lease.
Instead of writing novels, post /export hide-sensitive. Use find&replace in your favourite text editor to systematically replace all occurrences of each public IP address potentially identifying you by a distinctive pattern such as my.public.ip.1.

Who is online

Users browsing this forum: abakisensoy, accarda, Baidu [Spider], Bing [Bot], LSan83, m94646602, sindy and 141 guests