summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormh <mh@immerda.ch>2013-01-02 17:03:18 +0100
committermh <mh@immerda.ch>2013-01-02 17:03:18 +0100
commitdd6c24844ba5c0787255ce31098a6545bcda8a6e (patch)
tree76e7adefd3573ff7361322e82cb660d46342d3b1
parent35b62c1b3d406aa0f575b10d98b59e39451df6a9 (diff)
parent05e97ab8205d47c46fce9ff7c04f17601f7b951e (diff)
Merge remote-tracking branch 'shared/master'
Conflicts: files/config/my.cnf.Debian manifests/server/base.pp manifests/server/munin/default.pp manifests/server/nagios.pp
-rw-r--r--files/config/my.cnf.Debian32
-rw-r--r--files/munin/mysql_size_all179
-rw-r--r--manifests/client/perl.pp6
-rw-r--r--manifests/client/perl/debian.pp6
-rw-r--r--manifests/server/munin/debian.pp42
-rw-r--r--manifests/server/munin/default.pp2
-rw-r--r--manifests/server/nagios.pp2
7 files changed, 236 insertions, 33 deletions
diff --git a/files/config/my.cnf.Debian b/files/config/my.cnf.Debian
index 74ce554..069949c 100644
--- a/files/config/my.cnf.Debian
+++ b/files/config/my.cnf.Debian
@@ -50,27 +50,29 @@ bind-address = 127.0.0.1
#
key_buffer = 16M
max_allowed_packet = 16M
-thread_stack = 128K
-thread_cache_size = 8
+thread_stack = 192K
+thread_cache_size = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
-myisam-recover = BACKUP
+myisam-recover = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
-query_cache_limit = 1M
+query_cache_limit = 1M
query_cache_size = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
-#log = /var/log/mysql/mysql.log
+# As of 5.1 you can enable the log at runtime!
+#general_log_file = /var/log/mysql/mysql.log
+#general_log = 1
#
-# Error logging goes to syslog. This is a Debian improvement :)
+# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
#
# Here you can see queries with especially long duration
#log_slow_queries = /var/log/mysql/mysql-slow.log
@@ -87,11 +89,6 @@ max_binlog_size = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#
-# * BerkeleyDB
-#
-# Using BerkeleyDB is now discouraged as its support will cease in 5.1.12.
-#skip-bdb
-#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
@@ -127,20 +124,7 @@ max_allowed_packet = 16M
key_buffer = 16M
#
-# * NDB Cluster
-#
-# See /usr/share/doc/mysql-server-*/README.Debian for more information.
-#
-# The following configuration is read by the NDB Data Nodes (ndbd processes)
-# not from the NDB Management Nodes (ndb_mgmd processes).
-#
-# [MYSQL_CLUSTER]
-# ndb-connectstring=127.0.0.1
-
-
-#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
-
diff --git a/files/munin/mysql_size_all b/files/munin/mysql_size_all
new file mode 100644
index 0000000..f5954ad
--- /dev/null
+++ b/files/munin/mysql_size_all
@@ -0,0 +1,179 @@
+#!/usr/bin/perl
+#
+# Copyright (C) 2007 - Rodolphe Quiedeville <rodolphe@quiedeville.org>
+# Copyright (C) 2003-2004 - Andreas Buer
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; version 2 dated June,
+# 1991.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Log$
+# Revision 1.1 2007/01/17 10:41:01 rodo
+# Change incorrect family
+#
+# Revision 1.0 2007/01/16 15:57:01 rodo
+# Created by Rodolphe Quiedeville
+#
+# Parameters:
+#
+# config
+# autoconf
+#
+# Configuration variables
+#
+# mysqlopts - Options to pass to mysql
+# mysqladmin - Override location of mysqladmin
+#
+#%# family=manual
+#%# capabilities=autoconf
+
+use strict;
+
+# unless ($0 =~ /mysql_size(?:_([^_]+)|)_(.+)\s*$/)
+# {
+# die "Could not parse name $0.\n";
+# }
+# my $db = $2;
+
+my $COMMAND;
+my $MYSQLADMIN = $ENV{mysqladmin} || "mysql";
+
+my %WANTED = ( "Index" => "index",
+ "Datas" => "datas",
+ );
+
+my $arg = shift();
+
+if ($arg eq 'config') {
+ print_config();
+ exit();
+} elsif ($arg eq 'autoconf') {
+ unless (test_service() ) {
+ print "yes\n";
+ } else {
+ print "no\n";
+ }
+ exit;
+}
+
+sub getDBList;
+foreach my $db (getDBList()) {
+
+ my $datas = 0;
+ my $indexes = 0;
+ my (@infos,$info,$i_data,$i_index);
+
+ $COMMAND = "$MYSQLADMIN $ENV{mysqlopts} $db -e 'show table status;' | head -n 1";
+
+ open(SERVICE, "$COMMAND |")
+ or die("Coult not execute '$COMMAND': $!");
+
+ while (<SERVICE>) {
+ (@infos) = split;
+ }
+ close(SERVICE);
+
+ my $i = 0;
+ foreach $info (@infos) {
+ $i++;
+ if ($info eq 'Data_length') {
+ $i_data = $i;
+ next;
+ }
+ if ($info eq 'Index_length') {
+ $i_index = $i;
+ last;
+ }
+ }
+ my $total_size = 0;
+ if ($i_data>0 && $i_index>0) {
+ $COMMAND = "$MYSQLADMIN $ENV{mysqlopts} $db -e 'show table status;' | cut -f $i_data,$i_index | grep -v leng";
+
+ open(SERVICE, "$COMMAND |")
+ or die("Coult not execute '$COMMAND': $!");
+
+ while (<SERVICE>) {
+ (m/(\d+).*?(\d+(?:\.\d+)?)/);
+ $datas += $1;
+ $indexes += $2;
+ }
+ close(SERVICE);
+
+ $total_size = $datas+$indexes;
+ }
+ print("$db.value $total_size\n");
+# print("datas.value $datas\n");
+# print("index.value $indexes\n");
+}
+
+
+sub print_config {
+
+ my $num = 0;
+
+ my @dbs = getDBList;
+
+ print("graph_title MySQL databases size\n");
+ print ('graph_args --base 1024 -l 0
+graph_vlabel bytes
+graph_category mysql
+graph_info Plugin available at <a href="http://rodolphe.quiedeville.org/hack/munin/">http://rodolphe.quiedeville.org/hack/munin/</a>
+');
+
+ for my $db (@dbs) {
+ my $title = "$db";
+ print("$title.label ${title}\n",
+ "$title.min 0\n",
+ "$title.type GAUGE\n",
+ "$title.draw ", ($num) ? "STACK" : "AREA" , "\n",
+ );
+ $num++;
+ }
+}
+
+
+sub test_service {
+
+ my $return = 1;
+
+ system ("$MYSQLADMIN --version >/dev/null 2>/dev/null");
+ if ($? == 0)
+ {
+ system ("$COMMAND >/dev/null 2>/dev/null");
+ if ($? == 0)
+ {
+ print "yes\n";
+ $return = 0;
+ }
+ else
+ {
+ print "no (could not connect to mysql)\n";
+ }
+ }
+ else
+ {
+ print "no (mysqladmin not found)\n";
+ }
+ exit $return;
+}
+
+sub getDBList {
+ my @dbs;
+ foreach my $f (glob("/var/lib/mysql/*")) {
+ if (-d $f) {
+ $f =~ s!.*/!!;
+ @dbs[$#dbs+1]=$f };
+ }
+ return @dbs;
+}
+
diff --git a/manifests/client/perl.pp b/manifests/client/perl.pp
new file mode 100644
index 0000000..f11d06f
--- /dev/null
+++ b/manifests/client/perl.pp
@@ -0,0 +1,6 @@
+# mysql perl config
+class mysql::client::perl {
+ case $::operatingsystem {
+ debian: { include mysql::client::perl::debian }
+ }
+}
diff --git a/manifests/client/perl/debian.pp b/manifests/client/perl/debian.pp
new file mode 100644
index 0000000..f4acfb4
--- /dev/null
+++ b/manifests/client/perl/debian.pp
@@ -0,0 +1,6 @@
+# perl package name on debian
+class mysql::client::perl::debian {
+ package { 'libdbd-mysql-perl':
+ ensure => present,
+ }
+}
diff --git a/manifests/server/munin/debian.pp b/manifests/server/munin/debian.pp
index 2b2acb4..9ff7863 100644
--- a/manifests/server/munin/debian.pp
+++ b/manifests/server/munin/debian.pp
@@ -1,9 +1,35 @@
-# manifests/server/munin/debian.pp
-
-class mysql::server::munin::debian {
- munin::plugin {
- [mysql_bytes, mysql_queries, mysql_slowqueries, mysql_threads]:
- config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf",
- require => Package['mysql'],
- }
+# debian way of calling plugins
+class mysql::server::munin::debian inherits mysql::server::munin::default {
+ Munin::Plugin['mysql_bytes']{
+ config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf",
+ require => Package['mysql'],
+ }
+ Munin::Plugin['mysql_queries']{
+ config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf",
+ require => Package['mysql'],
+ }
+ Munin::Plugin['mysql_slowqueries']{
+ config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf",
+ require => Package['mysql'],
+ }
+ Munin::Plugin['mysql_threads']{
+ config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf",
+ require => Package['mysql'],
+ }
+ Munin::Plugin::Deploy['mysql_connections']{
+ config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf",
+ require => Package['mysql'],
+ }
+ Munin::Plugin::Deploy['mysql_qcache']{
+ config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf",
+ require => Package['mysql'],
+ }
+ Munin::Plugin::Deploy['mysql_cache_mem']{
+ config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf",
+ require => Package['mysql'],
+ }
+ Munin::Plugin::Deploy['mysql_size_all']{
+ config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf",
+ require => Package['mysql'],
+ }
}
diff --git a/manifests/server/munin/default.pp b/manifests/server/munin/default.pp
index 83924c5..11609d2 100644
--- a/manifests/server/munin/default.pp
+++ b/manifests/server/munin/default.pp
@@ -31,5 +31,7 @@ class mysql::server::munin::default {
source => 'mysql/munin/mysql_qcache';
'mysql_qcache_mem':
source => 'mysql/munin/mysql_qcache_mem';
+ 'mysql_size_all':
+ source => 'mysql/munin/mysql_size_all';
}
}
diff --git a/manifests/server/nagios.pp b/manifests/server/nagios.pp
index 0ceb968..39af429 100644
--- a/manifests/server/nagios.pp
+++ b/manifests/server/nagios.pp
@@ -6,7 +6,7 @@ class mysql::server::nagios {
} else {
$nagios_mysql_user = 'nagios@%'
nagios::service::mysql { 'connection-time':
- check_hostname => $::fqdn,
+ check_host => $::fqdn,
require => Mysql_grant[$nagios_mysql_user],
}
}