So since last September and initially instigated by Tony (murrant) we’ve been working on refactoring a lot of the discovery, polling and alerting code base. Some of this has caused a bit of pain along the way but we are getting there with it. The cleanup started with OS discovery and the addition of unit testing so that we could ensure future changes wouldn’t break existing device support – something which has happened before. Along with that, other areas of improvement include:
– Improved sensor polling to make use of multiple snmp calls per sensor type rather than calling them singularly.
– A tidy up of all of the MIBs that we have including removing duplicates and moving vendor specific mibs into separate sub directories.
– A more centralised include system to avoid including files within files within files.
– Various poller performance improvements to boost overall efficiency.
– Switched OS definitions from being part of the global `$config` variable to using separate yaml based config files (`includes/definitions/*.yaml`)
Why have we put some focus in to these things? LibreNMS has become quite popular, more so than we could have expected and because of this naturally the number of issues have also increased whether that’s from feature requests or bugs. In trying to improve the code base and introduce unit testing we can hopefully lower the barrier of entry for people to contribute whilst ensuring the code stays clean and bug free.
One example of the improvements these changes have had is in the previously mentioned global `$config` array that we inherited. All of the softwares configuration was within that array which has it’s benefit that it’s available pretty much anywhere within the code base, however it also means that it’s a bloaty array and would continue to grow in size. A recursive count of `$config` before some of this refactor work stood the size at 4161 items – yes, over 4,000 items! After the refactor work, the recursive count of `$config` stands at 1696. That’s an enormous difference, over half where we started out.
Along that way, things broke, nothing badly but we have introduced regression and bugs in to the OS discovery process, the WebUI and sometimes data collection which we always strive to avoid. We can’t promise that this won’t happen again as we have a lot more work to do going forward but we will continue to aim to provide an amazing NMS for you to use that you can rely on. One thing we are doing to make sure things are better tested in the future is enabling more data collection for stats.librenms.org by collecting sysObjectIds and sysDescr for more robust unit testing, see https://community.librenms.org/t/greater-statistics-collection-for-improved-os-detection/441 for more info.
As always, if you want to get involved with the rest of the team @ LibreNMS then please get in touch – you don’t need to be able to code to help make a difference.