Skip to content

feat: add multi-distro reboot-required SNMP extend script - #633

Open
ahoogerhuis wants to merge 2 commits into
librenms:masterfrom
ahoogerhuis:reboot-required
Open

feat: add multi-distro reboot-required SNMP extend script#633
ahoogerhuis wants to merge 2 commits into
librenms:masterfrom
ahoogerhuis:reboot-required

Conversation

@ahoogerhuis

Copy link
Copy Markdown

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 via needs-restarting -r, SUSE/SLES/openSUSE via zypper 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.

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 bennetgallein left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should switch to emitting json. Probably not "easy" in bash (doable) but a short python version is probably prefered

@ahoogerhuis

Copy link
Copy Markdown
Author

should switch to emitting json. Probably not "easy" in bash (doable) but a short python version is probably prefered

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants