Make changes to lma_collector::collectd::mysql

This commit is related to the usage and documentation of the
lma_collector::collectd::mysql class.

The following changes are made:

1. Make the "username" and "password" parameters required. Today
   they default to the empty string, which doesn't make much sense.
2. Change the internal resource name from "nova" to "config". The
   name "nova" was confusing as the collection of MySQL statistics
   is unrelated to Nova. With this change the generated collectd
   configuration file is named "mysql-config.conf", which makes
   more sense than "mysql-nova.conf" and is consistent with other
   collectd config file names we have (e.g. "python-config.conf").
3. Add a unit test for the class.
4. Adjust the documentation.

Change-Id: I281c28d9f4da7ae728615041e175845ad5829b34
This commit is contained in:
Éric Lemoine 2016-02-09 00:20:25 -08:00
parent be85d7ebac
commit 54a2e4b4b9
5 changed files with 45 additions and 15 deletions

View File

@ -301,7 +301,6 @@ if $lma_collector['influxdb_mode'] != 'disabled' {
}
class { 'lma_collector::collectd::mysql':
database => 'nova',
username => 'nova',
password => $nova['db_password'],
}

View File

@ -325,7 +325,10 @@ To make the collector collect statistics for MySQL declare the
`lma_collector::collectd::mysql` class:
```puppet
class { 'lma_collector::collectd::mysql': }
class { 'lma_collector::collectd::mysql':
username => 'mysql_username',
password => 'mysql_password',
}
```
### Collect OpenStack notifications
@ -650,17 +653,16 @@ which uses Pacemaker's `crm_resource` command to get statistics from Pacemaker.
#### Class: `lma_collector::collectd::mysql`
Declare this class to configure collectd to collect statistics for MySQL.
Declare this class to configure collectd to collect statistics for the MySQL
instance local to the node.
The collectd plugin used is the native collectd [MySQL
plugin](https://collectd.org/wiki/index.php/Plugin:MySQL).
plugin](https://collectd.org/wiki/index.php/Plugin:MySQL). It is configured
with `'localhost'` as the `Host`, meaning that the local MySQL Unix socket will
be used to connect to MySQL.
##### Parameters
* `host`: *Optional*. The host onto which the MySQL database runs. Valid
options: a string. Default: `'127.0.0.1'`.
* `port`: *Optional*. The port the MySQL database listens on. Valid options: an
integer. Default: `3306`.
* `username`: *Required*. The database user to use to connect to the MySQL
database. Valid options: a string.
* `password`: *Required*. The database password to use to connect to the MySQL

View File

@ -13,12 +13,13 @@
# under the License.
#
class lma_collector::collectd::mysql (
$database = $lma_collector::params::mysql_database,
$username = $lma_collector::params::mysql_username,
$password = $lma_collector::params::mysql_password,
$username,
$password,
) inherits lma_collector::params {
collectd::plugin::mysql::database { $database:
# With "config" as the resource title the collectd configuration
# file will be named "mysql-config.conf".
collectd::plugin::mysql::database { 'config':
host => 'localhost',
username => $username,
password => $password,

View File

@ -106,9 +106,6 @@ class lma_collector::params {
}
}
$additional_packages = [ 'python-dateutil' ]
$mysql_database = ''
$mysql_username = ''
$mysql_password = ''
$openstack_user = ''
$openstack_password = ''
$openstack_tenant = ''

View File

@ -0,0 +1,31 @@
# Copyright 2016 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
require 'spec_helper'
describe 'lma_collector::collectd::mysql' do
let(:facts) do
{:kernel => 'Linux', :operatingsystem => 'Ubuntu',
:osfamily => 'Debian', :concat_basedir => '/foo'}
end
describe 'with params' do
let(:params) do
{:username => 'user', :password => 'password'}
end
it { is_expected.to contain_collectd__plugin__mysql__database('config') \
.with_host('localhost') \
.with_username('user') \
.with_password('password') }
end
end