feat: add multi-distro reboot-required SNMP extend script - #633
Open
ahoogerhuis wants to merge 2 commits into
Open
feat: add multi-distro reboot-required SNMP extend script#633ahoogerhuis wants to merge 2 commits into
ahoogerhuis wants to merge 2 commits into
Conversation
Detects whether a host needs a reboot to apply a pending kernel or library update. Self-detects the distro family via /etc/os-release ($ID/$ID_LIKE) instead of shipping separate per-distro scripts: - Debian/Ubuntu: /var/run/reboot-required file existence - RHEL/CentOS/Rocky/Alma/Fedora/Amazon Linux: needs-restarting -r - SUSE/SLES/openSUSE: zypper needs-rebooting - Arch: compare running kernel against /usr/lib/modules On an unrecognized distro or a missing detection tool, exits non-zero with no output rather than guessing, so a poll error is surfaced instead of a silent false "no reboot needed".
bennetgallein
approved these changes
Sep 3, 2026
bennetgallein
requested changes
Sep 3, 2026
bennetgallein
left a comment
Member
There was a problem hiding this comment.
should switch to emitting json. Probably not "easy" in bash (doable) but a short python version is probably prefered
Author
One rewrite coming up shortly. |
Per maintainer feedback on librenms#633: rewrite as Python, emitting the standard {version, error, errorString, data} envelope used by 27 other scripts in this directory, instead of a bare "1"/"0" on stdout. Detection logic is unchanged -- same four distro-family checks (Debian/Ubuntu via /var/run/reboot-required, RHEL-family via needs-restarting -r, SUSE via zypper needs-rebooting, Arch via kernel-module-dir comparison), same exit-code semantics per family. Only the output format and the unsupported-distro/missing-tool signal changed: previously a silent non-zero exit, now error=1 with a descriptive errorString in the envelope, which the core-side json_app_get() consumer surfaces as a poll error the same way. Modeled on snmp/backupninja.py + backupninja.inc.php (core repo) -- the simplest existing json_app_get()-based app found, not snmp/systemd.py which is a much richer multi-metric structure.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The extend script consumed by librenms/librenms#20446 (the companion application-module PR on the core repo). Self-detects distro family via
/etc/os-release($ID/$ID_LIKE) and delegates to the appropriate native check per family, rather than shipping separate scripts.Debian/Ubuntu via
/var/run/reboot-required, RHEL/CentOS/Rocky/Alma/Fedora/Amazon Linux vianeeds-restarting -r, SUSE/SLES/openSUSE viazypper needs-rebooting, Arch via comparing the running kernel against installed modules. Exits non-zero with no output on an unrecognized distro or missing tool, rather than guessing.On AI assistance: this script involved AI-assisted development (Claude, plus Claude Code), reviewed and verified by me before submission.