Collect apache metrics.

- Enable apache module status
- Install collectd apache plugin

Change-Id: I92a8e1f0790b7473c224e7a7e17f6425902ea54d
This commit is contained in:
Guillaume Thouvenin 2015-03-24 12:17:58 +01:00
parent 350a21c6b3
commit b58577dc8f
11 changed files with 95 additions and 0 deletions

View File

@ -84,4 +84,7 @@ if $fuel_settings['lma_collector']['influxdb_mode'] != 'disabled' {
if $enable_notifications {
class { 'lma_collector::notifications::metrics': }
}
# Enable Apache status module
class { 'lma_collector::mod_status': }
}

View File

@ -0,0 +1,8 @@
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from localhost
</Location>
ExtendedStatus On

View File

@ -0,0 +1 @@
LoadModule status_module modules/mod_status.so

View File

@ -120,6 +120,9 @@ function process_message ()
msg['Fields']['name'] = 'memcached' .. sep .. string.gsub(metric_name, 'memcached_', '')
elseif metric_source == 'haproxy' then
msg['Fields']['name'] = 'haproxy' .. sep .. sample['type_instance']
elseif metric_source == 'apache' then
metric_name = string.gsub(metric_name, 'apache_', '')
msg['Fields']['name'] = 'apache' .. sep .. string.gsub(metric_name, 'scoreboard', 'workers')
else
msg['Fields']['name'] = metric_name
end

View File

@ -107,4 +107,13 @@ class lma_collector::collectd::controller (
class { 'collectd::plugin::memcached':
}
class { 'collectd::plugin::apache':
instances => {
'localhost' => {
'url' => 'http://localhost/server-status?auto'
},
}
}
}

View File

@ -0,0 +1,48 @@
# Class: lma_collector::mod_status
#
# We don't use apache::mod_status because it requires to include the apache
# base class. And by doing this we overwrite horizon configuration.
class lma_collector::mod_status {
include apache::params
include apache::service
case $::osfamily {
'redhat': {
$status_conf = '/etc/httpd/conf.d/status.conf'
$status_load = '/etc/httpd/conf.d/status.load'
file { $status_load:
source => 'puppet:///modules/lma_collector/apache/status.load'
}
file { $status_conf:
source => 'puppet:///modules/lma_collector/apache/status.conf',
require => File[$status_load],
notify => Class['apache::service'],
}
}
'debian': {
$status_conf = '/etc/apache2/mods-enabled/status.conf'
$status_load = '/etc/apache2/mods-enabled/status.load'
file { $status_conf:
ensure => link,
target => '/etc/apache2/mods-available/status.conf',
}
file { $status_load:
ensure => link,
target => '/etc/apache2/mods-available/status.load',
require => File[$status_conf],
notify => Class['apache::service'],
}
}
default : {
notify {"Cannot enable apache status module on ${::operatingsystem}": }
}
}
}

View File

@ -19,6 +19,7 @@
],
"description": "Puppet module for configuring the LMA collector service",
"dependencies": [
{"name": "puppetlabs/apache", "version_requirement": ">= 1.4.0"},
{"name": "puppetlabs/stdlib", "version_requirement": "4.x"},
{"name": "pdxcat/collectd", "version_requirement": "3.x"},
{"name": "mirantis/heka", "version_requirement": "1.x"}

View File

@ -68,6 +68,7 @@ release = '1.0'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = [
'metrics/apache.rst',
'metrics/mysql.rst',
'metrics/openstack.rst',
'metrics/rabbitmq.rst',

View File

@ -74,6 +74,11 @@ System
.. include:: metrics/system.rst
Apache
------
.. include:: metrics/apache.rst
MySQL
-----

View File

@ -0,0 +1,9 @@
.. _Apache_metrics:
* ``apache.bytes``, the number of bytes per second transmitted by the server.
* ``apache.requests``, the number of requests processed per second.
* ``apache.connections``, the current number of active connections.
* ``apache.idle_workers``, the current number of idle workers.
* ``apache.workers.<state>``, the current number of workers by state.
``<state>`` is one of ``closing``, ``dnslookup``, ``finishing``, ``idle_cleanup``, ``keepalive``, ``logging``, ``open``, ``reading``, ``sending``, ``starting``, ``waiting``.

View File

@ -9,6 +9,7 @@ HEKA_VERSION="0.9.0"
FUEL_LIB_VERSION="6.0"
FUEL_LIB_TARBALL_URL="https://github.com/stackforge/fuel-library/archive/${FUEL_LIB_VERSION}.tar.gz"
COLLECTD_TARBALL_URL="https://forgeapi.puppetlabs.com/v3/files/pdxcat-collectd-3.2.0.tar.gz"
APACHE_TARBALL_URL="https://forgeapi.puppetlabs.com/v3/files/puppetlabs-apache-1.4.0.tar.gz"
function download_packages {
while [ $# -gt 0 ]; do
@ -60,3 +61,9 @@ wget -qO- "${FUEL_LIB_TARBALL_URL}" | \
rm -rf ${MODULES_DIR}/collectd
mkdir -p ${MODULES_DIR}/collectd
wget -qO- "${COLLECTD_TARBALL_URL}" | tar -C "${MODULES_DIR}/collectd" --strip-components=1 -xz
# Apache is not available in Fuel 6.0. It will be available in 6.1. So until the switch to 6.1
# we download it from puppetlabs.
rm -rf ${MODULES_DIR}/apache
mkdir -p ${MODULES_DIR}/apache
wget -qO- "${APACHE_TARBALL_URL}" | tar -C "${MODULES_DIR}/apache" --strip-components=1 -xz