Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions systemd-service-status.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def cache_service_status(self):
# Temporary data structure used to create sorted oid list later
oids = [self.oid_prefix]

lines = subprocess.check_output(["/bin/systemctl", "list-units", "-a", "-t", "service", "--no-legend"]).decode("UTF-8").split("\n")
lines = subprocess.check_output(["/bin/systemctl", "list-units", "-a", "-t", "service", "--no-legend", "--plain"]).decode("UTF-8").split("\n")

for line in lines:
# Filter out systemd services that are service instance "templates" and
Expand All @@ -47,7 +47,7 @@ def cache_service_status(self):
#
# Regular expression can be easily tested online, e.g. here: https://pythex.org
#
result = re.search(r"^(.+)\.service\s+[\w|-]+\s+\w+\s+(\w+)\s+.*$", line)
result = re.search(r"^(.+)\.service\s+[\w|-]+\s+\w+\s+([\w|-]+)\s+.*$", line)
service_name = result.group(1)
service_status = result.group(2)

Expand Down