diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-06-21 21:56:59 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-06-21 22:10:44 +0200 |
commit | 1328d62f9d3a2eb9f089d531614302005c29ec37 (patch) | |
tree | 17c179b21813f3dbea0d83535d0523dd411908f8 /doc/stats_dabmux_multi.py | |
parent | 711f52b5a1f114ae911d0e072498c81831c0b814 (diff) | |
download | dabmux-1328d62f9d3a2eb9f089d531614302005c29ec37.tar.gz dabmux-1328d62f9d3a2eb9f089d531614302005c29ec37.tar.bz2 dabmux-1328d62f9d3a2eb9f089d531614302005c29ec37.zip |
Replace MGMT socket by ZMQ, make services shared_ptr
Diffstat (limited to 'doc/stats_dabmux_multi.py')
-rwxr-xr-x | doc/stats_dabmux_multi.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/doc/stats_dabmux_multi.py b/doc/stats_dabmux_multi.py index 7c21d84..a2587a4 100755 --- a/doc/stats_dabmux_multi.py +++ b/doc/stats_dabmux_multi.py @@ -5,11 +5,9 @@ import sys import json -import socket +import zmq import os -SOCK_RECV_SIZE = 10240 - config_top = """ """ @@ -72,6 +70,8 @@ right.warning -40:0 right.critical -80:0 """ +ctx = zmq.Context() + if not os.environ.get("MUNIN_CAP_MULTIGRAPH"): print("This needs munin version 1.4 at least") sys.exit(1) @@ -81,10 +81,11 @@ def connect(): returns: the socket""" - sock = socket.socket() - sock.connect(("localhost", 12720)) + sock = zmq.Socket(ctx, zmq.REQ) + sock.connect("tcp://localhost:12720") - version = json.loads(sock.recv(SOCK_RECV_SIZE)) + sock.send("info") + version = json.loads(sock.recv()) if not version['service'].startswith("ODR-DabMux"): sys.stderr.write("Wrong version\n") @@ -94,8 +95,8 @@ def connect(): if len(sys.argv) == 1: sock = connect() - sock.send("values\n") - values = json.loads(sock.recv(SOCK_RECV_SIZE))['values'] + sock.send("values") + values = json.loads(sock.recv())['values'] munin_values = "" for ident in values: @@ -115,9 +116,9 @@ if len(sys.argv) == 1: elif len(sys.argv) == 2 and sys.argv[1] == "config": sock = connect() - sock.send("config\n") + sock.send("config") - config = json.loads(sock.recv(SOCK_RECV_SIZE)) + config = json.loads(sock.recv()) munin_config = config_top @@ -125,4 +126,6 @@ elif len(sys.argv) == 2 and sys.argv[1] == "config": munin_config += config_template.format(ident=conf) print(munin_config) +else: + sys.exit(1) |