Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
icinga-checks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
IML Open Source
icinga-checks
Commits
36f19dca
Commit
36f19dca
authored
3 months ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
check_requirements: add ping check; timout 1 sec in connection check
parent
f67286d3
No related branches found
No related tags found
1 merge request
!292
Simple task/7546 icinga check für ablaufende gitlab tokens
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_requirements
+30
-4
30 additions, 4 deletions
check_requirements
with
30 additions
and
4 deletions
check_requirements
+
30
−
4
View file @
36f19dca
...
...
@@ -12,12 +12,13 @@
# 2023-02-13 v1.0 ah initial version with check for processes, tcp/ udp
# 2023-02-15 v1.1 ah add label
# 2024-06-07 v1.2 ah use iml help and add link to docs
# 2025-02-11 v1.3 ah add ping check; add timeout in connection check
# ======================================================================
.
"
$(
dirname
$0
)
/inc_pluginfunctions"
self_APPVERSION
=
1.
2
self_APPVERSION
=
1.
3
self
=
$(
basename
$0
)
...
...
@@ -63,6 +64,7 @@ PARAMETERS:
TYPE string one of tcp|udp
TARGET string target host
PORT int port number
-i|--ping TARGET ping a target system
-l|--label STRING add label to divide the output in multiple sections
-p|--process STRING check if a process with given regex exists in the
output of 'ps aux'
...
...
@@ -124,6 +126,10 @@ function newline(){
"
}
# ----------------------------------------------------------------------
# check functions
# ----------------------------------------------------------------------
# check in process list
# param string regex to search for in output of "ps aux"
function
chkProcess
(){
...
...
@@ -145,7 +151,7 @@ function chkProcess(){
newline
}
#
c
heck connection
#
C
heck connection
# param string type: one of tcp|udp
# param string target: a servername eg. localhost or www.example.com
# param integer port number to connect
...
...
@@ -155,11 +161,11 @@ function chkConnection(){
local
port
=
"
$3
"
# port number
COUNT+
=
1
if
!
echo
"
$type
/
$target
/
$port
"
|
grep
-E
"^(tcp|udp)/[a-z][a-z0-9
\.\-
]*/[1-9][0-9]*$"
>
/dev/null 2>&1
;
then
if
!
echo
"
$type
/
$target
/
$port
"
|
grep
-E
q
"^(tcp|udp)/[a-z][a-z0-9
\.\-
]*/[1-9][0-9]*$"
;
then
COUNTERR+
=
1
OUT+
=
"ERROR syntax error detected - verify params for port check; type=
$type
(one of tcp|udp) target=
$target
(servername to connect) port=
$port
"
else
if
(
>
/dev/
$type
/
$target
/
$port
)
2>/dev/null
;
then
if
timeout
1 bash
-c
"
>/dev/
$type
/
$target
/
$port
"
2>/dev/null
;
then
COUNTOK+
=
1
addOutput
"OK"
"connection"
"
$type
to
$target
on port
$port
"
else
...
...
@@ -172,6 +178,25 @@ function chkConnection(){
newline
}
# Check ping to a target
# param string target: a servername eg. localhost or www.example.com
function
chkPing
(){
local
myHost
=
"
$1
"
local
cmdout
COUNT+
=
1
if
cmdout
=
"
$(
ping
-c
1
$myHost
2>&1
)
"
;
then
COUNTOK+
=
1
addOutput
"OK"
"ping"
"ping to
$myHost
$(
echo
"
$cmdout
"
|
head
-2
|
tail
-1
| rev |
cut
-f
-1
,2
-d
' '
| rev
)
"
else
COUNTERR+
=
1
ph.setStatus critical
addOutput
"ERROR"
"ping"
"ping to host
$myHost
FAILED"
fi
addVerbose
"
$cmdout
"
newline
}
# ----------------------------------------------------------------------
# MAIN
# ----------------------------------------------------------------------
...
...
@@ -184,6 +209,7 @@ fi
# parse params
while
[[
"$#"
-gt
0
]]
;
do case
$1
in
-c
|
--connect
)
chkConnection
"
$2
"
"
$3
"
"
$4
"
;
shift
;
shift
;
shift
;
shift
;;
-i
|
--ping
)
chkPing
"
$2
"
;
shift
;
shift
;;
-l
|
--label
)
showLabel
"
$2
"
;
shift
;
shift
;;
-p
|
--process
)
chkProcess
"
$2
"
;
shift
2
;;
-h
|
--help
)
showHelp
;
exit
0
;;
...
...
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