Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
custom-metrics-generator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cloud
custom-metrics-generator
Commits
fb5ddac9
Commit
fb5ddac9
authored
1 year ago
by
Josef Němec
Browse files
Options
Downloads
Patches
Plain Diff
Finalize cephpingmon
parent
f92f3a9f
No related branches found
No related tags found
1 merge request
!12
Finalize cephpingmon
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+2
-2
2 additions, 2 deletions
CHANGELOG.md
dependencies.yum.txt
+1
-0
1 addition, 0 deletions
dependencies.yum.txt
src/metric-generators/cephpingmon.sh
+29
-17
29 additions, 17 deletions
src/metric-generators/cephpingmon.sh
with
32 additions
and
19 deletions
CHANGELOG.md
+
2
−
2
View file @
fb5ddac9
...
...
@@ -6,9 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [1.3.4] - 2024-03-
19
## [1.3.4] - 2024-03-
25
### 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
### Fixed
...
...
This diff is collapsed.
Click to expand it.
dependencies.yum.txt
+
1
−
0
View file @
fb5ddac9
...
...
@@ -6,3 +6,4 @@ curl
cronie
smartmontools
pciutils
fping
This diff is collapsed.
Click to expand it.
src/metric-generators/cephpingmon.sh
+
29
−
17
View file @
fb5ddac9
#!/bin/bash
set
-eo
pipefail
METRIC_NAME
=
"cephpingmon_endpoint_accessible"
if
[[
-z
"
${
CEPH_IPS
}
"
]]
;
then
...
...
@@ -9,24 +8,37 @@ 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
function
publish_metrics_nofrag
{
local
ping_result
local
loss_percent
local
success_ratio
local
fragmentation
=
"no"
# $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
for
ip
in
$CEPH_IPS
;
do
ping_result
=
$(
ping
-q
-c4
-W
1
-s
$MTU_SIZE
-M
do
$ip
)
loss_percent
=
$(
echo
${
ping_result
}
|
sed
-n
-e
's/^.*, \(.*\)% packet.*/\1/p'
)
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
}
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
)
function
publish_metrics_frag
{
local
ip
local
loss_percent
local
success_ratio
local
fragmentation
=
"yes"
LC_NUMERIC
=
C
printf
'%s{ip="%s", fragmentation="%s"} %.2f\n'
\
"
${
METRIC_NAME
}
"
"
$1
"
"
$2
"
"
${
ping_success_ratio
}
"
while
IFS
=
read
-r
line
;
do
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
publish_metric
$ip
yes
publish_metric
$ip
no
done
printf
'# HELP %s: Ceph endpoint ping success ratio. (1 ~ no loss, 0 ~ complete loss)\n'
$METRIC_NAME
ping_result
=
$(
fping
-q
-c4
-b
$MTU_SIZE
$CEPH_IPS
2>&1
)
publish_metric
s_frag
"
${
ping_result
}
"
publish_metrics_nofrag
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment