What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Diversion Asuswrt-Merlin-gnuton Stats not considering correct DHCP range

hribcek

New Around Here
I've seen two issues when diversion is doing a backup of ipleases to /tmp/divstats-iphostleases.txt.

1. When trying to get check whether the hostname is known or it should put "(Name-N/A)", it uses this:
Bash:
    if grep -wq "$i *" /var/lib/misc/dnsmasq.leases; then
            echo " $i (Name-N/A)" >>/tmp/divstats-iphostleases
        else
            echo " $(awk -v var="$i" -F' ' '$3 == var{print $3, $4}' /var/lib/misc/dnsmasq.leases)" >>/tmp/divstats-iphostleases
        fi
    fi

The issue is that grep always ends up in the first branch and outputs (Name-N/A) even when the name is present. The correct way to do this is to escape * so it will look like:
Code:
 if grep -wq "$i \*" /var/lib/misc/dnsmasq.leases; then
or alternatively:
Code:
 if grep -Fq "$i *" /var/lib/misc/dnsmasq.leases; then

2. Diversion assumes that DHPC leases are done within in the network where only the last number of IPv4 is changing (i.e. DHCP range is defined like 192.168.1.2 - 192.168.1.254). If falls short if it's not.
I've split my network and I'm using wider range (my DHCP range is 172.1x.0.2 - 172.1x.255.254).

The changed code (with the change for the point 1 as well) for your consideration is this gist.
It replaces the code in file functions.div in function c_stats, the case block for value 5.

My router is:
RT-AX82U (armv7l) Kernel-4.1.52
FW-3004.388.92-gnuton2 @ *my.local.ip*

Thanks,
 

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top