2025-01-24 13:21:30 +05:30
|
|
|
# check for service enabled
|
|
|
|
|
2025-01-29 16:53:31 +05:30
|
|
|
# Save trace setting
|
|
|
|
_XTRACE_PROMETHEUS_PLUGIN=$(set +o | grep xtrace)
|
|
|
|
set -o xtrace
|
|
|
|
|
|
|
|
echo_summary "devstack-plugin-prometheus's plugin.sh was called..."
|
|
|
|
. $DEST/devstack-plugin-prometheus/devstack/lib/prometheus
|
2025-01-30 13:01:22 +05:30
|
|
|
. $DEST/devstack-plugin-prometheus/devstack/lib/node_exporter
|
2025-03-18 14:17:26 +05:30
|
|
|
. $DEST/devstack-plugin-prometheus/devstack/lib/podman_exporter
|
2025-01-29 16:53:31 +05:30
|
|
|
|
|
|
|
# Show all of defined environment variables
|
|
|
|
(set -o posix; set)
|
|
|
|
|
|
|
|
## Prometheus
|
|
|
|
if is_service_enabled prometheus; then
|
2025-01-24 13:21:30 +05:30
|
|
|
if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
|
|
|
|
# Set up system services
|
|
|
|
echo_summary "Configuring system services prometheus"
|
|
|
|
pre_install_prometheus
|
|
|
|
|
|
|
|
elif [[ "$1" == "stack" && "$2" == "install" ]]; then
|
|
|
|
# Perform installation of service source
|
|
|
|
echo_summary "Installing prometheus"
|
|
|
|
install_prometheus
|
|
|
|
|
|
|
|
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
|
|
|
|
# Configure after the other layer 1 and 2 services have been configured
|
|
|
|
echo_summary "Configuring prometheus"
|
|
|
|
configure_prometheus
|
|
|
|
|
2025-01-29 16:53:31 +05:30
|
|
|
elif [[ "$1" == "stack" && "$2" == "test-config" ]]; then
|
2025-01-24 13:21:30 +05:30
|
|
|
# Initialize and start the prometheus service
|
|
|
|
echo_summary "Initializing prometheus"
|
|
|
|
init_prometheus
|
2025-01-29 16:53:31 +05:30
|
|
|
echo_summary "Starting prometheus service"
|
|
|
|
start_prometheus
|
|
|
|
echo_summary "Give time to prometheus to scrape data"
|
|
|
|
wait_for_data
|
2025-02-18 13:15:43 +05:30
|
|
|
check_data_prometheus
|
2025-01-24 13:21:30 +05:30
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$1" == "unstack" ]]; then
|
|
|
|
# Shut down prometheus services
|
|
|
|
# no-op
|
2025-01-29 16:53:31 +05:30
|
|
|
echo_summary "Stoping prometheus service"
|
|
|
|
stop_prometheus
|
2025-03-17 12:46:53 +05:30
|
|
|
echo_summary "Cleaning prometheus service"
|
|
|
|
cleanup_prometheus
|
2025-01-24 13:21:30 +05:30
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$1" == "clean" ]]; then
|
|
|
|
# Remove state and transient data
|
|
|
|
# Remember clean.sh first calls unstack.sh
|
|
|
|
# no-op
|
2025-01-29 16:53:31 +05:30
|
|
|
echo_summary "Cleaning prometheus service"
|
2025-01-24 13:21:30 +05:30
|
|
|
cleanup_prometheus
|
|
|
|
fi
|
|
|
|
fi
|
2025-01-30 13:01:22 +05:30
|
|
|
|
|
|
|
## Node Exporter
|
|
|
|
if is_service_enabled node_exporter; then
|
|
|
|
if [[ "$1" == "source" ]]; then
|
|
|
|
# Initial source of lib script
|
|
|
|
source $(dirname "$0")/lib/node_exporter
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
|
|
|
|
# Set up system services
|
|
|
|
echo_summary "Configuring system services node exporter"
|
|
|
|
pre_install_node_exporter
|
|
|
|
|
|
|
|
elif [[ "$1" == "stack" && "$2" == "install" ]]; then
|
|
|
|
# Perform installation of service source
|
|
|
|
echo_summary "Installing node exporter"
|
|
|
|
install_node_exporter
|
|
|
|
|
|
|
|
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
|
|
|
|
# Configure after the other layer 1 and 2 services have been configured
|
|
|
|
echo_summary "Configuring node_exporter"
|
|
|
|
init_node_exporter
|
|
|
|
echo_summary "Starting node exporter service"
|
|
|
|
start_node_exporter
|
|
|
|
echo_summary "Give time to node_exporter to push metrics"
|
|
|
|
wait_for_data
|
2025-02-18 13:15:43 +05:30
|
|
|
check_data_node_exporter
|
2025-01-30 13:01:22 +05:30
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$1" == "unstack" ]]; then
|
|
|
|
# Shut down node exporter services
|
|
|
|
# no-op
|
|
|
|
echo_summary "Stoping node_exporter service"
|
|
|
|
stop_node_exporter
|
2025-03-17 12:46:53 +05:30
|
|
|
echo_summary "Cleaning node exporter service"
|
|
|
|
cleanup_node_exporter
|
2025-01-30 13:01:22 +05:30
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$1" == "clean" ]]; then
|
|
|
|
# Remove state and transient data
|
|
|
|
# Remember clean.sh first calls unstack.sh
|
|
|
|
# no-op
|
|
|
|
echo_summary "Cleaning node exporter service"
|
|
|
|
cleanup_node_exporter
|
|
|
|
fi
|
|
|
|
fi
|
2025-03-18 14:17:26 +05:30
|
|
|
|
|
|
|
## Podman Exporter
|
|
|
|
if is_service_enabled podman_exporter; then
|
|
|
|
if [[ "$1" == "source" ]]; then
|
|
|
|
# Initial source of lib script
|
|
|
|
source $(dirname "$0")/lib/podman_exporter
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
|
|
|
|
# Set up system services
|
|
|
|
echo_summary "Configuring system services podman exporter"
|
|
|
|
pre_install_podman_exporter
|
|
|
|
|
|
|
|
elif [[ "$1" == "stack" && "$2" == "install" ]]; then
|
|
|
|
# Perform installation of service source
|
|
|
|
echo_summary "Installing podman exporter"
|
|
|
|
install_podman_exporter
|
|
|
|
|
|
|
|
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
|
|
|
|
# Configure after the other layer 1 and 2 services have been configured
|
|
|
|
echo_summary "Configuring podman_exporter"
|
|
|
|
init_podman_exporter
|
|
|
|
echo_summary "Starting podman exporter service"
|
|
|
|
start_podman_exporter
|
|
|
|
echo_summary "Give time to podman_exporter to push metrics"
|
|
|
|
wait_for_podman_data
|
|
|
|
check_data_podman_exporter
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$1" == "unstack" ]]; then
|
|
|
|
# Shut down podman exporter services
|
|
|
|
# no-op
|
|
|
|
echo_summary "Stoping podman_exporter service"
|
|
|
|
stop_podman_exporter
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$1" == "clean" ]]; then
|
|
|
|
# Remove state and transient data
|
|
|
|
# Remember clean.sh first calls unstack.sh
|
|
|
|
# no-op
|
|
|
|
echo_summary "Cleaning podman exporter service"
|
|
|
|
cleanup_podman_exporter
|
|
|
|
fi
|
|
|
|
fi
|