9b56c14d85
- This change qoutes the module name - This change fixes processing of COLLECTD_BATCH_SIZE Change-Id: I1de49d65351e5973b794eec973efec852d42151b Closes-Bug: #1607526
85 lines
1.9 KiB
Bash
85 lines
1.9 KiB
Bash
#!/bin/bash
|
|
#
|
|
# common functions for collectd ceilometer plugin
|
|
# -----------------------------------------------
|
|
|
|
# start/stop service
|
|
#
|
|
function start_collectd {
|
|
if [ -e /usr/lib/systemd/system/collectd.service ] || [ -e /etc/init.d/collectd ]; then
|
|
sudo service collectd start
|
|
fi
|
|
}
|
|
|
|
function stop_collectd {
|
|
if [ -e /usr/lib/systemd/system/collectd.service ] || [ -e /etc/init.d/collectd ]; then
|
|
sudo service collectd stop
|
|
fi
|
|
}
|
|
|
|
# install collectd service
|
|
function install_collectd {
|
|
if [[ "$COLLECTD_INSTALL" == True ]]; then
|
|
if is_fedora || is_ubuntu; then
|
|
install_package collectd
|
|
else
|
|
die $LINENO "No support for collectd on this platform"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# Add conf file for plugin
|
|
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
|
|
</LoadPlugin>
|
|
|
|
<Plugin python>
|
|
ModulePath "$COLLECTD_CEILOMETER_DIR"
|
|
LogTraces true
|
|
Interactive false
|
|
Import "collectd_ceilometer.plugin"
|
|
|
|
<Module "collectd_ceilometer.plugin">
|
|
|
|
# Verbosity 1|0
|
|
#VERBOSE 0
|
|
|
|
# Batch size
|
|
BATCH_SIZE "$COLLECTD_BATCH_SIZE"
|
|
|
|
# Service endpoint addresses
|
|
OS_AUTH_URL "$OS_AUTH_URL"
|
|
|
|
# Ceilometer address
|
|
#CEILOMETER_ENDPOINT
|
|
CEILOMETER_URL_TYPE "$CEILOMETER_URL_TYPE"
|
|
|
|
# Ceilometer timeout in ms
|
|
CEILOMETER_TIMEOUT "$CEILOMETER_TIMEOUT"
|
|
|
|
# # Ceilometer user creds
|
|
OS_USERNAME "$OS_USERNAME"
|
|
OS_PASSWORD "$OS_PASSWORD"
|
|
OS_TENANT_NAME "service"
|
|
|
|
</Module>
|
|
</Plugin>
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
# remove plugin conf file
|
|
function restore_collectd_conf {
|
|
|
|
if [ -f '$COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf' ]; then
|
|
sudo rm -f $COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf
|
|
fi
|
|
|
|
}
|