Restart and configure collectd log file.

When installing collectd is usually automatically started. If it is
already running, the start operation has no effects. Therfore, to make
any configuration setting effective it has to be instead restarted
(stop + start).

Collectd log file is stored by logfile plugin to stack log folder.
The actual location of this file can be configured.

Verbosity of plugin can be increased to make debug messages visible
when running inside a collectd release compiled without deubgging
support. This option is mainly useful for plugin developers.

Related-Bug: #1606338
Change-Id: I658c1c3837970f3732ea64acd791838ee54c61ac
This commit is contained in:
Federico Ressi 2016-08-24 15:43:15 +01:00 committed by Emma Foley
parent 595b58ae0e
commit 7bcd8a9e01
3 changed files with 43 additions and 6 deletions

View File

@ -7,7 +7,7 @@
#
function start_collectd {
if [ -e /usr/lib/systemd/system/collectd.service ] || [ -e /etc/init.d/collectd ]; then
sudo service collectd start
sudo service collectd restart
fi
}
@ -33,6 +33,7 @@ function adapt_collectd_conf {
if [ ! -d "$COLLECTD_CONF_DIR" ]; then
sudo mkdir "$COLLECTD_CONF_DIR"
fi
cat << EOF | sudo tee $COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf
<LoadPlugin python>
Globals true
@ -46,8 +47,8 @@ cat << EOF | sudo tee $COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf
<Module "collectd_ceilometer.plugin">
# Verbosity 1|0
#VERBOSE 0
# Verbosity True|False
VERBOSE $COLLECTD_CEILOMETER_VERBOSE
# Batch size
BATCH_SIZE "$COLLECTD_BATCH_SIZE"
@ -71,6 +72,19 @@ cat << EOF | sudo tee $COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf
</Plugin>
EOF
# Configure collectd logfile plugin
if [ -n $COLLECTD_LOG_FILE ]; then
touch $COLLECTD_LOG_FILE
cat << EOF | sudo tee "$COLLECTD_CONF_DIR/logfile.conf"
LoadPlugin "logfile"
<Plugin "logfile">
LogLevel "$COLLECTD_LOG_LEVEL"
File "$COLLECTD_LOG_FILE"
Timestamp true
</Plugin>
EOF
fi
}

View File

@ -4,6 +4,12 @@ COLLECTD_BATCH_SIZE=${COLLECTD_BATCH_SIZE:-3}
COLLECTD_INSTALL=${COLLECTD_INSTALL:-True}
COLLECTD_CONF_DIR=${COLLECTD_CONF_DIR:-''}
COLLECTD_CEILOMETER_VERBOSE=${COLLECTD_CEILOMETER_VERBOSE:-False}
# Configurations for Collectd LogFile plugin
COLLECTD_LOG_FILE=${COLLECTD_LOG_FILE:-$LOGDIR/collectd.log}
COLLECTD_LOG_LEVEL=${COLLECTD_LOG_LEVEL:-info}
# Ceilometer connection info.
CEILOMETER_URL_TYPE=${CEILOMETER_URL_TYPE:-internalURL}
CEILOMETER_TIMEOUT=${CEILOMETER_TIMEOUT:-1000}
@ -21,4 +27,3 @@ if [ -z $COLLECTD_CONF_DIR ]; then
COLLECTD_CONF_DIR=/etc/collectd.d
fi
fi

View File

@ -1,6 +1,6 @@
========
=====
Usage
========
=====
To use collectd-ceilometer-plugin in collectd::
@ -41,3 +41,21 @@ COLLECTD_DIR
CEILOMETER_TIMEOUT
Sets the ceilometer's request timeout. The value is passed in milliseconds.
Default: 1000 i.e. 1 sec.
COLLECTD_CEILOMETER_VERBOSE
(True|False) Set this to True to make collectd-ceilometer debugging
messages visible as info messagges. This is useful when running the
plugin inside a collectd compiled without debug message support.
Default: False
COLLECTD_LOG_FILE
(file) The path of the collectd log file.
Default: /opt/stack/logs/collectd.log
COLLECTD_LOG_LEVEL
(debug|info|notice|warning|err) All log messages with lower log level than
this are going to be filtered out from the log file.
Default: info