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
17ba3f2d
Commit
17ba3f2d
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
first check "up"
parent
16bb44b0
No related branches found
No related tags found
1 merge request
!148
change authentication
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_couchdb
+28
-16
28 additions, 16 deletions
check_couchdb
with
28 additions
and
16 deletions
check_couchdb
+
28
−
16
View file @
17ba3f2d
...
@@ -10,16 +10,24 @@
...
@@ -10,16 +10,24 @@
# - curl
# - curl
#
#
# SYNTAX:
# SYNTAX:
# - check_couchdb [-h] [-
t
FILE] -m MODE
# - check_couchdb [-h] [-
c CFG
FILE] -m MODE
#
#
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# 2023-08-28 v0.1 <axel.hahn@unibe.ch>
# 2023-08-28 v0.1 <axel.hahn@unibe.ch> first lines
# 2023-08-28 v0.2 <axel.hahn@unibe.ch> first check "up"
# ======================================================================
# ======================================================================
.
$(
dirname
$0
)
/inc_pluginfunctions
.
$(
dirname
$0
)
/inc_pluginfunctions
export
self_APPVERSION
=
0.
1
export
self_APPVERSION
=
0.
2
cfgfile
=
/etc/icingaclient/.couchdb
# ----------------------------------------------------------------------
# FUNCTIONS
# ----------------------------------------------------------------------
# show help
function
showHelp
(){
function
showHelp
(){
local
_self
;
_self
=
$(
basename
$0
)
local
_self
;
_self
=
$(
basename
$0
)
cat
<<
EOF
cat
<<
EOF
...
@@ -32,9 +40,9 @@ $_self [-h] [-t FILE] -m MODE
...
@@ -32,9 +40,9 @@ $_self [-h] [-t FILE] -m MODE
OPTIONS:
OPTIONS:
-h or --help show this help.
-h or --help show this help.
-c CFGFILE set a custom config file
default:
${
cfgfile
}
-m MODE test a value; for debugging purposes
-m MODE test a value; for debugging purposes
-t FILE take couchdb auth from Telegraph config
add file like /etc/telegraf/telegraf.conf
EXAMPLE:
EXAMPLE:
$_self
-m up
$_self
-m up
...
@@ -43,6 +51,10 @@ $_self -m up
...
@@ -43,6 +51,10 @@ $_self -m up
EOF
EOF
}
}
# ----------------------------------------------------------------------
# MAIN
# ----------------------------------------------------------------------
# --- check param -h
# --- check param -h
case
"
$1
"
in
case
"
$1
"
in
"--help"
|
"-h"
)
"--help"
|
"-h"
)
...
@@ -52,26 +64,24 @@ case "$1" in
...
@@ -52,26 +64,24 @@ case "$1" in
*
)
*
)
esac
esac
sTelegraph
=
$(
ph.getValueWithParam
""
"t"
"
$@
"
)
sMode
=
$(
ph.getValueWithParam
''
"m"
"
$@
"
)
sMode
=
$(
ph.getValueWithParam
''
"m"
"
$@
"
)
cfgfile
=
$(
ph.getValueWithParam
"
${
cfgfile
}
"
"c"
"
$@
"
)
if
[
-n
"
$sTelegraph
"
]
;
then
if
[
!
-f
"
$cfgfile
"
]
;
then
if
[
!
-r
"
${
sTelegraph
}
"
]
;
then
echo
"ERROR: Config file [
${
cfgfile
}
] does not exist."
echo
"ERROR: Telegraph config file [
${
sTelegraph
}
] cannot be read."
ph.abort
showHelp
ph.abort
fi
_user
=
$(
grep
"basic_username = "
"
${
sTelegraph
}
"
|
cut
-f
2
-d
'"'
)
_pw
=
$(
grep
"basic_password = "
"
${
sTelegraph
}
"
|
cut
-f
2
-d
'"'
)
export
COUCH_URL
=
http://
${
_user
}
:
${
_pw
}
@localhost:5984
fi
fi
.
"
$cfgfile
"
||
exit
1
if
[
-z
"
$COUCH_URL
"
]
;
then
if
[
-z
"
$COUCH_URL
"
]
;
then
echo
"ERROR: I have no couchdb url + autentication yet."
echo
"ERROR: I have no couchdb url + aut
h
entication yet."
echo
"Maybe you need to add -t /etc/telegraf/telegraf.conf."
echo
"Maybe you need to add -t /etc/telegraf/telegraf.conf."
ph.abort
ph.abort
fi
fi
# ----------------------------------------------------------------------
case
"
${
sMode
}
"
in
case
"
${
sMode
}
"
in
"up"
)
"up"
)
response
=
$(
curl
-s
"
${
COUCH_URL
}
/_up"
)
response
=
$(
curl
-s
"
${
COUCH_URL
}
/_up"
)
...
@@ -90,3 +100,5 @@ case "${sMode}" in
...
@@ -90,3 +100,5 @@ case "${sMode}" in
esac
esac
ph.exit
ph.exit
# ----------------------------------------------------------------------
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