Skip to content Skip to sidebar Skip to footer

Python Errno 23 - Socket Livestatus

I'm trying to send two queries to the server with this script, to get the MK Livestatus: live.py #!/usr/bin/python socket_path = '/tmp/run/live' import socket s = socket.socket(soc

Solution 1:

so ... I've written a function that does the job :-)

Function

def sendQuery(query):
    s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    s.connect(socket_path)
    s.send(query)
    s.shutdown(socket.SHUT_WR)

    answer = ''
    while True:
        data = s.recv(1024)
        answer += data
        if len(data) < 1024:
            break

    s.close()
    return answer

Usage

sendQuery("GET hosts\nColumns: name\n")

Post a Comment for "Python Errno 23 - Socket Livestatus"