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
This commit is contained in:
commit
dd6c24844b
7 changed files with 236 additions and 33 deletions
|
@ -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/.
|
||||
|
@ -126,21 +123,8 @@ max_allowed_packet = 16M
|
|||
[isamchk]
|
||||
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/
|
||||
|
||||
|
|
179
files/munin/mysql_size_all
Normal file
179
files/munin/mysql_size_all
Normal file
|
@ -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;
|
||||
}
|
||||
|
6
manifests/client/perl.pp
Normal file
6
manifests/client/perl.pp
Normal file
|
@ -0,0 +1,6 @@
|
|||
# mysql perl config
|
||||
class mysql::client::perl {
|
||||
case $::operatingsystem {
|
||||
debian: { include mysql::client::perl::debian }
|
||||
}
|
||||
}
|
6
manifests/client/perl/debian.pp
Normal file
6
manifests/client/perl/debian.pp
Normal file
|
@ -0,0 +1,6 @@
|
|||
# perl package name on debian
|
||||
class mysql::client::perl::debian {
|
||||
package { 'libdbd-mysql-perl':
|
||||
ensure => present,
|
||||
}
|
||||
}
|
|
@ -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'],
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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],
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue