Community discussions

MikroTik App
 
eddieb
Member
Member
Topic Author
Posts: 327
Joined: Thu Aug 28, 2014 10:53 am
Location: Netherlands

count number of rows matching in oid ?

Thu May 03, 2018 12:46 pm

Hi,

I want to count the number of dhcp leases in ROS,
for now I use

array_find(oid_column("1.3.6.1.2.1.9999.1.1.6.4.1.4"),"dynamic (2)")

but array_find only returns the number of the first row in the array where it finds "dynamic (2)".
So, great to find IF there are any dynamic leases ...
It returns 8 here because that is the 1st row which matches.
BUT I want to count the number of rows which contain "dynamic (2)"

any suggestions ?
 
pe1chl
Forum Guru
Forum Guru
Posts: 10234
Joined: Mon Jun 08, 2015 12:09 pm

Re: count number of rows matching in oid ?

Thu May 03, 2018 2:19 pm

You might want to know that the OID .1.3.6.1.4.1.14988.1.1.6.1.0 (MIKROTIK-MIB::mtxrDHCPLeaseCount.0) directly returns the total number of leases.
 
eddieb
Member
Member
Topic Author
Posts: 327
Joined: Thu Aug 28, 2014 10:53 am
Location: Netherlands

Re: count number of rows matching in oid ?

Thu May 03, 2018 3:41 pm

That wil give me the total number, including the expired ... I want the total for active static and active dynamic
 
pe1chl
Forum Guru
Forum Guru
Posts: 10234
Joined: Mon Jun 08, 2015 12:09 pm

Re: count number of rows matching in oid ?

Thu May 03, 2018 4:04 pm

It does not include the expired leases. But it does include the static ones.
 
eddieb
Member
Member
Topic Author
Posts: 327
Joined: Thu Aug 28, 2014 10:53 am
Location: Netherlands

Re: count number of rows matching in oid ?

Thu May 03, 2018 4:14 pm

That is strange, it does here :

snmpwalk -v2c -c public -On mt .1.3.6.1.4.1.14988.1.1.6.1
.1.3.6.1.4.1.14988.1.1.6.1.0 = Gauge32: 66

snmpwalk -v2c -c public -On mt .1.3.6.1.2.1.9999.1.1.6.4.1.4 | wc -l
66

the array .1.3.6.1.2.1.9999.1.1.6.4.1.4 includes the expired static leases

static :
snmpwalk -v2c -c public -On mt .1.3.6.1.2.1.9999.1.1.6.4.1.4 | grep INTEGER\:\ 1 | wc -l
31

dynamic :
snmpwalk -v2c -c public -On mt .1.3.6.1.2.1.9999.1.1.6.4.1.4 | grep INTEGER\:\ 2 | wc -l
1

expired :
snmpwalk -v2c -c public -On mt .1.3.6.1.2.1.9999.1.1.6.4.1.4 | grep INTEGER\:\ 3 | wc -l
34
 
pe1chl
Forum Guru
Forum Guru
Posts: 10234
Joined: Mon Jun 08, 2015 12:09 pm

Re: count number of rows matching in oid ?

Thu May 03, 2018 4:27 pm

Ah expired static leases, I did not think of those (we don't have them as static leases are only used for equipment that is always on).
For sure it does not include expired dynamic leases.
 
eddieb
Member
Member
Topic Author
Posts: 327
Joined: Thu Aug 28, 2014 10:53 am
Location: Netherlands

Re: count number of rows matching in oid ?

Mon May 07, 2018 4:11 pm

tnx for thinking with me ...

any other suggestions ?

Who is online

Users browsing this forum: No registered users and 23 guests