Create separate config files for collectd plugins

- Add collectd-ceilometer-plugin.conf to etc/collectd.conf.d/
- Add logfile.conf to etc/collectd.conf.d/
- Add default values to the collectd-ceilometer-plugin.conf
- Add default values to the logfile.conf
During deployment:
- Add substitutions for the vars

Change-Id: I196367e6f48af94c053b149596c57a735109b9ed
This commit is contained in:
Emma Foley 2016-09-19 16:41:46 +01:00
parent 4e3545b513
commit 3e98d4f26a
3 changed files with 55 additions and 45 deletions

View File

@ -34,58 +34,28 @@ 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
</LoadPlugin>
sudo cp $COLLECTD_CEILOMETER_DIR/etc/collectd.conf.d/collectd-ceilometer-plugin.conf $COLLECTD_CONF_DIR/
<Plugin python>
ModulePath "$COLLECTD_CEILOMETER_DIR"
LogTraces true
Interactive false
Import "collectd_ceilometer.plugin"
<Module "collectd_ceilometer.plugin">
# Verbosity True|False
VERBOSE $COLLECTD_CEILOMETER_VERBOSE
# Batch size
BATCH_SIZE "$COLLECTD_BATCH_SIZE"
# Service endpoint addresses
OS_AUTH_URL "$OS_AUTH_URL"
OS_IDENTITY_API_VERSION "$OS_IDENTITY_API_VERSION"
# Ceilometer address
#CEILOMETER_ENDPOINT
CEILOMETER_URL_TYPE "$CEILOMETER_URL_TYPE"
# Ceilometer timeout in ms
CEILOMETER_TIMEOUT "$CEILOMETER_TIMEOUT"
# # Ceilometer user creds
OS_USERNAME "ceilometer"
OS_PASSWORD "$SERVICE_PASSWORD"
OS_TENANT_NAME "$SERVICE_TENANT_NAME"
</Module>
</Plugin>
EOF
# Configure collectd-ceiloemter-plugin.conf
sudo sed -i 's|ModulePath.*$|ModulePath "'$COLLECTD_CEILOMETER_DIR'"|g' $COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf
sudo sed -i 's|VERBOSE.*$|VERBOSE '$COLLECTD_CEILOMETER_VERBOSE'|g' $COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf
sudo sed -i 's|BATCH_SIZE.*$|BATCH_SIZE "'$COLLECTD_BATCH_SIZE'"|g' $COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf
sudo sed -i 's|OS_AUTH_URL.*$|OS_AUTH_URL "'$OS_AUTH_URL'"|g' $COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf
sudo sed -i 's|CEILOMETER_URL_TYPE.*$|CEILOMETER_URL_TYPE "'$CEILOMETER_URL_TYPE'"|g' $COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf
sudo sed -i 's|CEILOMETER_TIMEOUT.*$|CEILOMETER_TIMEOUT "'$CEILOMETER_TIMEOUT'"|g' $COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf
sudo sed -i 's|OS_PASSWORD.*$|OS_PASSWORD "'$SERVICE_PASSWORD'"|g' $COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf
sudo sed -i 's|OS_TENANT_NAME.*$|OS_TENANT_NAME "'$OS_TENANT_NAME'"|g' $COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf
# 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
sudo cp $COLLECTD_CEILOMETER_DIR/etc/collectd.conf.d/logfile.conf $COLLECTD_CONF_DIR/
sudo sed -i 's|LogLevel.*$|LogLevel "'$COLLECTD_LOG_LEVEL'"|g' $COLLECTD_CONF_DIR/logfile.conf
sudo sed -i 's|File.*$|File "'$COLLECTD_LOG_FILE'"|g' $COLLECTD_CONF_DIR/logfile.conf
}

View File

@ -0,0 +1,34 @@
<LoadPlugin python>
Globals true
</LoadPlugin>
<Plugin python>
ModulePath "/opt/stack/collectd-ceilometer-plugin"
LogTraces true
Interactive false
Import "collectd_ceilometer.plugin"
<Module "collectd_ceilometer.plugin">
# Verbosity True|False
VERBOSE False
# Batch size
BATCH_SIZE "1"
# Service endpoint addresses
OS_AUTH_URL "<OS_AUTH_URL>"
# Ceilometer address
CEILOMETER_URL_TYPE "internalURL"
# Ceilometer timeout in ms
CEILOMETER_TIMEOUT "1000"
# # Ceilometer user creds
OS_USERNAME "ceilometer"
OS_PASSWORD "password"
OS_TENANT_NAME "service"
</Module>
</Plugin>

View File

@ -0,0 +1,6 @@
LoadPlugin "logfile"
<Plugin "logfile">
LogLevel "info"
File "/opt/stack/screen/collectd.log"
Timestamp true
</Plugin>