fd8d018bab
The check_rabbitmq_queues nrpe check accesses the cron file created for running collect stats job. This is done in order to determine if the stats are too old and an alert should be raised. The nagios user does not have access to read the cron job when running in a hardened environment where /etc/cron.d is not readable. This change refactors this logic to move the calculation of maximum age for a stats file from the check_rabbitmq_queues script and into the rabbit_utils code where it is generating the nrpe configuration. A new (optional) parameter is added to the check_rabbitmq_queues script to accept the maximum age in seconds a file can last be modified. This change also removes the trusty support in hooks/install and hooks/upgrade-charm as the rabbit_utils.py file needs to import a dependency which is installed by the scripts. It is cleaned up to make sure the croniter package is always installed on install or upgrade. Change-Id: If948fc921ee0b63682946c7cc879ac50e971e588 Closes-Bug: #1940495 Co-authored-by: Aurelien Lourot <aurelien.lourot@canonical.com>
22 lines
498 B
Bash
Executable File
22 lines
498 B
Bash
Executable File
#!/bin/bash -e
|
|
# Wrapper to ensure that the required py3 versions are installed if upgrading
|
|
# from a py2 charm to a py3 based charm.
|
|
|
|
declare -a DEPS=('apt' 'netaddr' 'netifaces' 'pip' 'yaml' 'dnspython' 'requests' 'croniter')
|
|
|
|
check_and_install() {
|
|
pkg="${1}-${2}"
|
|
if ! dpkg -s ${pkg} 2>&1 > /dev/null; then
|
|
apt-get -y install ${pkg}
|
|
fi
|
|
}
|
|
|
|
PYTHON="python3"
|
|
|
|
apt-get update
|
|
for dep in ${DEPS[@]}; do
|
|
check_and_install ${PYTHON} ${dep}
|
|
done
|
|
|
|
exec ./hooks/upgrade-charm.real
|