Hi, I’m using a router OS as my main DHCP Server, i have various pools, some of them privates IP and others public IP ranges.
I would like to set up some cacti graphs for know (and demonstrate to RIPE) the use of our public IP pools.
I’ve tried in SNMP but i’ve not got the answer I expected.
Also tried in terminal but i’ve only found this command:
You can give that print command regular expressions to match.
For example, to count only leases that start with “1.1.1.”:
/ip dhcp-server lease print count-only where address~"1.1.1."
If you have multiple ranges you can collect them and add them up:
{
:local first [/ip dhcp-server lease print count-only where address~"1.1.1."];
:local second [/ip dhcp-server lease print count-only where address~"2.2.2."];
:local total ($first + $second);
:put $total
}
Hope that helps. You can very probably do this via SNMP by walking DHCP lease tables or ARP tables if there are no lease tables available. Fetch all results externally and pipe them through something like Perl to find the IPs you’re interested in, then add up the number of entries. Right now I’m not in a position where I can try that for you, though.
I have got a default pool with private addresses and I assign public pool addresses by static router’s mac entries so this little change worked for me:
/ip dhcp-server lease print count-only where active-address~"1.1.1."
I can use this perfectly for get the values in a PHP script using MK API and graph this with Cacti so thanks is what i need : )