1
0
mirror of https://github.com/librenms/librenms-agent.git synced 2024-05-09 09:54:52 +00:00
Files
librenms-librenms-agent/snmp/powerdns.py
Jellyfrog 61064dc9fe Cleanup some code (#355)
* Format with isort

* Format with Black

* Fix CRLF

* Format with shellcheck

* Fix some warning

* Fix PHP style

* Dont modifiy check_mk files

* Fixes
2021-03-18 12:24:30 +01:00

29 lines
545 B
Python
Executable File

#!/usr/bin/env python
import json
import subprocess
pdnscontrol = "/usr/bin/pdns_control"
process = subprocess.Popen(
[pdnscontrol, "show", "*"], stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
input = process.communicate()
stdout = input[0].decode()
stderr = input[1].decode()
data = {}
for var in stdout.split(","):
if "=" in var:
key, value = var.split("=")
data[key] = value
output = {
"version": 1,
"error": process.returncode,
"errorString": stderr,
"data": data,
}
print(json.dumps(output))