Skip to content

Updated systemctl command + regex - #2

Open
AndrewMRQuinn wants to merge 1 commit into
Puppet-Finland:masterfrom
AndrewMRQuinn:SystemctlFixes
Open

Updated systemctl command + regex#2
AndrewMRQuinn wants to merge 1 commit into
Puppet-Finland:masterfrom
AndrewMRQuinn:SystemctlFixes

Conversation

@AndrewMRQuinn

@AndrewMRQuinn AndrewMRQuinn commented Oct 2, 2023

Copy link
Copy Markdown

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.

Added "--plain" to systemctl command to omit bullets, and updated  regex to allow dashes in sub-state
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.

1 participant