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
7035e0ca
Commit
7035e0ca
authored
3 years ago
by
Dominik Vašek
Browse files
Options
Downloads
Patches
Plain Diff
feat(add): gateway monitoring - ostack controlplane networks are reachable
parent
b77dbfaa
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!4
feat(add): gateway monitoring - ostack controlplane networks are reachable
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+5
-1
5 additions, 1 deletion
CHANGELOG.md
entrypoint.sh
+1
-1
1 addition, 1 deletion
entrypoint.sh
src/metric-generators/gatewaypingmon.sh
+43
-0
43 additions, 0 deletions
src/metric-generators/gatewaypingmon.sh
with
49 additions
and
2 deletions
CHANGELOG.md
+
5
−
1
View file @
7035e0ca
...
@@ -6,13 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
...
@@ -6,13 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [Unreleased]
## [1.1.0] - 2022-04-26
### Added
-
Reachability of controlplane gateways
## [1.0.5] - 2021-10-14
## [1.0.5] - 2021-10-14
### Changed
### Changed
-
none, simple rebuild
-
none, simple rebuild
## [1.0.4] - 2021-07-13
## [1.0.4] - 2021-07-13
### Fixed
### Fixed
-
dockermon id assert corrected, now expects
`/docker/`
prefix
-
dockermon id assert corrected, now expects
`/docker/`
prefix
## [1.0.3] - 2021-07-12
## [1.0.3] - 2021-07-12
### Fixed
### Fixed
...
...
This diff is collapsed.
Click to expand it.
entrypoint.sh
+
1
−
1
View file @
7035e0ca
...
@@ -11,7 +11,7 @@ CMG_MAX_JITTER_DELAY="${CMG_MAX_JITTER_DELAY:-"3"}"
...
@@ -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_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_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_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"
}
CMG_NODEROLEMON_METRICS_TEXTFILE
=
${
CMG_NODEROLEMON_METRICS_TEXTFILE
:-
"/etc/node-exporter/node-role.prom"
}
# load the library
# load the library
...
...
This diff is collapsed.
Click to expand it.
src/metric-generators/gatewaypingmon.sh
0 → 100644
+
43
−
0
View file @
7035e0ca
#!/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
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