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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
icinga-checks
Merge requests
!147
couch db check "up" - WIP
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
couch db check "up" - WIP
6588-add-couchdb-check
into
master
Overview
0
Commits
1
Pipelines
0
Changes
1
Merged
Hahn Axel (hahn)
requested to merge
6588-add-couchdb-check
into
master
1 year ago
Overview
0
Commits
1
Pipelines
0
Changes
1
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
6fef98aa
1 commit,
1 year ago
1 file
+
93
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
check_couchdb
0 → 100755
+
93
−
0
View file @ 6fef98aa
Edit in single-file editor
Open in Web IDE
#!/bin/bash
# ======================================================================
#
# Icinga/ Nagios Check
# COUCHDB
#
# ----------------------------------------------------------------------
#
# REQUIREMENTS:
# - curl
#
# SYNTAX:
# - check_couchdb [-h] [-t FILE] -m MODE
#
# ----------------------------------------------------------------------
# 2023-08-28 v0.1 <axel.hahn@unibe.ch>
# ======================================================================
.
$(
dirname
$0
)
/inc_pluginfunctions
export
self_APPVERSION
=
0.1
function
showHelp
(){
local
_self
;
_self
=
$(
basename
$0
)
cat
<<
EOF
$(
ph.showImlHelpHeader
)
Show couchdb status.
SYNTAX:
$_self
[-h] [-t FILE] -m MODE
OPTIONS:
-h or --help show this help.
-m MODE test a value; for debugging purposes
-t FILE take couchdb auth from Telegraph config
add file like /etc/telegraf/telegraf.conf
EXAMPLE:
$_self
-m up
Check if couchdb is up and running
EOF
}
# --- check param -h
case
"
$1
"
in
"--help"
|
"-h"
)
showHelp
exit
0
;;
*
)
esac
sTelegraph
=
$(
ph.getValueWithParam
""
"t"
"
$@
"
)
sMode
=
$(
ph.getValueWithParam
''
"m"
"
$@
"
)
if
[
-n
"
$sTelegraph
"
]
;
then
if
[
!
-r
"
${
sTelegraph
}
"
]
;
then
echo
"ERROR: Telegraph config file [
${
sTelegraph
}
] cannot be read."
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
if
[
-z
"
$COUCH_URL
"
]
;
then
echo
"ERROR: I have no couchdb url + autentication yet."
echo
"Maybe you need to add -t /etc/telegraf/telegraf.conf."
ph.abort
fi
case
"
${
sMode
}
"
in
"up"
)
response
=
$(
curl
-s
"
${
COUCH_URL
}
/_up"
)
_status
=
$(
jq
'.status'
<<<
"
${
response
}
"
|
tr
-d
'"'
)
if
!
echo
"
$_status
"
|
grep
"ok"
>
/dev/null
;
then
ph.setStatus critical
fi
ph.status
"Couchdb status (value in /_up is '
$_status
')"
echo
"Reponse: "
;
echo
"
${
response
}
"
| jq
_status
=
$(
jq
'.status'
<<<
"
${
response
}
"
|
tr
-d
'"'
)
;;
*
)
echo
"ERRROR: [
${
sMode
}
] is an INVALID mode"
showHelp
ph.abort
esac
ph.exit
Loading