Merge "Add code to build collectd"

This commit is contained in:
Jenkins 2017-03-21 23:46:55 +00:00 committed by Gerrit Code Review
commit 536f851533
5 changed files with 160 additions and 14 deletions

View File

@ -17,32 +17,107 @@ function stop_collectd {
fi
}
function install_requirements {
echo "Installing pre-resquisites"
if is_ubuntu; then
install_package libvirt-bin libvirt-dev python-libvirt
if [[ "$COLLECTD_INSTALL_TYPE" == "source" ]]; then
install_package byacc flex bison build-essential automake libgcrypt20 libtool
fi
elif is_fedora; then
install_package libvirt libvirt-devel libvirt-python
if [[ "$COLLECTD_INSTALL_TYPE" == "source" ]]; then
install_package flex bison automake autoconf libtool
fi
else
echo "Unsupported distros"
fi
}
function install_service_file {
# Configure systemd service file
if [[ `ls -la /sbin/init` =~ "systemd" ]]; then
local service_file=/etc/systemd/system/collectd.service
local collectd_binary=$COLLECTD_PREFIX/sbin/collectd
local collectd_conf_file=$COLLECTD_PREFIX/etc/collectd.conf
sudo -E cp $COLLECTD_DIR/contrib/systemd.collectd.service $service_file
sudo sed 's#ExecStart=.*$#ExecStart='"$collectd_binary"' -C '"$collectd_conf_file"'#g' -i $service_file
# Enable collectd
sudo systemctl enable collectd
else
die $LINENO "No support for systemd on this platform.\n
To use collectd, build it, configure the service
manually, and set COLLECTD_INSTALL=False."
fi
}
function build_collectd {
git_clone $COLLECTD_REPO $COLLECTD_DIR $COLLECTD_BRANCH
pushd $COLLECTD_DIR
# $PS4 has been defined to call short_source but the function is not
# available when build.sh is called.
OPS4=$PS4
PS4='+'
build_output=$( ./build.sh )
echo "Build output: " $build_output
PS4=$OPS4
./configure --enable-python --enable-debug \
--enable-logging --enable-syslog \
--prefix=$COLLECTD_PREFIX/
make -j all
sudo make install
popd
# Allow read access to collectd conf file
sudo chmod +r $COLLECTD_PREFIX/etc/collectd.conf;
install_service_file
add_include_dir
}
# install collectd
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"
if [[ "$COLLECTD_INSTALL_TYPE" == "source" ]]; then
build_collectd
else # if install type is binary
if is_fedora || is_ubuntu; then
install_package collectd
else
die $LINENO "No support for collectd on this platform"
fi
fi
fi
}
# Add the Include block so that conf dir is read
function add_include_dir {
cat << EOF | sudo -E tee -a $PREFIX/etc/collectd.conf
<Include "$COLLECTD_CONF_DIR">
Filter "*.conf"
</Include>
EOF
}
# Add conf file for plugin
function adapt_collectd_conf {
if [ ! -d "$COLLECTD_CONF_DIR" ]; then
sudo mkdir -p "$COLLECTD_CONF_DIR"
sudo -E mkdir -p "$COLLECTD_CONF_DIR"
fi
# Configure collectd-ceilometer-plugin

View File

@ -1,8 +1,14 @@
# General settings
COLLECTD_CEILOMETER_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )
COLLECTD_BATCH_SIZE=${COLLECTD_BATCH_SIZE:-1}
COLLECTD_BRANCH=${COLLECTD_BRANCH:-collectd-5.7}
COLLECTD_DIR=${COLLECTD_DIR:-$DEST/collectd-$COLLECTD_BRANCH/}
COLLECTD_INSTALL=${COLLECTD_INSTALL:-True}
COLLECTD_INSTALL_TYPE=${COLLECTD_INSTALL_TYPE:-'binary'}
COLLECTD_CONF_DIR=${COLLECTD_CONF_DIR:-''}
# this is a mirror of: git://git.verplant.org/collectd.git
COLLECTD_REPO=${COLLECTD_REPO:-'https://github.com/collectd/collectd.git'}
COLLECTD_PREFIX=${COLLECTD_PREFIX:-'/usr'}
COLLECTD_CEILOMETER_VERBOSE=${COLLECTD_CEILOMETER_VERBOSE:-False}

View File

@ -0,0 +1,33 @@
[[local|localrc]]
HOST_IP=<SINGLE NODE IP>
VERBOSE=True
FORCE=yes
MYSQL_PASSWORD=password
DATABASE_PASSWORD=password
RABBIT_PASSWORD=password
ADMIN_PASSWORD=password
SERVICE_PASSWORD=password
HORIZON_PASSWORD=password
SERVICE_TOKEN=tokentoken
disable_all_services
enable_service key
enable_service mysql
enable_service rabbit
enable_service dstat
# For more options refer to devstackGSG.rst
# GNOCCHI
enable_plugin gnocchi https://github.com/openstack/gnocchi master
GNOCCHI_USE_KEYSTONE=True
COLLECTD_GNOCCHI_ENABLED=True
# Setup collectd-ceilometer plugin
COLLECTD_INSTALL=True
COLLECTD_INSTALL_TYPE=source
COLLECTD_CEILOMETER_VERBOSE=True
enable_plugin collectd-ceilometer http://github.com/openstack/collectd-ceilometer-plugin

View File

@ -12,6 +12,12 @@ To use collectd-ceilometer-plugin in collectd::
local.conf settings
-------------------
COLLECTD_BRANCH
(<git branch>) Indicates which branch of collectd to checkout before
compiling.
Default: collectd-5.7
COLLECTD_CONF_DIR
(directory) Specify a directory where collectd conf files reside.
This is required if you use a distro other than Ubuntu or Fedora, or if
@ -19,11 +25,16 @@ COLLECTD_CONF_DIR
be created if it doesn't already exist.
Default: /etc/collectd/collectd.conf.d (Ubuntu) /etc/collectd.d (Fedora)
COLLECTD_DIR
(directory) Destination of the cloned collectd source code.
Default: $DEST/collectd-$COLLECTD_BRANCH/
COLLECTD_INSTALL
(True|False) Indicates whether to install collectd from package manager.
Set this to False if you are running a custom collectd build or do not
want to upgrade installed version.
(True|False) Indicates whether to install collectd.
Set this to False if you are running a pre-built version of collectd or do
not want to upgrade installed version.
Default: True
@ -32,12 +43,6 @@ COLLECTD_BATCH_SIZE
Default: 1 i.e. no batching/buffering.
COLLECTD_DIR
Specify collectd directory, this is required if collectd was installed
manually.
Default: /opt/collectd
CEILOMETER_TIMEOUT
Sets the ceilometer's request timeout. The value is passed in milliseconds.
Default: 1000 i.e. 1 sec.
@ -89,6 +94,26 @@ COLLECTD_GNOCCHI_ENABLED
Default: True
COLLECTD_INSTALL_TYPE
(source|binary) Specify whether the collectd installation should use the
package manager or install from source.
Default: binary
COLLECTD_REPO
(url) Location of git repo to clone collectd from.
Default: https://github.com/collectd/collectd.git
COLLECTD_PREFIX
(directory) The directory to install collectd under.
Default: /usr/
Authenticating using Identity Server API v3
===========================================

View File

@ -0,0 +1,7 @@
---
features:
- |
Devstack code added to clone and build collectd from source, allowing
specific versions to be installed, including newly-developed plugin-ins
which have not been released yet, or are not included in the collectd main
repository.