From 05d8c7c8089f17b2b7e7e032dd2f198c8f4308a4 Mon Sep 17 00:00:00 2001 From: "@RubenKelevra" Date: Wed, 22 Jun 2016 01:23:34 +0200 Subject: [PATCH] add a servername to the graph to support multiple graphs per munin-node --- plugins/rethinkdb/rethinkdb_node_io | 31 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/plugins/rethinkdb/rethinkdb_node_io b/plugins/rethinkdb/rethinkdb_node_io index edda7fa1..ea7f9f40 100644 --- a/plugins/rethinkdb/rethinkdb_node_io +++ b/plugins/rethinkdb/rethinkdb_node_io @@ -1,18 +1,18 @@ #!/usr/bin/env python3 """ - rethinkdb_node_io - A munin plugin for Linux to monitor the io count + rethinkdb_node_io - A munin plugin for Linux to monitor the io count per second on the local node This plugin is licensed under the AGPL 3.0 license AGPL 3.0 RubenKelevra Author: @RubenKelevra - - + This plugin is written with the known limitation to a single instance per host. Patches which remove this limitation are very welcome. - - If your port / host is somewhat else than the default - localhost:28015, and/or your database-server differes in name from + + If your port / host is somewhat else than the default + localhost:28015, and/or your database-server differes in name from `hostname` (short hostname), you can add rethinkdb-node-io config vars like: [rethinkdb_*] @@ -35,6 +35,7 @@ from sys import argv from sys import exit as fatal_ from sys import stderr + # functions def fatal(status): fatal_("ERROR: " + status) @@ -64,17 +65,17 @@ def getFirstLine(respond): return e -def print_config(): - print("graph_title RethinkDB - Local Database IOPS and Queries") +def print_config(servername): + print("graph_title RethinkDB on '%s'- Local Database IOPS and Queries" % servername) print("graph_args --base 1000 -l 0") print("graph_vlabel Operations / second") print("graph_category rethinkdb") print("total_qps.label queries per sec") print("total_qps.type COUNTER") print("total_rdps.label read docs per sec") - print("total_rdps.type COUNTER") + print("total_rdps.type COUNTER") print("total_wdps.label written docs per sec") - print("total_wdps.type COUNTER") + print("total_wdps.type COUNTER") exit(0) @@ -86,11 +87,16 @@ def check_autoconf() -> bool: if __name__ == '__main__': + try: + RETHINKDB_SERVERNAME = env['rethinkdb_servername'] + except: + RETHINKDB_SERVERNAME = gethostname() + if len(argv) > 2: fatal("unsupported argument count") elif len(argv) == 2: if str(argv[1]) == "config": - print_config() + print_config(RETHINKDB_SERVERNAME) elif str(argv[1]) == "autoconf": if check_autoconf(): print("yes") @@ -118,11 +124,6 @@ if __name__ == '__main__': except: RETHINKDB_HOST = "localhost" - try: - RETHINKDB_SERVERNAME = env['rethinkdb_servername'] - except: - RETHINKDB_SERVERNAME = gethostname() - try: conn = connect(RETHINKDB_HOST, RETHINKDB_PORT) except: