Licenses: Updated the list of licenses and added a PDF containing all license texts
[check_mk.git] / doc / mkeventd / query_events
blob9a1b0f7f4f3971e7412bcda67e0e2b65366e8ee7
1 #!/usr/bin/python
2 # Example program for accessing status of event console
4 import socket, os
6 # Create Unix socket and connect to status socket
7 path = os.getenv("OMD_ROOT") + "/tmp/run/mkeventd/status"
8 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
9 sock.connect(path)
11 # Send query
12 sock.send("GET events\nFilter: event_phase = open")
14 # Read response and convert Python source to Python object
15 response_text = ""
16 while True:
17 chunk = sock.recv(8192)
18 response_text += chunk
19 if not chunk:
20 break
21 response = eval(response_text)
23 # The name of the column headers are the first item of the result list
24 headers = response[0]
26 # Output all results
27 for row in response[1:]:
28 with_headers = zip(headers, row)
29 with_headers.sort()
31 for key, value in with_headers:
32 print "%-20s: %s" % (key, value)
33 print