From fa2da1a46c25205c1b9ead7485b17f518b5a89d6 Mon Sep 17 00:00:00 2001 From: Simon Pasquier Date: Mon, 3 Aug 2015 09:33:25 +0200 Subject: [PATCH] Report DF metrics as percentage too This change includes a workaround for a bug [1] found in the upstream puppet-collectd module. [1] https://github.com/pdxcat/puppet-module-collectd/issues/162 Change-Id: I560e0436cfefb026d2c7a979091208a399bbe2fd --- .../files/plugins/decoders/collectd.lua | 4 +++ .../lib/facter/collectd_version.rb | 28 +++++++++++++++++++ .../lma_collector/manifests/collectd/base.pp | 3 +- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 deployment_scripts/puppet/modules/lma_collector/lib/facter/collectd_version.rb diff --git a/deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/collectd.lua b/deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/collectd.lua index 44793f0a..cd95ca84 100644 --- a/deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/collectd.lua +++ b/deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/collectd.lua @@ -86,6 +86,10 @@ function process_message () local entity if sample['type'] == 'df_inodes' then entity = 'inodes' + elseif sample['type'] == 'percent_inodes' then + entity = 'inodes_percent' + elseif sample['type'] == 'percent_bytes' then + entity = 'space_percent' else -- sample['type'] == 'df_complex' entity = 'space' end diff --git a/deployment_scripts/puppet/modules/lma_collector/lib/facter/collectd_version.rb b/deployment_scripts/puppet/modules/lma_collector/lib/facter/collectd_version.rb new file mode 100644 index 00000000..ae1deab6 --- /dev/null +++ b/deployment_scripts/puppet/modules/lma_collector/lib/facter/collectd_version.rb @@ -0,0 +1,28 @@ +# Copyright 2015 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. + +# Workaround because the puppet-collectd module cannot detect the collectd's +# version until the package is installed. +# +# See https://github.com/pdxcat/puppet-module-collectd/issues/162 for details. +Facter.add("collectd_version") do + setcode do + case Facter.value('osfamily') + when /(?i)(debian)/ + "5.4.0-3ubuntu2" + when /(?i)(redhat)/ + "5.4.1-5.mira1.mira1" + end + end +end diff --git a/deployment_scripts/puppet/modules/lma_collector/manifests/collectd/base.pp b/deployment_scripts/puppet/modules/lma_collector/manifests/collectd/base.pp index 32972fe7..3ccfbd84 100644 --- a/deployment_scripts/puppet/modules/lma_collector/manifests/collectd/base.pp +++ b/deployment_scripts/puppet/modules/lma_collector/manifests/collectd/base.pp @@ -64,7 +64,8 @@ # TODO: pass this list as a parameter or add a custom fact class { 'collectd::plugin::df': - mountpoints => ['/', '/boot'], + mountpoints => ['/', '/boot'], + valuespercentage => true, } $block_devices = join(split($::blockdevices, ','), '|')