diff --git a/devstack/libs/collectd b/devstack/libs/collectd new file mode 100644 index 0000000..266b21f --- /dev/null +++ b/devstack/libs/collectd @@ -0,0 +1,74 @@ +#!/bin/bash +# +# common functions for collectd ceilometer plugin +# ----------------------------------------------- + + +# start/stop service +# +function start_collectd { + if [ -e /usr/lib/systemd/system/collectd.service ]; then + sudo service collectd start + fi +} + +function stop_collectd { + if [ -e /usr/lib/systemd/system/collectd.service ]; then + sudo service collectd stop + fi +} + +# install collectd service +function install_collectd { + install_package collectd +} + +# Add conf file for plugin +function adapt_collectd_conf { + +cat << EOF | sudo tee /etc/collectd.d/collectd-ceilometer-plugin.conf + + Globals true + + + + ModulePath "$COLLECTD_DIR" + LogTraces true + Interactive false + Import "collectd_ceilometer" + + + + # Batch size + BATCH_SIZE 3 + + # 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" + + + +EOF + +} + + +# remove plugin conf file +function restore_collectd_conf { + + if [ -f '/etc/collectd.d/collectd-ceilometer-plugin.conf' ]; then + sudo rm -f /etc/collectd.d/collectd-ceilometer-plugin.conf + fi + +} diff --git a/devstack/plugin.sh b/devstack/plugin.sh new file mode 100644 index 0000000..aafdfbc --- /dev/null +++ b/devstack/plugin.sh @@ -0,0 +1,39 @@ +local xtrace=$(set +o | grep xtrace) +set -o xtrace + + # Initial source of lib script + source $COLLECTD_DIR/devstack/libs/collectd + + case $1 in + "stack") + case $2 in + "pre-install") + # install system package + install_collectd + ;; + "install") + # adapt collectd.conf + adapt_collectd_conf + ;; + "post-config") + # start collectd service + start_collectd + ;; + "extra") + # no-op + : + ;; + esac + ;; + "unstack") + # stop the service and restore original /etc/collect.conf + stop_collectd + restore_collectd_conf + ;; + "clean") + # no cleaning required as of now + : + ;; + esac + +$xtrace diff --git a/devstack/settings b/devstack/settings new file mode 100644 index 0000000..c498f9e --- /dev/null +++ b/devstack/settings @@ -0,0 +1,15 @@ +# General settings +COLLECTD_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd ) +COLLECTD_BATCH_SIZE=${COLLECTD_BATCH_SIZE:-3} + +# Ceilometer connection info. +CEILOMETER_URL_TYPE=${CEILOMETER_URL_TYPE:-internalURL} +CEILOMETER_TIMEOUT=${CEILOMETER_TIMEOUT:-1000} + +# Auth info +OS_AUTH_URL="$KEYSTONE_AUTH_URI/v$IDENTITY_API_VERSION" +OS_USERNAME="ceilometer" +OS_PASSWORD=${SERVICE_PASSWORD} + + +