diff --git a/check_haproxy_health b/check_haproxy_health index 7f7590d74cf52314fd3ad0623ebad86126141518..1be5adc3ee0a83c6f699dc44d131e0592401886a 100755 --- a/check_haproxy_health +++ b/check_haproxy_health @@ -12,12 +12,13 @@ # 2021-12-14 v1.3 <axel.hahn@iml.unibe.ch> use updated haproxy paser in sourced file # 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 -# 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 -export self_APPVERSION=1.6 +export self_APPVERSION=1.7 . $(dirname $0)/inc_haproxy_cfg.sh @@ -106,7 +107,7 @@ fi grep "200 OK" $tmpfile >/dev/null 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)" else ph.status "HA Proxy $safeurl is up and running." diff --git a/check_onevm b/check_onevm index d25032402bf8cd4782b5a5f592bc3a5705a9030e..c52aee81cfd4e0d40449b6563c2b206926d257b3 100755 --- a/check_onevm +++ b/check_onevm @@ -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. SYNTAX: -$(basename $0) +$_self -h or --help show this help. diff --git a/check_opencpu b/check_opencpu index 5442c2528ccce031888f37b1357357c040815f82..253daa76f9864f7a038468d7b2b8bc37d7bfb2d1 100755 --- a/check_opencpu +++ b/check_opencpu @@ -20,16 +20,18 @@ # 2019-05-22 v1.1 show built date # 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 +# 2023-08-23 v1.4 <axel.hahn@unibe.ch> add help; add param -p; fix critical status # ====================================================================== . $(dirname $0)/inc_pluginfunctions +self_APPVERSION=1.4 tmpOk=/tmp/check_opencpu-ok tmpErr=/tmp/check_opencpu-error ocpuUrl=http://localhost/ocpu -packages="eosceGLM eosceLinReg eosceReliability eosceReporter msrdAnalytics" +packagesDefault="eosceGLM eosceLinReg eosceReliability eosceReporter msrdAnalytics" paramsWget="-T 5 -t 1 --no-check-certificate" # ^ ^ @@ -40,7 +42,43 @@ paramsWget="-T 5 -t 1 --no-check-certificate" # 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(){ package=$1 pkgUrl=$ocpuUrl/library/$package/info @@ -59,23 +97,33 @@ function checkOpenCpuPackage(){ # 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 echo -n "OpenCpu: " # ----- check if WGET exists -wget --version >/dev/null 2>&1 -if [ $? -ne 0 ]; then - ph.abort "UNKNOWN (wget was not found)" -fi +ph.require wget # ----- check if openCpu is running wget $paramsWget -O /dev/null $ocpuUrl 2>/dev/null if [ $? -ne 0 ]; then 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 - ph.setStatus "error" + ph.setStatus "critical" ph.exit fi diff --git a/check_ssl b/check_ssl index e80f5d9b5def8438eb762e09970a24ea022adaa0..77e893818d6653f69bc301f72056a8826cc57efa 100755 --- a/check_ssl +++ b/check_ssl @@ -15,8 +15,9 @@ # ds=daniel.schueler@iml.unibe.ch # # 2017-03-03 v1.0 ah,ds -# 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 +# 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-08-23 v1.3 <axel.hahn@unibe.ch> fix wrong exitcode to "critical" # ====================================================================== @@ -75,7 +76,7 @@ function showHelp(){ echo | openssl s_client -connect ${sDomain}:${iPort} >/dev/null 2>&1 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" # repeat the last command without redirecting output echo | openssl s_client -connect ${sDomain}:${iPort} diff --git a/docs/20_Checks/_index.md b/docs/20_Checks/_index.md index 335c6c67b6a58caf20804c3f62d82ecbca9929a5..dda9bceb0062d6f01e0109f8b98a7f196e3ebbe7 100644 --- a/docs/20_Checks/_index.md +++ b/docs/20_Checks/_index.md @@ -30,7 +30,7 @@ There is one include script used by all checks: * [check_netstat](check_netstat.md) * [check_onehost](check_onehost.md) * [check_onevm](check_onevm.md) -* check_opencpu +* [check_opencpu](check_opencpu.md) * check_packages2install * check_php-fpm-status * check_proc_mem diff --git a/docs/20_Checks/check_opencpu.md b/docs/20_Checks/check_opencpu.md new file mode 100644 index 0000000000000000000000000000000000000000..6113c16b9f1b55c23ddd3b73c4d3769b96d38714 --- /dev/null +++ b/docs/20_Checks/check_opencpu.md @@ -0,0 +1,65 @@ +# 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 +```