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
With "--plain" on Ubuntu 22.04
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.
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
With "--plain" on Ubuntu 22.04
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.