From 9b243a4ee4e58406df4fecc4f98f7b701cc26f18 Mon Sep 17 00:00:00 2001 From: Ed Tanous Date: Fri, 3 Aug 2018 14:33:10 -0700 Subject: Make dbus monitor compatible with phosphor-rest This patchset makes the dbus monitor compatible with the upstream dbus monitor, which should help adoption. Performance seems greatly improved compared to the python implementation. The example given in the documentation of watching for sensors and state changes is checked in as a test script websocket_test.py, and seems to consume less of the CPU than the actual sensors that get produced (about 4% CPU on my ast2500) when producing 30 sensor updates per second. This can likely be improved in the future by batching change events, but it seems to be performant enough for the moment. Tested: Used test script checked in, and verified webui can register state change events properly. Change-Id: I7d4c61d0259b7773eb46df0f59f8fea1c7796450 Signed-off-by: Ed Tanous --- scripts/websocket_test.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 scripts/websocket_test.py (limited to 'scripts') diff --git a/scripts/websocket_test.py b/scripts/websocket_test.py new file mode 100644 index 0000000..8d9c8ae --- /dev/null +++ b/scripts/websocket_test.py @@ -0,0 +1,21 @@ +import json +import ssl +import websocket + +websocket.enableTrace(True) + +ws = websocket.create_connection('wss://10.243.48.93:18080/subscribe', + sslopt={"cert_reqs": ssl.CERT_NONE}, + cookie="XSRF-TOKEN=m0KhYNbxFmUEI4Sr1I22; SESSION=0mdwzoQy3gggQxW3vrEw") +request = json.dumps({ + "paths": ["/xyz/openbmc_project/logging", "/xyz/openbmc_project/sensors"], + "interfaces": ["xyz.openbmc_project.Logging.Entry", "xyz.openbmc_project.Sensor.Value"] +}) + +ws.send(request) +print("Sent") +print("Receiving...") +while True: + result = ws.recv() + print("Received '%s'" % result) +ws.close() -- cgit v1.2.3