-
Notifications
You must be signed in to change notification settings - Fork 5
Add IPv6 support and make hostname resolution more robust #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit adds support for dual-stack (IPv4 and IPv6) hosts by normalizing any IP addresses to a consistent format, and then summing the statistics for each host. This commit also makes the hostname resolution more robust by using the builtin `getHostHints` ubus procedure.
Thank you for your changes. I will apply them and will test it on my system. I am using only IPv4 so I can not verify IPv6 behaviour. Did you test it with IPv4/IPv6 clients? Is this working ok? I added the GPL 3 license to this project. This plugin has been created as replacement for Iptmon plugin which stopped working. Iptmon was using separate plugin_id for IPv4 and IPv6 data (IPv4 RRD files were stored in |
One more question, are you able to test if we still need following workaround?
For sure this was needed on openwrt 21.0 with really old routers, but maybe we do not need this on latest openwrt versions with modern hardware? |
Yup, all my devices have IPv6 addresses, and everything works as expected.
Perfect, thanks!
Correct.
Yes, if a device has both IPv4 and IPv6 addresses, nlbw2collectd/nlbw2collectd.lua Lines 96 to 104 in 266e910
I just tried it now without that, and it didn't work properly—as soon as a host exceeded 2^31-1, the value got stuck at 0 forever. I've submitted a patch upstream, but 8000 there hasn't been a release since 2020, so I have no idea if/when that will get merged. |
Thank you for your responses. I also applied your code to my Openwrt system and it works stable and without issues.
Thanks for opening issue against collectd. Perhaps one day they will include those changes. |
Currently, if you set a value larger than 2^31-1 from Lua on a 32-bit platform, collectd will truncate the value to 0, as this is what `lua_tointeger` returns on Lua 5.1 with a 32-bit `lua_Integer`. This commit modifies the `collectd-mod-lua` plugin to use `lua_tonumber` to first get the value as a float, and then cast it to the appropriate (>32 bit) integer type, ensuring that large values are not truncated. See also: - collectd/collectd#4369 - mstojek/nlbw2collectd#11 Signed-off-by: Max Chernoff <git@maxchernoff.ca>
Currently, if you set a value larger than 2^31-1 from Lua on a 32-bit platform, collectd will truncate the value to 0, as this is what `lua_tointeger` returns on Lua 5.1 with a 32-bit `lua_Integer`. This commit modifies the `collectd-mod-lua` plugin to use `lua_tonumber` to first get the value as a float, and then cast it to the appropriate (>32 bit) integer type, ensuring that large values are not truncated. See also: - collectd/collectd#4369 - mstojek/nlbw2collectd#11 Signed-off-by: Max Chernoff <git@maxchernoff.ca>
Good idea, I've submitted it in openwrt/packages#26824. |
Great! I hope that they will apply your patch to the Openwrt! |
This commit adds support for dual-stack (IPv4 and IPv6) hosts by normalizing any IP addresses to a consistent format, and then summing the statistics for each host. This commit also makes the hostname resolution more robust by using the builtin
getHostHints
ubus procedure.I've rewrote lots of the original code, so please let me know if there are any changes that you want me to make.
Also, I can't find any licences in this repository, so can you please add one? I'm okay with any open source licence, so pick whichever one you prefer.