paulbsd-salt/states/zabbix/scripts/systemd_discovery.py
2020-11-09 09:40:59 +01:00

13 lines
360 B
Python
Executable File

#!/usr/bin/python3
import subprocess
import json
ret = {"data": []}
output = subprocess.run("systemctl list-unit-files | grep -E '\.service\s+(generated|enabled)' | awk -F'.service ' '{print $1}'", shell=True, capture_output=True).stdout
for line in output.splitlines():
ret["data"].append({"{#SERVICE}": line.decode("utf-8")})
print(json.dumps(ret))