updated zabbix state
This commit is contained in:
parent
8170ebddd1
commit
cee0c05fb6
@ -1,17 +1,25 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
# vim: ft=python
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import json
|
import json
|
||||||
|
import re
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
ret = {"data": []}
|
ret = {"data": []}
|
||||||
output = subprocess.run("""
|
output_list = subprocess.run("""
|
||||||
systemctl list-unit-files | grep -E '\.service\s+(generated|enabled)' | awk -F'.service ' '{print $1}'
|
systemctl list-unit-files | grep -E '\.service\s+(generated|enabled)' | awk -F'.service ' '{print $1}'
|
||||||
""",
|
""",shell=True,capture_output=True).stdout
|
||||||
shell=True,
|
|
||||||
capture_output=True).stdout
|
|
||||||
|
|
||||||
for line in output.splitlines():
|
for line in output_list.splitlines():
|
||||||
|
output_is_enabled = subprocess.run(f"""
|
||||||
|
systemctl is-enabled {line.decode("utf-8")}
|
||||||
|
""",shell=True,capture_output=True).stdout.decode('utf-8')
|
||||||
|
#output_is_active = subprocess.run(f"""
|
||||||
|
# systemctl is-active {line.decode("utf-8")}
|
||||||
|
# """,shell=True,capture_output=True).stdout.decode('utf-8')
|
||||||
|
|
||||||
|
if re.match("^enabled", output_is_enabled) is not None:
|
||||||
ret["data"].append({"{#SERVICE}": line.decode("utf-8")})
|
ret["data"].append({"{#SERVICE}": line.decode("utf-8")})
|
||||||
|
|
||||||
return json.dumps(ret)
|
return json.dumps(ret)
|
||||||
|
Loading…
Reference in New Issue
Block a user