Community discussions

MikroTik App
 
mikuser
just joined
Topic Author
Posts: 6
Joined: Mon Apr 04, 2011 1:11 pm

how to send ip pool info to syslog server

Mon Feb 25, 2013 10:10 am

hi
I need to store ip pool information like Owner-Address
how I can do this?
 
User avatar
jgellis
Member Candidate
Member Candidate
Posts: 139
Joined: Wed May 30, 2007 10:57 am
Location: USA

Re: how to send ip pool info to syslog server

Mon Feb 25, 2013 9:12 pm

RouterOS v6 includes the dhcp-server lease-script command. Very little/no documentation exists, so try the following in a controlled environment first. Due to lack of documentation or lack of features, it may not be able to provide details on the specific lease that was just obtained, so the below outputs all IPs on every change. Because of this simplicty, in versions prior to 6, you should just be able to run this as a scheduler event every so often, per your requirements.

Setup syslogging (update this invalid IP to your syslog server):
/system logging
action add name=syslog target=remote remote=192.168.999.999
add action=syslog topics=script,info
In the dhcp-server script on v6 or a scheduler event, use the :log command to log the appropriate data like so:
:global IpPoolUsedAddresses ""
:foreach lease in=[/ip pool used find owner=DHCP] do={
   :if ([:len $IpPoolUsedAddresses]=0) do={
      :global IpPoolUsedAddresses [/ip pool used get $lease value-name=address]
   } else={
      :global IpPoolUsedAddresses ($IpPoolUsedAddresses . ", " . [/ip pool used get $lease value-name=address])
   }
}
:log info message= $IpPoolUsedAddresses

Who is online

Users browsing this forum: Frostbite1991, lubara and 185 guests