Skip to content
Snippets Groups Projects
Commit a3c925ce authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Merge branch '6468-docs-and-harmonize' into 'master'

6468 docs and harmonize

See merge request !138
parents 02999619 ee7074ff
Branches
No related tags found
1 merge request!1386468 docs and harmonize
...@@ -13,11 +13,12 @@ ...@@ -13,11 +13,12 @@
# 2022-04-01 v1.4 <axel.hahn@iml.unibe.ch> use wget default params; shell fixes # 2022-04-01 v1.4 <axel.hahn@iml.unibe.ch> use wget default params; shell fixes
# 2022-10-21 v1.5 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space # 2022-10-21 v1.5 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space
# 2023-07-28 v1.6 <axel.hahn@unibe.ch> add help page # 2023-07-28 v1.6 <axel.hahn@unibe.ch> add help page
# 2023-08-23 v1.7 <axel.hahn@unibe.ch> fix wrong exitcode to "critical"
# ====================================================================== # ======================================================================
. $(dirname $0)/inc_pluginfunctions . $(dirname $0)/inc_pluginfunctions
export self_APPVERSION=1.6 export self_APPVERSION=1.7
. $(dirname $0)/inc_haproxy_cfg.sh . $(dirname $0)/inc_haproxy_cfg.sh
...@@ -106,7 +107,7 @@ fi ...@@ -106,7 +107,7 @@ fi
grep "200 OK" $tmpfile >/dev/null grep "200 OK" $tmpfile >/dev/null
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
ph.setStatus "error" ph.setStatus "critical"
ph.status "url $safeurl did not contain 200 OK. $(wget -T 5 -t 1 --no-check-certificate -O - -S $url)" ph.status "url $safeurl did not contain 200 OK. $(wget -T 5 -t 1 --no-check-certificate -O - -S $url)"
else else
ph.status "HA Proxy $safeurl is up and running." ph.status "HA Proxy $safeurl is up and running."
......
...@@ -62,7 +62,7 @@ It will go to warning if a non running state was found. ...@@ -62,7 +62,7 @@ It will go to warning if a non running state was found.
It will go to critical if a vm is on failure. It will go to critical if a vm is on failure.
SYNTAX: SYNTAX:
$(basename $0) $_self
-h or --help show this help. -h or --help show this help.
......
...@@ -20,16 +20,18 @@ ...@@ -20,16 +20,18 @@
# 2019-05-22 v1.1 show built date # 2019-05-22 v1.1 show built date
# 2020-03-05 v1.2 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions # 2020-03-05 v1.2 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions
# 2022-04-01 v1.3 <axel.hahn@iml.unibe.ch> use wget default params; shell fixes # 2022-04-01 v1.3 <axel.hahn@iml.unibe.ch> use wget default params; shell fixes
# 2023-08-23 v1.4 <axel.hahn@unibe.ch> add help; add param -p; fix critical status
# ====================================================================== # ======================================================================
. $(dirname $0)/inc_pluginfunctions . $(dirname $0)/inc_pluginfunctions
self_APPVERSION=1.4
tmpOk=/tmp/check_opencpu-ok tmpOk=/tmp/check_opencpu-ok
tmpErr=/tmp/check_opencpu-error tmpErr=/tmp/check_opencpu-error
ocpuUrl=http://localhost/ocpu ocpuUrl=http://localhost/ocpu
packages="eosceGLM eosceLinReg eosceReliability eosceReporter msrdAnalytics" packagesDefault="eosceGLM eosceLinReg eosceReliability eosceReporter msrdAnalytics"
paramsWget="-T 5 -t 1 --no-check-certificate" paramsWget="-T 5 -t 1 --no-check-certificate"
# ^ ^ # ^ ^
...@@ -40,7 +42,43 @@ paramsWget="-T 5 -t 1 --no-check-certificate" ...@@ -40,7 +42,43 @@ paramsWget="-T 5 -t 1 --no-check-certificate"
# FUNCTIONS # FUNCTIONS
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# show help text
function showHelp(){
local _self; _self=$(basename $0)
cat <<EOF
$( ph.showImlHelpHeader )
Test if opencpu is available.
It returns OK if
- opencpu is running on $ocpuUrl
- all packages are installed:
$packagesDefault
SYNTAX:
$_self [-h] [-p PKG]
OPTIONS:
-h or --help show this help and exit.
PARAMETERS:
-p PKG(s) define package to test; for multiple packages quote
it and delimit them with space.
EXAMPLES:
$_self -p "myPackage1 myPackage2 anotherPackage"
Check given opencpu packages
$_self -p ""
Check Opencpu only (without packages)
EOF
}
# check if a givem packe is installed
# param string name of the package
function checkOpenCpuPackage(){ function checkOpenCpuPackage(){
package=$1 package=$1
pkgUrl=$ocpuUrl/library/$package/info pkgUrl=$ocpuUrl/library/$package/info
...@@ -59,23 +97,33 @@ function checkOpenCpuPackage(){ ...@@ -59,23 +97,33 @@ function checkOpenCpuPackage(){
# MAIN # MAIN
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# --- check param -h
case "$1" in
"--help"|"-h")
showHelp
exit 0
;;
*)
esac
packages=$( ph.getValueWithParam "$packagesDefault" "p" "$@" | sort )
rm -f $tmpOk 2>/dev/null rm -f $tmpOk 2>/dev/null
echo -n "OpenCpu: " echo -n "OpenCpu: "
# ----- check if WGET exists # ----- check if WGET exists
wget --version >/dev/null 2>&1 ph.require wget
if [ $? -ne 0 ]; then
ph.abort "UNKNOWN (wget was not found)"
fi
# ----- check if openCpu is running # ----- check if openCpu is running
wget $paramsWget -O /dev/null $ocpuUrl 2>/dev/null wget $paramsWget -O /dev/null $ocpuUrl 2>/dev/null
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "ERROR: unable to connect to openCpu with $ocpuUrl" echo "ERROR: unable to connect to openCpu with $ocpuUrl"
echo
echo "I repeat the http request to show some more debug infos:"
wget $paramsWget -O /dev/null -S $ocpuUrl wget $paramsWget -O /dev/null -S $ocpuUrl
ph.setStatus "error" ph.setStatus "critical"
ph.exit ph.exit
fi fi
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
# 2017-03-03 v1.0 ah,ds # 2017-03-03 v1.0 ah,ds
# 2020-03-05 v1.1 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions # 2020-03-05 v1.1 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions
# 2023-02-13 v1.2 <axel.hahn@unibe.ch> some shell fixes # 2023-02-13 v1.2 <axel.hahn@unibe.ch> some shell fixes
# 2023-08-23 v1.3 <axel.hahn@unibe.ch> fix wrong exitcode to "critical"
# ====================================================================== # ======================================================================
...@@ -75,7 +76,7 @@ function showHelp(){ ...@@ -75,7 +76,7 @@ function showHelp(){
echo | openssl s_client -connect ${sDomain}:${iPort} >/dev/null 2>&1 echo | openssl s_client -connect ${sDomain}:${iPort} >/dev/null 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
ph.setStatus "error" ph.setStatus "critical"
ph.status "unable to connect to ${sDomain} via port :${iPort} - maybe wrong host ... or port ... wrong chaining" ph.status "unable to connect to ${sDomain} via port :${iPort} - maybe wrong host ... or port ... wrong chaining"
# repeat the last command without redirecting output # repeat the last command without redirecting output
echo | openssl s_client -connect ${sDomain}:${iPort} echo | openssl s_client -connect ${sDomain}:${iPort}
......
...@@ -30,7 +30,7 @@ There is one include script used by all checks: ...@@ -30,7 +30,7 @@ There is one include script used by all checks:
* [check_netstat](check_netstat.md) * [check_netstat](check_netstat.md)
* [check_onehost](check_onehost.md) * [check_onehost](check_onehost.md)
* [check_onevm](check_onevm.md) * [check_onevm](check_onevm.md)
* check_opencpu * [check_opencpu](check_opencpu.md)
* check_packages2install * check_packages2install
* check_php-fpm-status * check_php-fpm-status
* check_proc_mem * check_proc_mem
......
# check_opencpu
## Introduction
Test if OpenCpu is available via http and test if given packages are installed.
### Requirements
* wget
## Syntax
```text
> ./check_opencpu -h
______________________________________________________________________
CHECK_OPENCPU
v1.4
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
https://os-docs.iml.unibe.ch/icinga-checks/Checks/check_opencpu.html
______________________________________________________________________
Test if opencpu is available.
It returns OK if
- opencpu is running on http://localhost/ocpu
- all packages are installed:
eosceGLM eosceLinReg eosceReliability eosceReporter msrdAnalytics
SYNTAX:
check_opencpu [-h] [-p PKG]
OPTIONS:
-h or --help show this help and exit.
PARAMETERS:
-p PKG(s) define package to test; for multiple packages quote
it and delimit them with space.
EXAMPLES:
check_opencpu -p "myPackage1 myPackage2 anotherPackage"
Check given opencpu packages
check_opencpu -p ""
Check Opencpu only (without packages)
```
## Examples
### Check with packages
```txt
OpenCpu: OK
OK: openCpu is running and reachable with http
OK: package is available [myPackage1] .. Build: R 4.1.1; ; 2021-11-09 10:18:01 UTC; unix
OK: package is available [myPackage2] .. Build: R 4.1.1; ; 2022-03-07 11:07:03 UTC; unix
OK: package is available [anotherPackage] .. Build: R 4.1.2; ; 2023-07-18 08:32:57 UTC; unix
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment