Add collectd support for Ubuntu

Change-Id: I923b3d327f7a0c2ba059f3ae54f176d560b8c73d
(cherry picked from commit ed185d2ab9)
This commit is contained in:
Carlos Goncalves 2016-03-19 22:21:27 +00:00 committed by sean mooney
parent 6103a8759a
commit fdfcf27a31
1 changed files with 16 additions and 7 deletions

View File

@ -3,17 +3,23 @@
# common functions for collectd ceilometer plugin # common functions for collectd ceilometer plugin
# ----------------------------------------------- # -----------------------------------------------
if is_ubuntu; then
COLLECTD_CONF_DIR=/etc/collectd/collectd.conf.d
elif is_fedora; then
COLLECTD_CONF_DIR=/etc/collectd.d
fi
# start/stop service # start/stop service
# #
function start_collectd { function start_collectd {
if [ -e /usr/lib/systemd/system/collectd.service ]; then if [ -e /usr/lib/systemd/system/collectd.service ] || [ -e /etc/init.d/collectd ]; then
sudo service collectd start sudo service collectd start
fi fi
} }
function stop_collectd { function stop_collectd {
if [ -e /usr/lib/systemd/system/collectd.service ]; then if [ -e /usr/lib/systemd/system/collectd.service ] || [ -e /etc/init.d/collectd ]; then
sudo service collectd stop sudo service collectd stop
fi fi
} }
@ -21,14 +27,17 @@ function stop_collectd {
# install collectd service # install collectd service
function install_collectd { function install_collectd {
if [[ "$COLLECTD_INSTALL" == True ]]; then if [[ "$COLLECTD_INSTALL" == True ]]; then
install_package collectd if is_fedora || is_ubuntu; then
install_package collectd
else
die $LINENO "No support for collectd on this platform"
fi
fi fi
} }
# Add conf file for plugin # Add conf file for plugin
function adapt_collectd_conf { function adapt_collectd_conf {
cat << EOF | sudo tee $COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf
cat << EOF | sudo tee /etc/collectd.d/collectd-ceilometer-plugin.conf
<LoadPlugin python> <LoadPlugin python>
Globals true Globals true
</LoadPlugin> </LoadPlugin>
@ -69,8 +78,8 @@ EOF
# remove plugin conf file # remove plugin conf file
function restore_collectd_conf { function restore_collectd_conf {
if [ -f '/etc/collectd.d/collectd-ceilometer-plugin.conf' ]; then if [ -f '$COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf' ]; then
sudo rm -f /etc/collectd.d/collectd-ceilometer-plugin.conf sudo rm -f $COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf
fi fi
} }