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

Finalize cephpingmon

parent f92f3a9f
No related branches found
No related tags found
1 merge request!12Finalize cephpingmon
...@@ -6,9 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -6,9 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [1.3.4] - 2024-03-19 ## [1.3.4] - 2024-03-25
### Added ### Added
- cephpingmon added as optional module (default behavior unchanged) - cephpingmon added as optional module (default behavior unchanged), add fping dependency
## [1.3.3] - 2023-10-25 ## [1.3.3] - 2023-10-25
### Fixed ### Fixed
......
...@@ -6,3 +6,4 @@ curl ...@@ -6,3 +6,4 @@ curl
cronie cronie
smartmontools smartmontools
pciutils pciutils
fping
#!/bin/bash #!/bin/bash
set -eo pipefail
METRIC_NAME="cephpingmon_endpoint_accessible" METRIC_NAME="cephpingmon_endpoint_accessible"
if [[ -z "${CEPH_IPS}" ]]; then if [[ -z "${CEPH_IPS}" ]]; then
...@@ -9,24 +8,37 @@ if [[ -z "${MTU_SIZE}" ]]; then ...@@ -9,24 +8,37 @@ if [[ -z "${MTU_SIZE}" ]]; then
MTU_SIZE=8972 MTU_SIZE=8972
fi fi
printf '# HELP %s: Ceph endpoint ping success ratio. (1 ~ no loss, 0 ~ complete loss)\n' $METRIC_NAME function publish_metrics_nofrag {
local ping_result
local loss_percent
local success_ratio
local fragmentation="no"
# $1 == ip address, $2 == yes/no fragmentation allowed for ip in $CEPH_IPS; do
function publish_metric { ping_result=$(ping -q -c4 -W 1 -s $MTU_SIZE -M do $ip)
if [[ $2 == "yes" ]]; then loss_percent=$(echo ${ping_result} | sed -n -e 's/^.*, \(.*\)% packet.*/\1/p')
local ping_result=$(ping -c4 -s $MTU_SIZE $ip || echo "0 received, 100% packet loss") success_ratio=$(echo "scale=2 ; 1 - ${loss_percent} / 100" | bc)
else LC_NUMERIC=C printf '%s{endpoint_ip="%s", fragmentation="%s"} %.2f\n' \
local ping_result=$(ping -c4 -s $MTU_SIZE -M do -q $ip || echo "0 received, 100% packet loss") "${METRIC_NAME}" $ip $fragmentation "${success_ratio}"
fi done
}
local packet_loss_percent=$(echo ${ping_result} | sed -n -e 's/^.*, \(.*\)% packet.*/\1/p') function publish_metrics_frag {
local ping_success_ratio=$(echo "scale=2 ; 1 - ${packet_loss_percent} / 100" | bc) local ip
local loss_percent
local success_ratio
local fragmentation="yes"
LC_NUMERIC=C printf '%s{ip="%s", fragmentation="%s"} %.2f\n' \ while IFS= read -r line; do
"${METRIC_NAME}" "$1" "$2" "${ping_success_ratio}" ip=$(echo $line | cut -d' ' -f1)
loss_percent=$(echo $line | cut -d' ' -f5 | cut -d'/' -f3 | tr -d % | tr -d ,)
success_ratio=$(echo "scale=2 ; 1 - ${loss_percent} / 100" | bc)
LC_NUMERIC=C printf '%s{endpoint_ip="%s", fragmentation="%s"} %.2f\n' \
"${METRIC_NAME}" $ip $fragmentation "${success_ratio}"
done <<< "$1"
} }
for ip in $CEPH_IPS; do printf '# HELP %s: Ceph endpoint ping success ratio. (1 ~ no loss, 0 ~ complete loss)\n' $METRIC_NAME
publish_metric $ip yes ping_result=$(fping -q -c4 -b $MTU_SIZE $CEPH_IPS 2>&1)
publish_metric $ip no publish_metrics_frag "${ping_result}"
done publish_metrics_nofrag
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment