Skip to content

Commit 8e47231

Browse files
Filip ChabikJan Kunzmann
authored andcommitted
Allow to graph more than one mysql instance per host
(Currently requires a copy/link of this module per instance)
1 parent 3385fd6 commit 8e47231

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

mysql.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# Port 3306 (optional)
1414
# User root
1515
# Password xxxx
16+
# Instance xxxx
1617
# HeartbeatTable percona.heartbeat (optional, if using pt-heartbeat)
1718
# Verbose true (optional, to enable debugging)
1819
# </Module>
@@ -21,6 +22,7 @@
2122
#
2223
# Author: Chris Boulton <chris@chrisboulton.com>
2324
# Added metrics for Grafana Dashboards by Matej Zerovnik <matej@zunaj.si>
25+
# Added support for multiple instances by Filip Chabik <filip.chabik@erasys.de>
2426
# License: MIT (http://www.opensource.org/licenses/mit-license.php)
2527
#
2628

@@ -35,6 +37,7 @@
3537
'Password': '',
3638
'HeartbeatTable': '',
3739
'Verbose': False,
40+
'Instance': '',
3841
}
3942

4043
MYSQL_STATUS_VARS = {
@@ -480,10 +483,12 @@ def dispatch_value(prefix, key, value, type, type_instance=None):
480483
return
481484
value = int(value) # safety check
482485

483-
val = collectd.Values(plugin='mysql', plugin_instance=prefix)
484-
val.type = type
485-
val.type_instance = type_instance
486-
val.values = [value]
486+
val = collectd.Values(plugin='mysql', plugin_instance=prefix)
487+
val.plugin = 'mysql.%s' % MYSQL_CONFIG['Instance']
488+
val.plugin_instance = prefix
489+
val.type = type
490+
val.type_instance = type_instance
491+
val.values = [value]
487492
val.dispatch()
488493

489494
def configure_callback(conf):

0 commit comments

Comments
 (0)