SNMP Number of DHCP lease used in pool

Hi all
I’m using routerboard for big wifi hotspot.
I’m using too a supervision system wich is nagios based with trafic, CPU and a lot of information.

I’d like to monitor the number of DHCP lease in the pool of one or several subnet.
Just one for the moment will be very good.

I don’t find the good OID and don’t find any script on the web.

I try near OIB 9999 with
snmpwalk -v 2c -c XXX HHHH .1.3.6.1.2.1.9999
but I obtained just the list of IP address I think…

I dont’ nead to have lease list but just the number of uses lease.
Bonus is to have number of pool remaining (so the total number of pool)

Thanks for your help

For example :
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.4.10.2.66.62 = INTEGER: 2
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.4.10.2.66.71 = INTEGER: 2
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.4.10.2.66.74 = INTEGER: 2
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.4.10.2.66.92 = INTEGER: 2

SNMPv2-SMI::mib-2.9999.1.1.6.4.1.5.10.2.67.198 = Gauge32: 1498
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.5.10.2.67.199 = Gauge32: 1626
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.5.10.2.67.202 = Gauge32: 1734
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.5.10.2.67.208 = Gauge32: 1163

SNMPv2-SMI::mib-2.9999.1.1.6.4.1.7.10.2.66.62 = INTEGER: 3
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.7.10.2.66.71 = INTEGER: 3
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.7.10.2.66.74 = INTEGER: 3
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.7.10.2.66.92 = INTEGER: 3

SNMPv2-SMI::mib-2.9999.1.1.6.4.1.8.10.2.66.62 = Hex-STRING: BC 4C C4 88 B3 ED
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.8.10.2.66.71 = Hex-STRING: FC FC 48 41 0C D7
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.8.10.2.66.74 = Hex-STRING: CC AF 78 6C C3 8A
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.8.10.2.66.92 = Hex-STRING: F0 4F 7C 04 34 03

You can do an OID count, that’s how I monitor the number of connected devices to the wireless interface of a MikroTik:

/usr/bin/snmpwalk : -v 1 -c | /usr/bin/wc -l

I’m not familiar with Nagios specifically, but that’s the script I have in place for my Cacti server for couting the OIDs.

Do a MIB Walk and save the output to a file.

Open the file in something like Notepad++ and search for DHCP. It should be arround .1.3.6.1.2.1.9999.1.1.1.1.0.

The next OID will tell you where to look in the walk to find the DHCP server information. Mine returned 1.3.6.1.4.1.14988.1

Looking under there the number of active leases for my single scope was in .1.3.6.1.4.1.14988.1.1.6.1.0 There should be a Gauge32 value for each scope.

I have skipped use SNMP, since I need to set up SNMP for each new router. Instead I make the router send me the data using Syslog, including DHCP pool information.

See how to use Splunk with MikrotTik using link in my signature. Or click here to just show the DHCP example. http://forum.mikrotik.com/t/tool-using-splunk-to-analyse-mikrotik-logs-3-3-graphing-everything/121810/2

This is not correct, there always is only a single number (the total number of entries) there even when you have more than one DHCP scope!
To find the number of leases per scope you need to walk the .1.3.6.1.2.1.9999.1.1.6.4.1.4 OID and group/count the entries (the address is part of the OID, the value of each entry is the type static/dynamic/waiting).

Seems to be a bug in RouterOS when getting DHCP information. I have around 200 addresses in my DHCP scopes. This show the bottom part of the log, and you see snmpwalk from linux fails not getting all leases.

...
...
...
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.4.10.10.10.170 = INTEGER: 3
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.4.10.10.10.171 = INTEGER: 3
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.4.10.10.10.172 = INTEGER: 3
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.4.10.10.10.173 = INTEGER: 3
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.4.10.10.10.174 = INTEGER: 3
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.4.10.10.20.174 = INTEGER: 3
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.4.10.10.10.175 = INTEGER: 3
Error: OID not increasing: SNMPv2-SMI::mib-2.9999.1.1.6.4.1.4.10.10.20.174
 >= SNMPv2-SMI::mib-2.9999.1.1.6.4.1.4.10.10.10.175

That is true, it is a bug in RouterOS but you can work around it by passing the “-Cc” flag to snmpwalk.
(I would recommend using snmpbulkwalk -v2c for such long lists, but it requires the same flag to work around this bug)

snmpbulkwalk -Cc -v2c -c public router .1.3.6.1.2.1.9999.1.1.6.4.1.4

works fine here.

That did the trick. Thanks.

Hi,

One year later but.. there are an OID to get this value → MIKROTIK-MIB::mtxrDHCPLeaseCount.0

Regards :wink:

This was already mentioned in reply #3, the OID .1.3.6.1.4.1.14988.1.1.6.1.0 is the numeric value of MIKROTIK-MIB::mtxrDHCPLeaseCount.0
However, there is always only a .0 and there is no separate DHCPLeaseCount per pool or per DHCP scope.
That is why the solution is to walk the list of DHCP leases and group them by address in some external script.

This is great. Thank you all.

Total number of leases is sufficient for my purposes, though I can certainly see a use case for getting the totals of each pool (and count of pools) if the RouterOS devs are ever bored (unlikely).

Next question: Is there a way to get a count of “available” dhcp leases or a count of “remaining” dhcp leases?
I’d like to set up a Zabbix trigger to tell me if the pool is nearing exhaustion. ie: % of remaining available leases is less than 20.

Thanks again.

No, it is not available. You will have to write your own script to count the number of leases and calculate the percentage based on the size of your pools.
You can do this on the system running Zabbix or (in theory) also on the router itself, because you can write RouterOS scripts that are invoked when you read a user-defined OID.
But I am not going to help you with that! Writing and debugging RouterOS scripts is a frustrating affair.