From 8520ac425cf9a5ac4da8d97597480a1bf02d5416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 19 Aug 2015 10:44:03 +0000 Subject: [PATCH 1/2] add innodbstats and slavenotifications --- manifests/plugin/mysql/database.pp | 22 ++++++++++++---------- templates/mysql-database.conf.erb | 2 ++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/manifests/plugin/mysql/database.pp b/manifests/plugin/mysql/database.pp index e736ea1e5..48cf70bd1 100644 --- a/manifests/plugin/mysql/database.pp +++ b/manifests/plugin/mysql/database.pp @@ -1,14 +1,16 @@ # define collectd::plugin::mysql::database ( - $ensure = 'present', - $database = $name, - $host = 'UNSET', - $username = 'UNSET', - $password = 'UNSET', - $port = '3306', - $masterstats = false, - $slavestats = false, - $socket = undef, + $ensure = 'present', + $database = $name, + $host = 'UNSET', + $username = 'UNSET', + $password = 'UNSET', + $port = '3306', + $masterstats = false, + $slavestats = false, + $socket = undef, + $innodbstats = false, + $slavenotifications = false, ) { include collectd::params include collectd::plugin::mysql @@ -16,7 +18,7 @@ $conf_dir = $collectd::params::plugin_conf_dir validate_string($database, $host, $username, $password, $port) - validate_bool($masterstats, $slavestats) + validate_bool($masterstats, $slavestats, $innodbstats, $slavenotifications) if $socket { validate_string($socket) } diff --git a/templates/mysql-database.conf.erb b/templates/mysql-database.conf.erb index 04c2c23c2..2a48e2a7e 100644 --- a/templates/mysql-database.conf.erb +++ b/templates/mysql-database.conf.erb @@ -15,5 +15,7 @@ <%- if @socket -%> Socket "<%= @socket %>" <%- end -%> + InnodbStats <%= @innodbstats %> + SlaveNotifications <%= @slavenotifications %> From d7386aea6d4c6cd8a2c243343356ef9d9baef7c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Fri, 21 Aug 2015 10:26:56 +0000 Subject: [PATCH 2/2] mysql: make new settings optional --- manifests/plugin/mysql/database.pp | 14 +++++++++++--- templates/mysql-database.conf.erb | 4 ++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/manifests/plugin/mysql/database.pp b/manifests/plugin/mysql/database.pp index 48cf70bd1..a9909190a 100644 --- a/manifests/plugin/mysql/database.pp +++ b/manifests/plugin/mysql/database.pp @@ -9,8 +9,8 @@ $masterstats = false, $slavestats = false, $socket = undef, - $innodbstats = false, - $slavenotifications = false, + $innodbstats = undef, + $slavenotifications = undef, ) { include collectd::params include collectd::plugin::mysql @@ -18,11 +18,19 @@ $conf_dir = $collectd::params::plugin_conf_dir validate_string($database, $host, $username, $password, $port) - validate_bool($masterstats, $slavestats, $innodbstats, $slavenotifications) + validate_bool($masterstats, $slavestats) if $socket { validate_string($socket) } + if $innodbstats != undef { + validate_bool($innodbstats) + } + + if $slavenotifications != undef { + validate_bool($slavenotifications) + } + if ($masterstats == true and $slavestats == true) { fail('master and slave statistics are mutually exclusive.') } diff --git a/templates/mysql-database.conf.erb b/templates/mysql-database.conf.erb index 2a48e2a7e..e98f3214d 100644 --- a/templates/mysql-database.conf.erb +++ b/templates/mysql-database.conf.erb @@ -15,7 +15,11 @@ <%- if @socket -%> Socket "<%= @socket %>" <%- end -%> +<%- if not @innodbstats.nil? -%> InnodbStats <%= @innodbstats %> +<%- end -%> +<%- if not @slavenotifications.nil? -%> SlaveNotifications <%= @slavenotifications %> +<%- end -%>