Puppet-Finland / net-snmp-systemd-service-status

A Net-SNMP "pass" extension script that generates "is service up" data for all detected systemd services
BSD 2-Clause "Simplified" License
4 stars 1 forks source link

Updated systemctl command + regex #2

Open AndrewMRQuinn opened 1 year ago

AndrewMRQuinn commented 1 year ago

Thanks for the script! I found a couple of issues when testing and wanted to share the tweaks we made.

On some distros the "systemctl list-units" output contains an additional column to the left that can contain bullet points. This results in space and/or bullet characters being encoded as part of the OID. Adding "--plain" to the systemctl command prevents these bullets from being printed and interpreted as part of the service name.

Without "--plain" on Ubuntu 22.04 image

With "--plain" on Ubuntu 22.04 image

We also found that the sub-state for some services could be "auto-restart", which failed to match the existing regex because of the dash character. I've tweaked it to accept a dash.

We've tested the changes on AlmaLinux 8.8, CentOS 7, Debian 12, Kali Linux, Rocky Linux 9.2, openSUSE Leap 15.5, Ubuntu 18.04, and Ubuntu 22.04.