Hey Guys, I have the following code to show me my checkmk services. But it doesnt show me the intended informartion. When I type the statement into the lql on the checkmk-server I do get the right information. Can anyone help me?
In addition I get the following exception:
line 19: chunks.append(sock.recv(4096))
ConnectionResetError: [Errno 104] Connection reset by peer
import json, os, socket, ssl
address = (‘************’, 6556)
family = socket.AF_INET if type(address) == tuple else socket.AF_UNIX
sock = socket.socket(family, socket.SOCK_STREAM)
context = ssl.create_default_context()
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
sock.connect(address)
sock.sendall(f’GET services\nColumns: host_name description plugin_output state acknowledged\nTimelimit: 30\nOutputFormat: json\n\n’.encode())
chunks = []
while len(chunks) == 0 or chunks[-1] != “”:
chunks.append(sock.recv(4096))
print(chunks)
sock.close()
reply = “”.join(chunks)
print(json.loads(reply))