Merge "Add custom unit mapping to Gnocchi"

This commit is contained in:
Jenkins
2017-03-10 17:30:06 +00:00
committed by Gerrit Code Review
4 changed files with 35 additions and 14 deletions

View File

@@ -58,6 +58,8 @@ function adapt_collectd_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 "'$SERVICE_TENANT_NAME'"|g' $COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf
config_custom_units "ceilometer" "$COLLECTD_CEILOMETER_UNITS"
fi
# configure collectd-gnocchi plugin
@@ -74,17 +76,7 @@ function adapt_collectd_conf {
sudo sed -i 's|CEILOMETER_TIMEOUT.*$|CEILOMETER_TIMEOUT "'$CEILOMETER_TIMEOUT'"|g' $COLLECTD_CONF_DIR/collectd-gnocchi-plugin.conf
sudo sed -i 's|OS_PASSWORD.*$|OS_PASSWORD "'$SERVICE_PASSWORD'"|g' $COLLECTD_CONF_DIR/collectd-gnocchi-plugin.conf
sudo sed -i 's|OS_TENANT_NAME.*$|OS_TENANT_NAME "'$SERVICE_TENANT_NAME'"|g' $COLLECTD_CONF_DIR/collectd-gnocchi-plugin.conf
fi
# Configure custom units
if [[ "$COLLECTD_CEILOMETER_UNITS" != none ]]; then
OIFS=$IFS
IFS=','
for UNIT in $COLLECTD_CEILOMETER_UNITS
do
sudo sed -i '/<UNITS>/a\ UNIT '"$UNIT"'' $COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf
done
IFS=$OIFS
config_custom_units "gnocchi" "$COLLECTD_GNOCCHI_UNITS"
fi
# Configure collectd logfile plugin
@@ -99,6 +91,22 @@ function adapt_collectd_conf {
}
function config_custom_units {
service_name=$1
custom_units=$2
if [[ $custom_units != none ]]; then
OIFS=$IFS
IFS=','
for UNIT in $custom_units
do
sudo sed -i '/<UNITS>/a\ UNIT '"$UNIT"'' $COLLECTD_CONF_DIR/collectd-$service_name-plugin.conf
done
IFS=$OIFS
fi
}
# remove plugin conf file
function restore_collectd_conf {

View File

@@ -31,4 +31,5 @@ if [ -z $COLLECTD_CONF_DIR ]; then
fi
#Custom units feature
COLLECTD_CEILOMETER_UNITS=${COLLECTD_CUSTOM_UNITS:-none}
COLLECTD_CEILOMETER_UNITS=${COLLECTD_CEILOMETER_CUSTOM_UNITS:-none}
COLLECTD_GNOCCHI_UNITS=${COLLECTD_GNOCCHI_CUSTOM_UNITS:-none}

View File

@@ -61,13 +61,23 @@ COLLECTD_LOG_LEVEL
Default: info
COLLECTD_CUSTOM_UNITS
COLLECTD_CEILOMETER_CUSTOM_UNITS
(meter=unit) a comma seperated list of pairs, defining meters and their units.
Allows existing units to be changed and new units to be set for new meters.
The "meter" is generally in the form of "plugin.type", where plugin and
plugin type are attributes of the collectd data.
Example: COLLECTD_CUSTOM_UNITS="<meter> <unit>,<meter> <unit>"
Example: COLLECTD_CEILOMETER_CUSTOM_UNITS="<meter> <unit>,<meter> <unit>"
COLLECTD_GNOCCHI_CUSTOM_UNITS
(meter=unit) a comma seperated list of pairs, defining meters and their units.
Allows existing units to be changed and new units to be set for new meters.
The "meter" is generally in the form of "plugin.type", where plugin and
plugin type are attributes of the collectd data.
Example: COLLECTD_GNOCCHI_CUSTOM_UNITS="<meter> <unit>,<meter> <unit>"
COLLECTD_CEILOMETER_ENABLED
(True|False) Toggle whether collectd-ceilometer-plugin is enabled.

View File

@@ -30,5 +30,7 @@
OS_PASSWORD "password"
OS_TENANT_NAME "service"
<UNITS>
</UNITS>
</Module>
</Plugin>