Skip to content
Snippets Groups Projects
Commit c903ced9 authored by Dominik Vašek's avatar Dominik Vašek
Browse files

Merge branch 'feature/gatewaymon' into 'master'

feat(add): gateway monitoring - ostack controlplane networks are reachable

See merge request !4
parents b77dbfaa 7035e0ca
No related branches found
No related tags found
1 merge request!4feat(add): gateway monitoring - ostack controlplane networks are reachable
Pipeline #153176 passed
......@@ -6,13 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [1.1.0] - 2022-04-26
### Added
- Reachability of controlplane gateways
## [1.0.5] - 2021-10-14
### Changed
- none, simple rebuild
## [1.0.4] - 2021-07-13
### Fixed
- dockermon id assert corrected, now expects `/docker/` prefix
- dockermon id assert corrected, now expects `/docker/` prefix
## [1.0.3] - 2021-07-12
### Fixed
......
......@@ -11,7 +11,7 @@ CMG_MAX_JITTER_DELAY="${CMG_MAX_JITTER_DELAY:-"3"}"
CMG_OUT_METRICS_DIR="${CMG_OUT_METRICS_DIR:-"${CMG_BASE_DIR}/out-metrics-dir"}"
CMG_STDOUT_LOG="${CMG_STDOUT_LOG:-"${CMG_BASE_DIR}/custom-metrics-generator.stdout.log"}"
CMG_STDERR_LOG="${CMG_STDERR_LOG:-"${CMG_BASE_DIR}/custom-metrics-generator.stderr.log"}"
CMG_EXEC_MODULES="${CMG_EXEC_MODULES:-"smartmon dockermon puppetmon noderolemon"}"
CMG_EXEC_MODULES="${CMG_EXEC_MODULES:-"smartmon dockermon puppetmon noderolemon gatewaypingmon"}"
CMG_NODEROLEMON_METRICS_TEXTFILE=${CMG_NODEROLEMON_METRICS_TEXTFILE:-"/etc/node-exporter/node-role.prom"}
# load the library
......
#!/usr/bin/env bash
# prometheus textfile metrics generator for node-exporter textfile collector
# Monitors: gateway reachability from host
# Usage: gatewaypingmon.sh <gw1> <gw2> ...
set -eo pipefail
METRIC_NAME="gatewaypingmon_prefix_gateway_accessible"
if [ -z "${GATEWAYPINGMON_GATEWAYS}" ] ; then
if hostname | grep -qF .stage.; then
GATEWAYPINGMON_GATEWAYS=("10.16.113.1" "10.16.104.1" "10.16.127.129" "147.251.62.129")
else
GATEWAYPINGMON_GATEWAYS=("10.16.100.1" "10.16.108.1" "10.16.61.1" "147.251.62.129")
fi
else
if ! declare -p GATEWAYPINGMON_GATEWAYS | grep -qE "declare[ \t]+-a[ \t]+"; then
GATEWAYPINGMON_GATEWAYS=(${GATEWAYPINGMON_GATEWAYS})
fi
fi
GATEWAYPINGMON_PING_ARGS=${GATEWAYPINGMON_PING_ARGS:-"-c 4 -i 0.2"}
ACCESS_RATIO=()
CMG_SRC_DIR=$(dirname $(dirname $(readlink -f $0)))
STAGE_NAME="configuration loaded"
source "${CMG_SRC_DIR}/../custom-metrics-generator.conf.env"
STAGE_NAME="library loaded"
source "${CMG_SRC_DIR}/lib.sh"
STAGE_NAME="accessibility of mandatory gateways from host tested"
for gateway in ${GATEWAYPINGMON_GATEWAYS[@]}; do
ping_result=$(ping ${GATEWAYPINGMON_PING_ARGS} ${gateway} || echo "0 received, 100% packet loss")
packet_loss_percent=$(echo $ping_result | sed -n -e 's/^.*, \(.*\)% packet.*/\1/p')
ACCESS_RATIO+=($(echo "scale=2 ; 1 - ${packet_loss_percent} / 100" | bc))
done
STAGE_NAME="accessibility of gateways is generated"
printf '# HELP %s: Current network gateway ping access ratio. (1 ~ no loss, 0 ~ complete loss)\n' "${METRIC_NAME}"
for ((i=0; i<${#GATEWAYPINGMON_GATEWAYS[*]}; i++)); do
printf '%s{gateway="%s"} %.2f\n' \
"${METRIC_NAME}" "${GATEWAYPINGMON_GATEWAYS[${i}]}" "${ACCESS_RATIO[${i}]}"
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment