Skip to content
Snippets Groups Projects
Commit f92f3a9f authored by Josef Němec's avatar Josef Němec
Browse files

Merge branch 'feat/cephpingmon' into 'master'

Add cephpingmon

See merge request !11
parents bae6d5df 6d433f93
No related branches found
No related tags found
1 merge request!11Add cephpingmon
Pipeline #413090 passed
...@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [1.3.4] - 2024-03-19
### Added
- cephpingmon added as optional module (default behavior unchanged)
## [1.3.3] - 2023-10-25 ## [1.3.3] - 2023-10-25
### Fixed ### Fixed
- Env (vars) are made accessible to cronjobs - Env (vars) are made accessible to cronjobs
......
#!/bin/bash
set -eo pipefail
METRIC_NAME="cephpingmon_endpoint_accessible"
if [[ -z "${CEPH_IPS}" ]]; then
CEPH_IPS="147.251.62.133 147.251.62.134 147.251.62.135 10.16.80.1"
fi
if [[ -z "${MTU_SIZE}" ]]; then
MTU_SIZE=8972
fi
printf '# HELP %s: Ceph endpoint ping success ratio. (1 ~ no loss, 0 ~ complete loss)\n' $METRIC_NAME
# $1 == ip address, $2 == yes/no fragmentation allowed
function publish_metric {
if [[ $2 == "yes" ]]; then
local ping_result=$(ping -c4 -s $MTU_SIZE $ip || echo "0 received, 100% packet loss")
else
local ping_result=$(ping -c4 -s $MTU_SIZE -M do -q $ip || echo "0 received, 100% packet loss")
fi
local packet_loss_percent=$(echo ${ping_result} | sed -n -e 's/^.*, \(.*\)% packet.*/\1/p')
local ping_success_ratio=$(echo "scale=2 ; 1 - ${packet_loss_percent} / 100" | bc)
LC_NUMERIC=C printf '%s{ip="%s", fragmentation="%s"} %.2f\n' \
"${METRIC_NAME}" "$1" "$2" "${ping_success_ratio}"
}
for ip in $CEPH_IPS; do
publish_metric $ip yes
publish_metric $ip no
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment