diff options
Diffstat (limited to 'plugins/livestatus.py')
-rw-r--r-- | plugins/livestatus.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/plugins/livestatus.py b/plugins/livestatus.py index 9fc2ad7..4145c70 100644 --- a/plugins/livestatus.py +++ b/plugins/livestatus.py @@ -41,13 +41,31 @@ def readLiveStatus(cmd): s.shutdown(socket.SHUT_WR) # Read the answer - answer = s.recv(1000) + answer = s.recv(8192) # Parse the answer into a table table = [line.split('|') for line in answer.split('\n')[:-1]] return table +def readLiveStatusAsJSON(cmd): + cmd += "OutputFormat: json\n" + s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + s.connect(_socketPath) + + # Write command to socket + s.send(cmd) + + # Close socket + s.shutdown(socket.SHUT_WR) + + # Read the answer + answer = s.recv(8192) + + # return the result + return answer + + def checkLiveStatus(cmd): s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s.connect(_socketPath) |