diff --git a/about b/about index 44fb6f5d8568d0ff55821d08f04cd197460525ac..0bea24abf0596340552f142c24b46175b0fc54aa 100755 --- a/about +++ b/about @@ -5,14 +5,16 @@ # ABOUT # # ---------------------------------------------------------------------- -# 2023-10-23 v1.0 <axel.hahn@unibe.ch> initial version -# 2023-10-25 v1.1 <axel.hahn@unibe.ch> show disks, show installed versions (WIP) -# 2023-12-22 v1.2 <axel.hahn@unibe.ch> show help +# 2023-10-23 v1.0 <axel.hahn@unibe.ch> initial version +# 2023-10-25 v1.1 <axel.hahn@unibe.ch> show disks, show installed versions (WIP) +# 2023-12-22 v1.2 <axel.hahn@unibe.ch> show help +# 2025-02-10 v1.3 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $(dirname $0)/inc_pluginfunctions +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -export self_APPVERSION=1.2 +export self_APPVERSION=1.3 . /etc/icingaclient/client.cfg 2>/dev/null @@ -27,7 +29,7 @@ export self_APPVERSION=1.2 # show help text function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_apache_requests b/check_apache_requests index af9f8d17419422fb67e8867db576eeb059693371..ce7b506a73fca66ca1c2e5d297b65b5ff29b936f 100755 --- a/check_apache_requests +++ b/check_apache_requests @@ -13,9 +13,12 @@ # 2022-08-31 v1.4 <axel.hahn@iml.unibe.ch> add help; shellfix corrections # 2023-06-19 v1.5 <axel.hahn@unibe.ch> no more tmpfile # 2023-07-27 v1.6 <axel.hahn@unibe.ch> update help page +# 2025-02-10 v1.3 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $(dirname $0)/inc_pluginfunctions +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 + export self_APPVERSION=1.6 # url=`hostname -f`/server-status @@ -41,7 +44,7 @@ paramsWget="-T 5 -t 1 --no-check-certificate" # ---------------------------------------------------------------------- function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_ceph_diskfree b/check_ceph_diskfree index b9e9bc3f1cee02256592b74d0886ed75074f976f..ec012bcc4b625100fa67a36d1d7f1313b87f051b 100755 --- a/check_ceph_diskfree +++ b/check_ceph_diskfree @@ -22,10 +22,11 @@ # 2023-06-19 v1.4 <axel.hahn@unibe.ch> no more tmpfile # 2023-07-27 v1.5 <axel.hahn@unibe.ch> update help page # 2023-10-20 v1.6 <axel.hahn@unibe.ch> harden sudo command execution -# 2025-02-12 v1.7 <axel.hahn@unibe.ch> Show -w and -c param in help +# 2025-02-10 v1.7 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $(dirname $0)/inc_pluginfunctions +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 export self_APPVERSION=1.7 @@ -34,7 +35,7 @@ typeset -i iCritical=0 function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) @@ -44,7 +45,8 @@ This check sends performance data. It uses 'ceph df' to parse data. SYNTAX: -$(basename $0) + + $_self OPTIONS: -h or --help show this help. diff --git a/check_ceph_io b/check_ceph_io index a5034a568e6c1d413baec366453e1233402e143a..b0dc78e05ab996c2c4333b94c97732bae7719f79 100755 --- a/check_ceph_io +++ b/check_ceph_io @@ -15,19 +15,21 @@ # # ---------------------------------------------------------------------- # 2023-05-09 v1.0 <axel.hahn@unibe.ch> -# 2023-05-10 v1.1 <axel.hahn@unibe.ch> fix for small transfer rates in B/s -# 2023-05-10 v1.2 <axel.hahn@unibe.ch> add tests -# 2023-05-11 v1.3 <axel.hahn@unibe.ch> handle ceph status without io data in output -# 2023-07-27 v1.4 <axel.hahn@unibe.ch> update help page -# 2023-10-20 v1.5 <axel.hahn@unibe.ch> harden sudo command execution +# 2023-05-10 v1.1 <axel.hahn@unibe.ch> fix for small transfer rates in B/s +# 2023-05-10 v1.2 <axel.hahn@unibe.ch> add tests +# 2023-05-11 v1.3 <axel.hahn@unibe.ch> handle ceph status without io data in output +# 2023-07-27 v1.4 <axel.hahn@unibe.ch> update help page +# 2023-10-20 v1.5 <axel.hahn@unibe.ch> harden sudo command execution +# 2025-02-10 v1.6 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $(dirname $0)/inc_pluginfunctions +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -export self_APPVERSION=1.5 +export self_APPVERSION=1.6 function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_ceph_osd b/check_ceph_osd index 8de525537d8cfe428dd573bdbf62b9865f82c012..cac24b1c2722012793a53af509d7f4ebca5c0602 100755 --- a/check_ceph_osd +++ b/check_ceph_osd @@ -22,17 +22,19 @@ # ---------------------------------------------------------------------- # 2020-03-04 v1.0 <axel.hahn@iml.unibe.ch> # 2020-03-05 v1.1 <axel.hahn@iml.unibe.ch> added params -w -c -# 2020-03-05 v1.2 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions -# 2022-10-21 v1.3 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space -# 2023-04-24 v1.4 <axel.hahn@unibe.ch> update for newer ceph versions -# 2023-06-19 v1.5 <axel.hahn@unibe.ch> add help and param support; no more tmpfile -# 2023-07-27 v1.6 <axel.hahn@unibe.ch> shorten ceph exec; show output on error; shell fixes -# 2023-10-20 v1.7 <axel.hahn@unibe.ch> harden sudo command execution +# 2020-03-05 v1.2 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions +# 2022-10-21 v1.3 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space +# 2023-04-24 v1.4 <axel.hahn@unibe.ch> update for newer ceph versions +# 2023-06-19 v1.5 <axel.hahn@unibe.ch> add help and param support; no more tmpfile +# 2023-07-27 v1.6 <axel.hahn@unibe.ch> shorten ceph exec; show output on error; shell fixes +# 2023-10-20 v1.7 <axel.hahn@unibe.ch> harden sudo command execution +# 2025-02-10 v1.8 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $(dirname $0)/inc_pluginfunctions +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -export self_APPVERSION=1.7 +export self_APPVERSION=1.8 # column number in output where to find the up/ down info iColUpDown=5 @@ -42,7 +44,7 @@ iColUpDown=5 # ---------------------------------------------------------------------- function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_ceph_status b/check_ceph_status index d2e25fede66d627877316427150e731b19366209..480b5be9dbbc33459bc77ee612c8f234448fd646 100755 --- a/check_ceph_status +++ b/check_ceph_status @@ -23,11 +23,13 @@ # 2023-07-27 v1.6 <axel.hahn@unibe.ch> update help page # 2023-10-20 v1.7 <axel.hahn@unibe.ch> harden sudo command execution # 2024-02-29 v1.8 <axel.hahn@unibe.ch> show restore progress only for misplaed/ degraded objects +# 2025-02-10 v1.9 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $(dirname $0)/inc_pluginfunctions +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -export self_APPVERSION=1.8 +export self_APPVERSION=1.9 initfile="/tmp/ceph-status-not-ok-start-$USER" @@ -45,7 +47,7 @@ line="__________________________________________________________________________ # ---------------------------------------------------------------------- function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_clientbackup b/check_clientbackup index d9b18fb5ee976db8a19ed28bb903ff9e7fc3e0d3..075be12ae76654b09f8ccfa435ab095df7c42b87 100755 --- a/check_clientbackup +++ b/check_clientbackup @@ -6,24 +6,26 @@ # ---------------------------------------------------------------------- # 2016-12-09 v1.0 first lines # 2016-12-23 v1.1 added readable exitcode from shared functions file -# 2020-03-05 v1.2 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions -# 2020-04-04 v1.3 <axel.hahn@iml.unibe.ch> set status unknown if never executed -# 2022-02-17 v1.4 <axel.hahn@iml.unibe.ch> no tmpfile; show more output to see backed up dirs -# 2022-03-07 v1.5 <axel.hahn@iml.unibe.ch> update scan for results in transfer -# 2022-03-18 v1.6 <axel.hahn@iml.unibe.ch> show dumped databases -# 2022-03-21 v1.7 <axel.hahn@iml.unibe.ch> show databases infos for couchdb2 too -# 2022-03-23 v1.8 <axel.hahn@iml.unibe.ch> FIX: exit with error if backup error occured -# 2022-08-10 v1.9 <axel.hahn@iml.unibe.ch> FIX: mask the dot in .log -# 2022-10-21 v1.10 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space -# show last backup, prune, verify -# 2023-06-22 v1.11 <axel.hahn@unibe.ch> add help and param support; add parameter for install directory -# 2023-07-27 v1.12 <axel.hahn@unibe.ch> add docs url of IML backup -# 2023-09-01 v1.13 <axel.hahn@unibe.ch> add changecounters and performancedata +# 2020-03-05 v1.2 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions +# 2020-04-04 v1.3 <axel.hahn@iml.unibe.ch> set status unknown if never executed +# 2022-02-17 v1.4 <axel.hahn@iml.unibe.ch> no tmpfile; show more output to see backed up dirs +# 2022-03-07 v1.5 <axel.hahn@iml.unibe.ch> update scan for results in transfer +# 2022-03-18 v1.6 <axel.hahn@iml.unibe.ch> show dumped databases +# 2022-03-21 v1.7 <axel.hahn@iml.unibe.ch> show databases infos for couchdb2 too +# 2022-03-23 v1.8 <axel.hahn@iml.unibe.ch> FIX: exit with error if backup error occured +# 2022-08-10 v1.9 <axel.hahn@iml.unibe.ch> FIX: mask the dot in .log +# 2022-10-21 v1.10 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space +# show last backup, prune, verify +# 2023-06-22 v1.11 <axel.hahn@unibe.ch> add help and param support; add parameter for install directory +# 2023-07-27 v1.12 <axel.hahn@unibe.ch> add docs url of IML backup +# 2023-09-01 v1.13 <axel.hahn@unibe.ch> add changecounters and performancedata +# 2025-02-10 v1.14 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $( dirname $0 )/inc_pluginfunctions +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -export self_APPVERSION=1.13 +export self_APPVERSION=1.14 sInstalldir=/opt/imlbackup/client/ @@ -32,7 +34,7 @@ sInstalldir=/opt/imlbackup/client/ # ---------------------------------------------------------------------- function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_conn b/check_conn index bbf9842adb6cbfc07bb883172f673e8aa09811f7..f0af26d95af0b67012c748bcd9f06c54899dd983 100755 --- a/check_conn +++ b/check_conn @@ -10,12 +10,14 @@ # 2021-11-05 v0.0 <axel.hahn@iml.unibe.ch> # 2023-07-27 v1.1 <axel.hahn@unibe.ch> update help page # 2025-02-10 v1.2 <axel.hahn@unibe.ch> no text on STDERR if portcheck fails +# 2025-02-10 v1.3 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. $(dirname $0)/inc_pluginfunctions || exit 1 -export self_APPVERSION=1.2 -cfgfile=$( dirname $0 )/$( basename $0 ).cfg +export self_APPVERSION=1.3 +cfgfile="$0.cfg" out="" # ---------------------------------------------------------------------- @@ -31,7 +33,7 @@ function getChecks(){ function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) @@ -92,7 +94,7 @@ typeset -i iErrors=0 typeset -i iOK=0 typeset -i iCount=0 -for myline in $( echo $configline; getChecks $cfgfile ) +for myline in $( echo "$configline"; getChecks "$cfgfile" ) do iCount=$iCount+1 diff --git a/check_couchdb b/check_couchdb index 1dbae7de834b55ef6e9c445b1ce46d83e84fc9d8..d6fd7d9ede1c02dc0f89775e4386d9eed7ee0c57 100755 --- a/check_couchdb +++ b/check_couchdb @@ -13,20 +13,21 @@ # - check_couchdb [-h] [-c CFGFILE] -m MODE # # ---------------------------------------------------------------------- -# 2023-08-28 v0.1 <axel.hahn@unibe.ch> first lines -# 2023-08-28 v0.2 <axel.hahn@unibe.ch> first check "up" -# 2023-08-28 v0.3 <axel.hahn@unibe.ch> add check "replication" -# 2023-08-28 v0.4 <axel.hahn@unibe.ch> add check "pending" -# 2023-08-28 v0.5 <axel.hahn@unibe.ch> add checks "open_databases" + "open_os_files" -# 2023-08-28 v0.6 <axel.hahn@unibe.ch> add check "httpd_methods" -# 2023-08-29 v0.7 <axel.hahn@unibe.ch> add check "httpd" -# 2023-08-29 v0.8 <axel.hahn@unibe.ch> add check "httpd_status_codes" -# 2024-01-25 v0.9 <axel.hahn@unibe.ch> "httpd_status_codes" show total requests per sec +# 2023-08-28 v0.1 <axel.hahn@unibe.ch> first lines +# 2023-08-28 v0.2 <axel.hahn@unibe.ch> first check "up" +# 2023-08-28 v0.3 <axel.hahn@unibe.ch> add check "replication" +# 2023-08-28 v0.4 <axel.hahn@unibe.ch> add check "pending" +# 2023-08-28 v0.5 <axel.hahn@unibe.ch> add checks "open_databases" + "open_os_files" +# 2023-08-28 v0.6 <axel.hahn@unibe.ch> add check "httpd_methods" +# 2023-08-29 v0.7 <axel.hahn@unibe.ch> add check "httpd" +# 2023-08-29 v0.8 <axel.hahn@unibe.ch> add check "httpd_status_codes" +# 2025-02-10 v1.0 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $(dirname $0)/inc_pluginfunctions +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -export self_APPVERSION=0.8 +export self_APPVERSION=1.0 cfgfile=/etc/icingaclient/.couchdb export RESPONSE @@ -40,7 +41,7 @@ NL=" # show help function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_cpu b/check_cpu index edf44bf8a0e58bd05c49d976bec5bee90e031b51..652935c16dc5575507dd8d06e9ab667a1c39393e 100755 --- a/check_cpu +++ b/check_cpu @@ -24,19 +24,20 @@ # 2023-02-13 v1.13 <axel.hahn@iml.unibe.ch> small shell fixes # 2023-07-27 v1.14 <axel.hahn@unibe.ch> update help page # 2023-09-18 v1.15 <axel.hahn@unibe.ch> prevent broken pipe message in journallog +# 2025-02-10 v1.16 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. $(dirname $0)/inc_pluginfunctions - -export self_APPVERSION=1.15 +export self_APPVERSION=1.16 # ---------------------------------------------------------------------- # functions # ---------------------------------------------------------------------- function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) @@ -47,7 +48,8 @@ On higher cpu usage it can show processes that cause cpu waits and with most cpu consumption. SYNTAX: -$(basename $0) [-w WARN_LIMIT] [-c CRITICAL_LIMIT] [-i CRITICAL_IO_WAIT] [-p PROCESS_LIMIT] + + $_self [-w WARN_LIMIT] [-c CRITICAL_LIMIT] [-i CRITICAL_IO_WAIT] [-p PROCESS_LIMIT] OPTIONS: @@ -66,7 +68,8 @@ PARAMETERS: None. EXAMPLE: -$(basename $0) -w 60 -c 80 -p 40 + + $_self -w 60 -c 80 -p 40 EOF } diff --git a/check_cronstatus b/check_cronstatus index e904cc1403f1f4f1584d8eede5ff3bf54575cde6..2a1c63facc44152c429d7b9796579fdff036dd9c 100755 --- a/check_cronstatus +++ b/check_cronstatus @@ -27,12 +27,13 @@ # 2023-09-18 v2.2 <axel.hahn@unibe.ch> replace pipes in systemctl status output # 2024-04-03 v2.3 <axel.hahn@unibe.ch> add NO_COLOR=1 to supress color and emojis # 2024-04-24 v2.4 <axel.hahn@unibe.ch> add short status on top of details +# 2025-02-10 v2.5 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. $( dirname $0 )/inc_pluginfunctions - -export self_APPVERSION=2.4 +export self_APPVERSION=2.5 statusScript=/opt/cronwrapper/cronstatus.sh @@ -41,7 +42,7 @@ statusScript=/opt/cronwrapper/cronstatus.sh # ---------------------------------------------------------------------- function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) @@ -54,7 +55,8 @@ The last run of each job is verified to these conditions: SYNTAX: -$(basename $0) [-h] [SCRIPT] + + $_self [-h] [SCRIPT] OPTIONS: diff --git a/check_deployment b/check_deployment index a2334e7a387521c7dada1a9717da77062f9234f3..98c7ff5fa60f055051ad75a91463376403afdb40 100755 --- a/check_deployment +++ b/check_deployment @@ -5,11 +5,13 @@ # # ---------------------------------------------------------------------- # 2023-12-14 v0.1 first lines +# 2025-02-10 v1.0 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $( dirname $0 )/inc_pluginfunctions +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -export self_APPVERSION=0.1 +export self_APPVERSION=1.0 sInstalldir=/opt/imldeployment-installer @@ -18,7 +20,7 @@ sInstalldir=/opt/imldeployment-installer # ---------------------------------------------------------------------- function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_disk-io b/check_disk-io index 82d57d797883e03cfb96c37498022b21fc481380..4e4c6cba57cbb2b3cdb84b7f895bec48e9d81e3a 100755 --- a/check_disk-io +++ b/check_disk-io @@ -14,12 +14,13 @@ # ---------------------------------------------------------------------- # 2020-07-17 v1.0 <axel.hahn@iml.unibe.ch> # 2023-07-27 v1.1 <axel.hahn@unibe.ch> shell fixes; remove unsupported warn and critical +# 2025-02-10 v1.2 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. $( dirname $0 )/inc_pluginfunctions - -export self_APPVERSION=1.1 +export self_APPVERSION=1.2 # ---------------------------------------------------------------------- # FUNCTIONS @@ -45,7 +46,7 @@ function getDisks(){ # show help function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_dns_responsetime b/check_dns_responsetime index d38b4d966a5247910fcacccffd91f500b94559d2..3194a198b5a34593f23dacfa3d14d92f558ce22d 100755 --- a/check_dns_responsetime +++ b/check_dns_responsetime @@ -13,12 +13,13 @@ # 2022-10-24 v1.2 <axel.hahn@unibe.ch> shell fixes; remove pipe char in output # 2023-07-27 v1.3 <axel.hahn@unibe.ch> shell fixes; add help page # 2023-10-13 v1.4 <axel.hahn@unibe.ch> fix syntax error in export +# 2025-02-10 v1.5 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. $( dirname $0 )/inc_pluginfunctions - -export self_APPVERSION=1.4 +export self_APPVERSION=1.5 tmpfile=/tmp/check_netstat_out_$$ infofile=/tmp/check_netstat_out_2_$$ @@ -38,7 +39,7 @@ typeset -i iNotReachable=0 # show help function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_docker_info b/check_docker_info index 11278c516c773692a452a121f0e44b9a3181301d..8f936a2a9540f61d08f2524c1f1d1f4b17ff40cd 100755 --- a/check_docker_info +++ b/check_docker_info @@ -18,13 +18,14 @@ # 2024-01-24 v1.3 <axel.hahn@unibe.ch> remove emoji icons; handle "null" in license info; show rootless or not # 2024-01-29 v1.4 <axel.hahn@unibe.ch> add --target option # 2024-02-13 v1.5 <axel.hahn@unibe.ch> update docker ps --format +# 2025-02-10 v1.6 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 +. "$( dirname "$0" )/inc_dockerfunctions.sh" || exit 1 -. $(dirname $0)/inc_pluginfunctions -. $(dirname $0)/inc_dockerfunctions.sh - -self_APPVERSION=1.5 +self_APPVERSION=1.6 # ---------------------------------------------------------------------- # FUNCTIONS @@ -33,7 +34,7 @@ self_APPVERSION=1.5 # show help function _showHelp(){ - local _self=$( basename $0 ) + local _self; _self="$( basename "$0" )" cat <<EOH $( ph.showImlHelpHeader ) diff --git a/check_docker_io b/check_docker_io index f85571dcdfc0714a740e96df01b8d8cccc34d8f1..a352515931bbeb666f057768f6ebd2156f39fd48 100755 --- a/check_docker_io +++ b/check_docker_io @@ -11,13 +11,14 @@ # # ---------------------------------------------------------------------- # 2024-02-22 v0.1 <axel.hahn@unibe.ch> init +# 2025-02-10 v0.2 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 +. "$( dirname "$0" )/inc_dockerfunctions.sh" || exit 1 -. $(dirname $0)/inc_pluginfunctions -. $(dirname $0)/inc_dockerfunctions.sh - -self_APPVERSION=0.1 +self_APPVERSION=0.2 typeset -i iRead typeset -i iTrans @@ -31,7 +32,7 @@ typeset -i iSpeedTrans # show help function _showHelp(){ - local _self=$( basename $0 ) + local _self; _self="$( basename "$0" )" cat <<EOH $( ph.showImlHelpHeader ) diff --git a/check_docker_stats b/check_docker_stats index 4ebe86cdcb005394f23139cd173ab3a1a09008d2..6e69f49dc835308712ebca349453e36a96c9e7a1 100755 --- a/check_docker_stats +++ b/check_docker_stats @@ -15,13 +15,14 @@ # ---------------------------------------------------------------------- # 2024-01-26 v1.0 <axel.hahn@unibe.ch> init # 2024-01-29 v1.1 <axel.hahn@unibe.ch> fix help; detect reason for no output +# 2025-02-10 v1.2 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 +. "$( dirname "$0" )/inc_dockerfunctions.sh" || exit 1 -. $(dirname $0)/inc_pluginfunctions -. $(dirname $0)/inc_dockerfunctions.sh - -self_APPVERSION=1.1 +self_APPVERSION=1.2 # ---------------------------------------------------------------------- # FUNCTIONS @@ -30,7 +31,7 @@ self_APPVERSION=1.1 # show help function _showHelp(){ - local _self=$( basename $0 ) + local _self; _self="$( basename "$0" )" cat <<EOH $( ph.showImlHelpHeader ) diff --git a/check_dockercontainer_info b/check_dockercontainer_info index 1ac4e1f472b09d1d1139125fb839ec3081e0e5ac..f5a8c00da57c84c271dfa6b59ae921e9145fe237 100755 --- a/check_dockercontainer_info +++ b/check_dockercontainer_info @@ -13,13 +13,14 @@ # ---------------------------------------------------------------------- # 2024-01-18 v0.1 <axel.hahn@unibe.ch> init # 2024-02-13 v1.0 <axel.hahn@unibe.ch> update docker ps --format +# 2025-02-10 v1.1 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 +. "$( dirname "$0" )/inc_dockerfunctions.sh" || exit 1 -. $(dirname $0)/inc_pluginfunctions -. $(dirname $0)/inc_dockerfunctions.sh - -self_APPVERSION=1.0 +self_APPVERSION=1.1 # ---------------------------------------------------------------------- # FUNCTIONS @@ -28,7 +29,7 @@ self_APPVERSION=1.0 # show help function _usage(){ - local _self=$( basename $0 ) + local _self; _self="$( basename "$0" )" cat <<EOH $( ph.showImlHelpHeader ) diff --git a/check_dockercontainer_top b/check_dockercontainer_top index a4a4fe39ab5c68b4fc6fc155b9822e9615617615..7a22ed53d914a45d197b246968f3e00d7c923cb3 100755 --- a/check_dockercontainer_top +++ b/check_dockercontainer_top @@ -14,13 +14,14 @@ # ---------------------------------------------------------------------- # 2024-01-26 v1.0 <axel.hahn@unibe.ch> init # 2024-01-29 v1.1 <axel.hahn@unibe.ch> fix help; +# 2025-02-10 v1.2 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 +. "$( dirname "$0" )/inc_dockerfunctions.sh" || exit 1 -. $(dirname $0)/inc_pluginfunctions -. $(dirname $0)/inc_dockerfunctions.sh - -self_APPVERSION=1.1 +self_APPVERSION=1.2 # ---------------------------------------------------------------------- # FUNCTIONS @@ -29,7 +30,7 @@ self_APPVERSION=1.1 # show help function _showHelp(){ - local _self=$( basename $0 ) + local _self; _self="$( basename "$0" )" cat <<EOH $( ph.showImlHelpHeader ) diff --git a/check_eol b/check_eol index 391a5335dab8fa24adef5be166b6a2aa67741968..9e421f07959f1fd047edaef67f54e5730167e1cb 100755 --- a/check_eol +++ b/check_eol @@ -50,12 +50,14 @@ # 2022-08-29 v1.5 <axel.hahn@iml.unibe.ch> fix help; shell syntax updates # 2023-01-30 v1.6 <axel.hahn@unibe.ch> add max value in performance data # 2023-07-27 v1.7 <axel.hahn@unibe.ch> update help page +# 2025-02-10 v1.8 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. "$( dirname $0 )/inc_pluginfunctions" -eolcfg="${0}-data/*.cfg" +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -export self_APPVERSION=1.7 +export self_APPVERSION=1.8 +eolcfg="${0}-data/*.cfg" # --- limits typeset -i iDaysWarn=365 @@ -140,7 +142,7 @@ function findEolDate(){ } function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_file_age b/check_file_age index 63cc4b41ba44f3853ed9ad6c44f38270de237804..27debf2bb1b3b70f125c876c02101bc6a08cb6eb 100755 --- a/check_file_age +++ b/check_file_age @@ -5,11 +5,13 @@ # # ---------------------------------------------------------------------- # 2024-06-21 v1.0 <martin.gasser@unibe.ch> +# 2025-02-10 v1.1 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $( dirname $0 )/inc_pluginfunctions +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -export self_APPVERSION=1.0 +export self_APPVERSION=1.1 dir_files=/var/iml-backup filter_files='*.*' @@ -32,7 +34,7 @@ typeset -i iLimitCritical=14 # show help text function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_fs_errors b/check_fs_errors index d76e67408e915bec14c640677736bd048932f714..6ae65a72935e25abe9dba62804d91dbd6f55ad21 100755 --- a/check_fs_errors +++ b/check_fs_errors @@ -12,12 +12,13 @@ # 2021-03-30 v1.1 <axel.hahn@iml.unibe.ch> max age of detected errors: since yesterday (commented) # 2023-07-27 v1.2 <axel.hahn@unibe.ch> shell fixes; update help page # 2023-10-20 v1.3 <axel.hahn@unibe.ch> harden sudo command execution +# 2025-02-10 v1.4 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. $( dirname $0 )/inc_pluginfunctions - -export self_APPVERSION=1.3 +export self_APPVERSION=1.4 # ---------------------------------------------------------------------- @@ -25,7 +26,7 @@ export self_APPVERSION=1.3 # ---------------------------------------------------------------------- function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_fs_writable b/check_fs_writable index e6c354324a46f22ca1baf815df520722e7873999..58b3bb0f463888cddd4794e240317eac7e866b14 100755 --- a/check_fs_writable +++ b/check_fs_writable @@ -8,13 +8,14 @@ # # ---------------------------------------------------------------------- # 2021-03-23 v0.0 <axel.hahn@iml.unibe.ch> -# 2023-07-27 v1.1 <axel.hahn@unibe.ch> shell fixes; update help page +# 2023-07-27 v1.1 <axel.hahn@unibe.ch> shell fixes; update help page +# 2025-02-10 v1.2 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. $( dirname $0 )/inc_pluginfunctions - -export self_APPVERSION=1.1 +export self_APPVERSION=1.2 dirs2test="/tmp /var/tmp" out="" @@ -24,7 +25,7 @@ out="" # ---------------------------------------------------------------------- function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_gitlab_tokens b/check_gitlab_tokens index b839b060881822b5eaa759a406a51e41a9ed056f..8366b19c5f4f6dbe3ab7c6593b5594a3819b62da 100755 --- a/check_gitlab_tokens +++ b/check_gitlab_tokens @@ -12,12 +12,15 @@ # 2024-10-29 v1.0 <axel.hahn@unibe.ch> # 2024-10-30 v1.1 <axel.hahn@unibe.ch> GITLAB_TOKEN=SKIP responds OK without tests # 2024-11-20 v1.2 <axel.hahn@unibe.ch> Update rest api client +# 2025-02-10 v1.3 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 + cd "$( dirname "$0" )" || exit -. "$( dirname $0 )/inc_pluginfunctions" || exit 1 -export self_APPVERSION=1.2 +export self_APPVERSION=1.3 sSkipvalue="SKIP" GITLAB_API='https://gitlab.example.com/api/v4' @@ -51,7 +54,7 @@ output="" # Show help function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_haproxy_health b/check_haproxy_health index 1be5adc3ee0a83c6f699dc44d131e0592401886a..a0d2398112f3efb0d5cc9fbd5dbec33143ea5bdb 100755 --- a/check_haproxy_health +++ b/check_haproxy_health @@ -14,15 +14,14 @@ # 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-08-23 v1.7 <axel.hahn@unibe.ch> fix wrong exitcode to "critical" +# 2025-02-10 v1.8 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $(dirname $0)/inc_pluginfunctions - -export self_APPVERSION=1.7 - -. $(dirname $0)/inc_haproxy_cfg.sh - +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 +. "$( dirname "$0" )/inc_haproxy_cfg.sh" || exit 1 +export self_APPVERSION=1.8 tmpfile=/tmp/check_haproxy_healthcheck_$$ # ---------------------------------------------------------------------- @@ -30,7 +29,7 @@ tmpfile=/tmp/check_haproxy_healthcheck_$$ # ---------------------------------------------------------------------- function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_haproxy_status b/check_haproxy_status index d3bce5a3af6b88ec291531f5c1607ee05c6cf9dd..d7c9cd638b924ee2b1af44cbd7f19111fb05463e 100755 --- a/check_haproxy_status +++ b/check_haproxy_status @@ -18,13 +18,14 @@ # 2022-04-01 v1.6 <axel.hahn@iml.unibe.ch> use wget default params; shell fixes # 2022-10-21 v1.7 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space # 2023-07-28 v1.8 <axel.hahn@unibe.ch> add help page +# 2025-02-10 v1.9 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $(dirname $0)/inc_pluginfunctions +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 +. "$( dirname "$0" )/inc_haproxy_cfg.sh" || exit 1 -export self_APPVERSION=1.8 - -. $(dirname $0)/inc_haproxy_cfg.sh +export self_APPVERSION=1.9 tmpfile=/tmp/check_haproxy_status_$$ tmpfile2=/tmp/check_haproxy_status2_$$ @@ -68,7 +69,7 @@ function checkStatus(){ # show help function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_http b/check_http index 61dc91cacae18ed661e4158c1bc44b4fe5b5fb05..47cc9d5fd0212f5178ebc50f4132f72438251067 100755 --- a/check_http +++ b/check_http @@ -8,11 +8,13 @@ # # ------------------------------------------------------------------------------- # 2023-09-06 v1.0 <axel.hahn@unibe.ch> -# ================================================================================ +# 2025-02-10 v1.1 <axel.hahn@unibe.ch> harden sourcing files +# ====================================================================== -. $( dirname $0 )/inc_pluginfunctions +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -export self_APPVERSION=1.0 +export self_APPVERSION=1.1 # ---------------------------------------------------------------------- # FUNCTIONS @@ -20,7 +22,7 @@ export self_APPVERSION=1.0 # show help text function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_iml_backup_server b/check_iml_backup_server index 9c28caf0258d7c2970e980a28490de6280f6379a..48c8ccea3fb30b142c6703839b4ace213455c28d 100755 --- a/check_iml_backup_server +++ b/check_iml_backup_server @@ -12,11 +12,13 @@ # 2023-12-21 v1.0 <axel.hahn@iml.unibe.ch> first version # 2023-12-21 v1.1 <axel.hahn@iml.unibe.ch> Update help text # 2024-03-22 v1.2 <axel.hahn@iml.unibe.ch> Update grep for backup via restic rest +# 2025-02-10 v1.3 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. $(dirname $0)/inc_pluginfunctions -export self_APPVERSION=1.2 +export self_APPVERSION=1.3 sInstalldir=/opt/imlbackup/server sScript=storage_helper.sh @@ -28,7 +30,7 @@ sMode= # show help function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_journallog b/check_journallog index 6652b6ac5913759825068bcbf665d31e29b28ec5..b73d76b3a2bfe5664f8fcafef110d982410f333f 100755 --- a/check_journallog +++ b/check_journallog @@ -10,11 +10,13 @@ # ---------------------------------------------------------------------- # 2023-10-12 v0.1 <axel.hahn@unibe.ch> initial version # 2023-10-13 v1.0 <axel.hahn@unibe.ch> update sudo command; set v1.0 +# 2025-02-10 v1.1 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $( dirname $0 )/inc_pluginfunctions +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -export self_APPVERSION=1.0 +export self_APPVERSION=1.1 tmpfile=/tmp/last_journallog_line_${USER}.txt @@ -24,7 +26,7 @@ tmpfile=/tmp/last_journallog_line_${USER}.txt # show help text function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_memory b/check_memory index 358b6854e1ecf06246f9023a02a8e19c185b4405..e075494b83227435067ba69bc3806199b16267bf 100755 --- a/check_memory +++ b/check_memory @@ -27,12 +27,13 @@ # 2023-02-13 v1.8 <axel.hahn@unibe.ch> shell fixes # 2023-07-28 v1.9 <axel.hahn@unibe.ch> update help page # 2023-09-14 v1.10 <axel.hahn@unibe.ch> fix sort: write failed: 'standard output': Broken pipe +# 2025-02-10 v1.11 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. "$(dirname $0)/inc_pluginfunctions" - -self_APPVERSION=1.10 +self_APPVERSION=1.11 # ---------------------------------------------------------------------- # FUNCTIONS @@ -47,7 +48,7 @@ function getMemvalue(){ # show help text function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) @@ -58,7 +59,8 @@ be shown. This plugin sends performancedata. SYNTAX: -$(basename $0) [-w WARN_LIMIT] [-c CRITICAL_LIMIT] [-s SWAP_LIMIT] [-p PROCESS_LIMIT] [-h] + + $_self [-w WARN_LIMIT] [-c CRITICAL_LIMIT] [-s SWAP_LIMIT] [-p PROCESS_LIMIT] [-h] OPTIONS: -w VALUE Warning level for RAM usage [%]; default: 75 @@ -75,7 +77,8 @@ PARAMETERS: none EXAMPLE: -$(basename $0) -w 90 -c 95 -p 70 + + $_self -w 90 -c 95 -p 70 EOF } diff --git a/check_mysqlserver b/check_mysqlserver index 2cc6d4cecaf173a214638eb9c46b5bb77744bd96..d33f88ea208af3bff994a76d506e7b2b3756fba3 100755 --- a/check_mysqlserver +++ b/check_mysqlserver @@ -22,11 +22,13 @@ # 2023-07-28 v1.0 <axel.hahn@unibe.ch> update help page; fix [client]: command not found # 2023-08-30 v1.1 <axel.hahn@unibe.ch> reverse return code in ph.hasParamoption to unix like return codes: 0=true; <>0 = false # 2024-12-09 v1.2 <axel.hahn@unibe.ch> fix showing help +# 2025-02-10 v1.3 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $( dirname $0 )/inc_pluginfunctions +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -export self_APPVERSION=1.2 +export self_APPVERSION=1.3 # --- set HOME HOME=/etc/icingaclient @@ -103,7 +105,7 @@ EOF # show help text function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) @@ -238,7 +240,7 @@ fi # --- check installation if ! grep $myuser $cfgfile >/dev/null 2>&1; then - ph.abort "MYSQL access not possible yet. You need to install the monitoring user first: as root execute $(basename $0) -i" + ph.abort "MYSQL access not possible yet. You need to install the monitoring user first: as root execute $(basename "$0" ) -i" fi # ---------------------------------------------------------------------- diff --git a/check_netio b/check_netio index 88fb012f808160962568c441676f39c31638d39a..37eb4f01caa7e4a4ee3b74d17ada2ecaa33cd170 100755 --- a/check_netio +++ b/check_netio @@ -13,12 +13,13 @@ # 2024-01-10 v1.5 <axel.hahn@unibe.ch> added regex filter for include and exclude # 2024-03-04 v1.6 <axel.hahn@unibe.ch> remove Kubernetes interfaces # 2024-03-26 v1.7 <axel.hahn@unibe.ch> ignore docker and veth interfaces +# 2025-02-10 v1.8 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. $( dirname $0 )/inc_pluginfunctions - -export self_APPVERSION=1.7 +export self_APPVERSION=1.8 # network data without non physical interfaces to be removed from /proc/net/dev # - lo - local @@ -35,7 +36,7 @@ nonPhysicalInterfaces="(lo|bond.*|cali.*|docker.*|flannel.*|ppp.*|veth.*):" # show help text function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_netstat b/check_netstat index 168ac8c943705079cad978e1a480fd358478eec4..45c4405eef835f59a3dde56c26670700fd1e1fc8 100755 --- a/check_netstat +++ b/check_netstat @@ -10,19 +10,20 @@ # 2020-07-08 v1.0 <axel.hahn@iml.unibe.ch> # 2022-10-25 v1.1 <axel.hahn@unibe.ch> shell fixes; no tmpfiles; IML look # 2023-08-22 v1.2 <axel.hahn@unibe.ch> update help; small shell fixes +# 2025-02-10 v1.3 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. $( dirname $0 )/inc_pluginfunctions - -export self_APPVERSION=1.2 +export self_APPVERSION=1.3 # ---------------------------------------------------------------------- # functions # ---------------------------------------------------------------------- function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_onehost b/check_onehost index aa40c9895ed029fb14cc4e41b2a842895c703a5f..ba795fc0978e9a2bf99e69284edc1df224b487bd 100755 --- a/check_onehost +++ b/check_onehost @@ -12,19 +12,20 @@ # 2023-08-23 v1.2 <axel.hahn@unibe.ch> update help; show help without requirements # 2023-09-15 v1.3 <axel.hahn@unibe.ch> add detection for disabled hosts; update texts # 2023-10-20 v1.4 <axel.hahn@unibe.ch> harden sudo command execution +# 2025-02-10 v1.5 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. $(dirname $0)/inc_pluginfunctions - -self_APPVERSION=1.4 +self_APPVERSION=1.5 # ---------------------------------------------------------------------- # functions # ---------------------------------------------------------------------- function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_onevm b/check_onevm index deae829c76205b0a72946ffdf4ee3f49894d5f8c..8cafccfcc0710e501d0f7352d3e658b2a66daeb3 100755 --- a/check_onevm +++ b/check_onevm @@ -40,12 +40,13 @@ # 2023-08-23 v1.2 <axel.hahn@unibe.ch> update help; show help without requirements # 2023-10-20 v1.3 <axel.hahn@unibe.ch> harden sudo command execution # 2024-10-04 v1.4 <axel.hahn@unibe.ch> added bak, rest, drsz; backup won't result in warning +# 2025-02-10 v1.5 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. $(dirname $0)/inc_pluginfunctions - -self_APPVERSION=1.4 +self_APPVERSION=1.5 # new line NL=" @@ -58,7 +59,7 @@ showData=0 # ---------------------------------------------------------------------- function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_opencpu b/check_opencpu index 253daa76f9864f7a038468d7b2b8bc37d7bfb2d1..d36fb32c61bf3e99baf1cf4a8c05d185d1bc30f8 100755 --- a/check_opencpu +++ b/check_opencpu @@ -21,11 +21,13 @@ # 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 +# 2025-02-10 v1.5 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. $(dirname $0)/inc_pluginfunctions -self_APPVERSION=1.4 +self_APPVERSION=1.5 tmpOk=/tmp/check_opencpu-ok tmpErr=/tmp/check_opencpu-error @@ -44,7 +46,7 @@ paramsWget="-T 5 -t 1 --no-check-certificate" # show help text function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_packages2install b/check_packages2install index 9d6c2cc6cc5f0c6575d42069fb95752fa7628f6d..3c8551d11c7b2d837637b96bcba77efb95f1d9c8 100755 --- a/check_packages2install +++ b/check_packages2install @@ -26,11 +26,13 @@ # 2022-10-21 v1.11 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space # 2023-08-24 v1.12 <axel.hahn@unibe.ch> update help; rename to getSecurityCount # 2023-10-20 v1.13 ah harden sudo command execution +# 2025-02-10 v1.14 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. $(dirname $0)/inc_pluginfunctions -self_APPVERSION=1.13 +self_APPVERSION=1.14 readonly iWarnDefault=1 readonly iCriticalDefault=200 @@ -39,8 +41,8 @@ typeset -i iCount=0 cronfile=/etc/cron.d/system-updater MYhost="localhost" -dir_pkg="$( dirname $0 )/check_packages2install-pkgmanager" -dir_filter="$( dirname $0 )/check_packages2install-data" +dir_pkg="$( dirname "$0" )/check_packages2install-pkgmanager" +dir_filter="$( dirname "$0" )/check_packages2install-data" # ---------------------------------------------------------------------- # functions @@ -82,8 +84,7 @@ function _functionExists(){ # show help function showHelp(){ - local _self - _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_php-fpm-status b/check_php-fpm-status index 37ca114f16db4da8ef8ddc4640917a9ab9eae0c8..0903d17f3281692bc40f6b28591916d7f71211bc 100755 --- a/check_php-fpm-status +++ b/check_php-fpm-status @@ -15,11 +15,13 @@ # 2022-07-08 v0.8 <axel.hahn@iml.unibe.ch> eliminate division by 0 # 2022-10-21 v1.0 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space # 2023-08-24 v1.1 <axel.hahn@unibe.ch> update help; do not use tmp file anymore +# 2025-02-10 v1.2 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $( dirname $0 )/inc_pluginfunctions +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -export self_APPVERSION=1.1 +export self_APPVERSION=1.2 outFpmStatus= defaulturl=localhost/status @@ -69,7 +71,7 @@ function _getvalue(){ function showHelp(){ - local _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_proc_mem b/check_proc_mem index cc73aebd101eff5ce1819846b35dfedaf5771854..4e11749e188f3284d9de111fd4a88e61884f6235 100755 --- a/check_proc_mem +++ b/check_proc_mem @@ -14,11 +14,13 @@ # 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-12-22 v1.3 <axel.hahn@unibe.ch> add help; do not use tmp file anymore; 5..10 times faster +# 2025-02-10 v1.4 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $( dirname $0 )/inc_pluginfunctions +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -export self_APPVERSION=1.3 +export self_APPVERSION=1.4 typeset -i iSizeMB @@ -35,7 +37,7 @@ typeset -i iCountCritical=0 # show help text function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_proc_ressources b/check_proc_ressources index ba3e48122c6a8bcc59b7c3fa340f7b40ecce509c..bf431c37aa932d05da02d8dbe8b05cd0989a43ea 100755 --- a/check_proc_ressources +++ b/check_proc_ressources @@ -16,11 +16,13 @@ # 2020-03-05 v1.1 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions # 2020-06-06 v1.2 <axel.hahn@iml.unibe.ch> for cpu: limits are multiplicated with count of cpu # 2023-12-22 v1.3 <axel.hahn@unibe.ch> update help; no temp files +# 2025-02-10 v1.4 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $( dirname $0 )/inc_pluginfunctions +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -export self_APPVERSION=1.3 +export self_APPVERSION=1.4 # --- limits iWarnLimitCpu=70 diff --git a/check_proc_zombie b/check_proc_zombie index ec342685954b9aea5a6dd9d70d52353db2ff4062..ec82c1f4cc1a9a2484e3d624fcb2ee73a6bd1c33 100755 --- a/check_proc_zombie +++ b/check_proc_zombie @@ -8,14 +8,16 @@ # # ---------------------------------------------------------------------- # 2020-03-10 v1.0 <axel.hahn@iml.unibe.ch> -# 2020-07-08 v1.1 <axel.hahn@iml.unibe.ch> FIX: set "ph." instead "ps." -# 2024-06-07 v1.2 <axel.hahn@unibe.ch> update help and add docs link +# 2020-07-08 v1.1 <axel.hahn@iml.unibe.ch> FIX: set "ph." instead "ps." +# 2024-06-07 v1.2 <axel.hahn@unibe.ch> update help and add docs link +# 2025-02-10 v1.3 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. `dirname $0`/inc_pluginfunctions -tmpfile=/tmp/check_proc_zombie_$$ +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -export self_APPVERSION=1.2 +export self_APPVERSION=1.3 +tmpfile=/tmp/check_proc_zombie_$$ # show help function showHelp(){ diff --git a/check_psqlserver b/check_psqlserver index 47c0e7f03ce2fd43b5f26d63936d6de3030b6939..f44d163f42e9beb04b494e0144b29142de9fa470 100755 --- a/check_psqlserver +++ b/check_psqlserver @@ -22,12 +22,13 @@ # 2023-08-30 v0.8 <axel.hahn@unibe.ch> reverse return code in ph.hasParamoption to unix like return codes: 0=true; <>0 = false # 2023-09-18 v0.9 <axel.hahn@unibe.ch> prevent broken pipe message in journallog # 2025-02-11 v1.0 <axel.hahn@unibe.ch> add default banner for IML checks +# 2025-02-10 v1.1 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. $(dirname $0)/inc_pluginfunctions -self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] ) -self_APPVERSION=0.9 +self_APPVERSION=1.1 # --- other vars... cfgfile=/etc/icingaclient/.psql.conf @@ -48,7 +49,7 @@ function _queryFailed(){ ph.setStatus "unknown" echo "UNKNOWN: the database query failed" echo "Quick troubleshooter:" - echo "* install a database user $myuser with command $(basename $0) -i" + echo "* install a database user $myuser with command $( basename "$0" ) -i" echo "* check pg_hba.conf login fails if it set to ident (eg. change it to md5)" ph.exit } @@ -110,7 +111,7 @@ EOF # show help function _usage(){ - local _self=$( basename $0 ) + local _self; _self="$( basename "$0" )" cat <<EOH $( ph.showImlHelpHeader ) @@ -212,7 +213,7 @@ fi # --- check installation if ! grep $myuser $cfgfile >/dev/null 2>&1; then - ph.abort "PSQL access not possible yet. You need to install the monitoring user first: as root execute `basename $0` -i" + ph.abort "PSQL access not possible yet. You need to install the monitoring user first: as root execute $( basename "$0" ) -i" fi . "${cfgfile}" diff --git a/check_rearbackup b/check_rearbackup index 9b85ba3a7371efbd4cb418054d608bc4d0f4c89d..49c9b39268076fd876aa6649bdeca64c5fa5ce3e 100755 --- a/check_rearbackup +++ b/check_rearbackup @@ -5,11 +5,13 @@ # # ---------------------------------------------------------------------- # 2023-12-22 v1.0 <axel.hahn@unibe.ch> +# 2025-02-10 v1.1 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $( dirname $0 )/inc_pluginfunctions +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -export self_APPVERSION=1.0 +export self_APPVERSION=1.1 dir_reardata=/rearshare/rear-backup @@ -31,7 +33,7 @@ typeset -i iLimitCritical=14 # show help text function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_reboot_required b/check_reboot_required index 4fad65100c71325d00e712f567b2b45eb38ca20c..3d0bf07ea450b2c6e8c30e6e0b76bb937b0489d1 100755 --- a/check_reboot_required +++ b/check_reboot_required @@ -10,20 +10,19 @@ # - ubuntu10+ # ---------------------------------------------------------------------- # 2016-08-12 added ouput of packages -# 2020-03-05 v1.2 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions -# 2022-10-14 v1.3 <axel.hahn@unibe.ch> fix debian output if /var/run/reboot-required.pkgs does not exist -# Shellfixes; add help -# 2023-03-29 v1.4 <martin.gasser@unibe.ch> add almalinux as distro -# 2024-03-07 v1.4 <martin.gasser@unibe.ch> add rocky as distro -# 2025-02-11 v1.5 <axel.hahn@unibe.ch> add default banner for IML checks; add support for manjaro +# 2020-03-05 v1.2 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions +# 2022-10-14 v1.3 <axel.hahn@unibe.ch> fix debian output if /var/run/reboot-required.pkgs does not exist +# Shellfixes; add help +# 2023-03-29 v1.4 <martin.gasser@unibe.ch> add almalinux as distro +# 2024-03-07 v1.4 <martin.gasser@unibe.ch> add rocky as distro +# 2025-02-11 v1.5 <axel.hahn@unibe.ch> add default banner for IML checks; add support for manjaro +# 2025-02-10 v1.6 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. $(dirname $0)/inc_pluginfunctions - -self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] ) -self_APPVERSION=1.5 - +self_APPVERSION=1.6 distro=$( ph.getOS ) # ---------------------------------------------------------------------- @@ -31,6 +30,7 @@ distro=$( ph.getOS ) # ---------------------------------------------------------------------- function showHelp(){ + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) @@ -48,7 +48,8 @@ If your distro is based on Arch, Centos or Debian then it easily can be added in the script if it does not work. Report the distro name to the author. SYNTAX: -$(basename $0) + + $_self OPTIONS: @@ -58,9 +59,6 @@ PARAMETERS: None. -EXAMPLE: -$(basename $0) - EOF } # ---------------------------------------------------------------------- diff --git a/check_requirements b/check_requirements index ab209325aa75455213227c07345d423d9cc25ec9..2664f76458b80ce70bc68b9826b64bf320cbd63b 100755 --- a/check_requirements +++ b/check_requirements @@ -13,14 +13,15 @@ # 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 +# 2025-02-10 v1.4 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. "$( dirname $0 )/inc_pluginfunctions" +self_APPVERSION=1.4 -self_APPVERSION=1.3 - -self=$( basename $0 ) +self="$( basename "$0" )" typeset -i VERBOSE=0 diff --git a/check_smartstatus b/check_smartstatus index 43b9d03e94a2888231c3d97d68a206897db16784..cb19fa92349c283df840c25b888e3c2cac5fab87 100755 --- a/check_smartstatus +++ b/check_smartstatus @@ -32,19 +32,20 @@ # 2016-12-23 v0.3 ah,ds # 2018-12-06 v0.4 ah,ds show details for each disc # 2020-02-27 v0.5 ah,ds add /sbin to PATH variable -# 2020-03-05 v1.0 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions -# 2021-01-22 v1.1 <axel.hahn@iml.unibe.ch> add status [no access] -# 2021-04-07 v1.2 <axel.hahn@iml.unibe.ch> update message if sudo smartctl -H fails -# 2021-10-28 v1.3 <axel.hahn@iml.unibe.ch> detect -d param for smartctl -# 2022-07-08 v1.4 <axel.hahn@iml.unibe.ch> remove pipe in status line -# 2023-10-20 v1.5 <axel.hahn@unibe.ch> harden sudo command execution -# 2024-06-07 v1.6 <axel.hahn@unibe.ch> add help page; use smartctl --scan to detect devices +# 2020-03-05 v1.0 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions +# 2021-01-22 v1.1 <axel.hahn@iml.unibe.ch> add status [no access] +# 2021-04-07 v1.2 <axel.hahn@iml.unibe.ch> update message if sudo smartctl -H fails +# 2021-10-28 v1.3 <axel.hahn@iml.unibe.ch> detect -d param for smartctl +# 2022-07-08 v1.4 <axel.hahn@iml.unibe.ch> remove pipe in status line +# 2023-10-20 v1.5 <axel.hahn@unibe.ch> harden sudo command execution +# 2024-06-07 v1.6 <axel.hahn@unibe.ch> add help page; use smartctl --scan to detect devices +# 2025-02-10 v1.7 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. $(dirname $0)/inc_pluginfunctions - -self_APPVERSION=1.6 +self_APPVERSION=1.7 typeset -i iFound=0 typeset -i iErrors=0 @@ -61,14 +62,14 @@ export PATH # show help function showHelp(){ - local self=$( basename $0 ) + local _self; _self="$( basename "$0" )" cat <<EOH $( ph.showImlHelpHeader ) Show status of local S.M.A.R.T. devices. SYNTAX: - $self [-h] [-l] [devices] + $_self [-h] [-l] [devices] OPTIONS: @@ -79,10 +80,10 @@ PARAMETERS: EXAMPLES - $self + $_self Scan all local disks - $self -l + $_self -l List all local disks without scanning them. EOH diff --git a/check_snmp_data b/check_snmp_data index 212c4f002d3e2c8ac221c5d06332e032a98bd7e9..33874a211ecaaeb3fcdfd13ccf0efc140eec4cee 100755 --- a/check_snmp_data +++ b/check_snmp_data @@ -63,23 +63,22 @@ # DATA:synoio:out:data:syno-io-write:1.3.6.1.4.1.6574.102.1.1.13.1 # # ---------------------------------------------------------------------- -# 2020-08-11 <axel.hahn@iml.unibe.ch> initial version -# 2020-08-13 <axel.hahn@iml.unibe.ch> add host in label for counter data -# 2022-10-21 v0.4 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space +# 2020-08-11 <axel.hahn@iml.unibe.ch> initial version +# 2020-08-13 <axel.hahn@iml.unibe.ch> add host in label for counter data +# 2022-10-21 v0.4 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space # 2022-10-21 v0.5 <andrea.gottsponer@unibe.ch> remove grep: warning: stray \ before white space -# 2022-10-25 v0.6 <axel.hahn@unibe.ch> fix empty value in performance data; shell fixes -# 2023-05-05 v0.7 <axel.hahn@unibe.ch> source shared func, support snmpv3; add synoio -# 2023-05-16 v0.8 <axel.hahn@unibe.ch> add about for general infos and without perf data -# 2025-02-12 v1.0 <axel.hahn@unibe.ch> add IML header in help +# 2022-10-25 v0.6 <axel.hahn@unibe.ch> fix empty value in performance data; shell fixes +# 2023-05-05 v0.7 <axel.hahn@unibe.ch> source shared func, support snmpv3; add synoio +# 2023-05-16 v0.8 <axel.hahn@unibe.ch> add about for general infos and without perf data +# 2025-02-12 v1.0 <axel.hahn@unibe.ch> add IML header in help +# 2025-02-10 v1.1 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $(dirname $0)/inc_pluginfunctions -. $(dirname $0)/check_snmp_includes - -# --- basic vars -self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] ) -self_APPVERSION=1.0 +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 +. "$(dirname "$0" )/check_snmp_includes" || exit 1 +self_APPVERSION=1.1 METHOD="" # --- output variables @@ -155,8 +154,8 @@ _isinteger(){ #--------------------------------------------------- # --- show usage function showHelp(){ - _self=$( basename $0 ) - local _methods=$( + local _self; _self="$( basename "$0" )" + local _methods; methods=$( _cfg_getMethods | while read -r line do METHOD=$(echo "$line" | cut -f 2 -d ":") diff --git a/check_snmp_printer b/check_snmp_printer index 0d07fabb136fa52480080f55cb05ca0ab7e33dc8..9a178dfca087876acf847f247011bef65cfc2850 100755 --- a/check_snmp_printer +++ b/check_snmp_printer @@ -12,21 +12,18 @@ # except "-c <script>" # # ------------------------------------------------------------ -# 2021-03-22 <axel.hahn@iml.unibe.ch> v0.1 -# 2023-09-18 <axel.hahn@iml.unibe.ch> v0.2 snmpv3 support -# 2023-10-12 <axel.hahn@iml.unibe.ch> v0.3 parameter for custom script; detect debian -# 2025-02-12 <axel.hahn@unibe.ch> v1.0 add help and debug param -# ============================================================ - -# ------------------------------------------------------------ -# CONFIG -# ------------------------------------------------------------ +# 2021-03-22 v0.1 <axel.hahn@iml.unibe.ch> +# 2023-09-18 v0.2 <axel.hahn@iml.unibe.ch> snmpv3 support +# 2023-10-12 v0.3 <axel.hahn@iml.unibe.ch> parameter for custom script; detect debian +# 2025-02-12 v1.0 <axel.hahn@unibe.ch> add help and debug param +# 2025-02-10 v1.1 <axel.hahn@unibe.ch> harden sourcing files +# ====================================================================== -. $( dirname $0 )/inc_pluginfunctions -. $( dirname $0 )/check_snmp_includes +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 +. "$( dirname "$0" )/check_snmp_includes" || exit 1 -self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] ) -self_APPVERSION=1.0 +self_APPVERSION=1.1 debug=0 @@ -43,7 +40,7 @@ esac #--------------------------------------------------- # --- show usage function showHelp(){ - _self=$( basename $0 ) + local _self; _self="$( basename "$0" )" cat <<EOH $( ph.showImlHelpHeader ) diff --git a/check_snmp_synology b/check_snmp_synology index 8d2c01e2674cab43d7c16ae0309c63421a6c64ed..f5d92d474b279a0e42f243206368914e0b85302e 100755 --- a/check_snmp_synology +++ b/check_snmp_synology @@ -1,11 +1,5 @@ #!/bin/bash -# check_snmp_synology for nagios version 1.2 -# 30.04.2013 Nicolas Ordonez, Switzerland -# 08.08.2020 Axel Hahn: add update, community string -# 03.05.2023 v1.2 Axel Hahn: support Snmpv3 connections -# 09.05.2023 v1.3 Axel Hahn: allow complete check or single check(s) -# 12.05.2023 v1.4 Axel Hahn: no raid size check (DSM 5.x) -# 12.02.2025 v1.5 Axel Hahn: update header in help with link to online help +# check_snmp_synology for nagios # ---------------------------------------------------------------------- # this plugin check the health of your Synology NAS # - System status (Power, Fans) @@ -18,14 +12,20 @@ # see docs: # https://global.download.synology.com/download/Document/Software/DeveloperGuide/Firmware/DSM/All/enu/Synology_DiskStation_MIB_Guide.pdf # ---------------------------------------------------------------------- +# 30.04.2013 Nicolas Ordonez, Switzerland +# 08.08.2020 Axel Hahn: add update, community string +# 03.05.2023 v1.2 Axel Hahn: support Snmpv3 connections +# 09.05.2023 v1.3 Axel Hahn: allow complete check or single check(s) +# 12.05.2023 v1.4 Axel Hahn: no raid size check (DSM 5.x) +# 12.02.2025 v1.5 <axel.hahn@unibe.ch> update header in help with link to online help +# 2025-02-10 v1.6 <axel.hahn@unibe.ch> harden sourcing files +# ====================================================================== -. $(dirname $0)/inc_pluginfunctions -. $(dirname $0)/check_snmp_includes - -# --- basic vars +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 +. "$( dirname "$0" )/check_snmp_includes" || exit 1 -self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] ) -self_APPVERSION=1.5 +self_APPVERSION=1.6 SNMPOUTPUT= option_found=0 @@ -72,7 +72,7 @@ FLAG_DISK=1 FLAG_UPDATE=1 FLAG_TEMPERATURE=1 -_self=$( basename $0 ) +_self="$( basename "$0" )" USAGE="$( ph.showImlHelpHeader ) Check health of a Synology drive using SNMP. diff --git a/check_ssl b/check_ssl index 566d5e6eb7393e33d6b1c9f664a7feea2e002ed4..b408c366aa965840458f18a8613764c20f90b66e 100755 --- a/check_ssl +++ b/check_ssl @@ -19,13 +19,13 @@ # 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" # 2025-02-12 v1.4 <axel.hahn@unibe.ch> add IML header in help; add warning and critical level +# 2025-02-10 v1.5 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. $(dirname $0)/inc_pluginfunctions - -self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] ) -self_APPVERSION=1.4 +self_APPVERSION=1.5 sDomain= iPort=443 @@ -41,7 +41,7 @@ sStatus= # show help with syntax function showHelp(){ - _self=$( basename $0 ) + local _self; _self="$( basename "$0" )" cat <<EOH $( ph.showImlHelpHeader ) diff --git a/check_ssl_certs b/check_ssl_certs index 9604ceb8713bf56afbaaceb343d96bbdc1f6a3a1..a10f0802ea32283d558b8ab453ac5c9e53ee9c96 100755 --- a/check_ssl_certs +++ b/check_ssl_certs @@ -14,10 +14,13 @@ # 2022-03-16 v0.2 <axel.hahn@iml.unibe.ch> shell fixes; shorten perfdata label # 2022-10-21 v1.3 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space # 2024-04-24 v1.4 <axel.hahn@unibe.ch> update for newer openssl version; update help +# 2025-02-10 v1.5 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $(dirname $0)/inc_pluginfunctions -self_APPVERSION=1.4 +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 + +self_APPVERSION=1.5 typeset -i iWarn=14 typeset -i iCrit=5 @@ -40,7 +43,7 @@ myDomain=".iml.unibe.ch" # show help text function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) @@ -48,7 +51,8 @@ Check locally installed SSL client certificates and warn if the expiration date comes closer. SYNTAX: -$(basename $0) [-w WARN_LIMIT] [-c CRITICAL_LIMIT] [-f "FILELIST"] + + $_self [-w WARN_LIMIT] [-c CRITICAL_LIMIT] [-f "FILELIST"] OPTIONS: @@ -67,11 +71,11 @@ PARAMETERS: EXAMPLE: - $(basename $0) -f "/etc/ssl/certs/*example.com.*.cer /somewhere/else/*.cer" + $_self -f "/etc/ssl/certs/*example.com.*.cer /somewhere/else/*.cer" Set 2 folders where to find the client certificates. They are seperated by space and both use * for globbing - $(basename $0) -w 30 -c 3 + $_self -w 30 -c 3 Overide the warning and critical level. EOF diff --git a/check_systemdservices b/check_systemdservices index 565449976da9f2de28ccf7df2e77d2c2262a1e40..4a7deed57c3666ed1218ad89f0388f83ba4179f1 100755 --- a/check_systemdservices +++ b/check_systemdservices @@ -20,17 +20,21 @@ # 2020-04-02 v1.2 <axel.hahn@iml.unibe.ch> added ph.execIfReady in _init # 2021-10-21 v1.3 <axel.hahn@iml.unibe.ch> remove starting spaces in systemctl output # 2022-04-14 v1.4 <axel.hahn@iml.unibe.ch> remove any special chars at beginning of line -# ================================================================================ +# 2025-02-10 v1.5 <axel.hahn@unibe.ch> harden sourcing files +# ====================================================================== + +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. `dirname $0`/inc_pluginfunctions +self_APPVERSION=1.5 cfgfile="$0.cfg" ignorefile="$0.ignore" -tmpServices=/tmp/`basename $0`-services.txt -tmpErrors=/tmp/`basename $0`-errors.txt -tmpOut=/tmp/`basename $0`-out.txt -tmpOutOther=/tmp/`basename $0`-out-other.txt +tmpServices="/tmp/$( basename "$0" )-services.txt" +tmpErrors=/tmp/$( basename "$0" )-errors.txt +tmpOut=/tmp/$( basename "$0" )-out.txt +tmpOutOther=/tmp/$( basename "$0" )-out-other.txt typeset -i iErrors=0 typeset -i iOk=0 diff --git a/check_systemdunit b/check_systemdunit index 54360894babf1759fcbdeecedfbdb896beb1f875..9dd9971f64c1cbe7ce9fc10d0c8f72f5200383be 100755 --- a/check_systemdunit +++ b/check_systemdunit @@ -12,11 +12,13 @@ # 2020-10-20 v1.5 <axel.hahn@unibe.ch> remove special chars from systemd status # 2020-10-23 v1.6 <axel.hahn@unibe.ch> handle units with multiple instrances # 2020-11-03 v1.7 <axel.hahn@unibe.ch> autodetect multiple instances without @ char in unit name -# ================================================================================ +# 2025-02-10 v1.8 <axel.hahn@unibe.ch> harden sourcing files +# ====================================================================== -. $( dirname $0 )/inc_pluginfunctions +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -export self_APPVERSION=1.7 +export self_APPVERSION=1.8 # ---------------------------------------------------------------------- # FUNCTIONS @@ -24,7 +26,7 @@ export self_APPVERSION=1.7 # show help text function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_timesync b/check_timesync index 91df8e0daddc4b9b1992caf807a0f3699ac48c2e..4a2ffe7086266df37b396b84e218514de3290140 100755 --- a/check_timesync +++ b/check_timesync @@ -12,14 +12,17 @@ # - ubuntu16 # ---------------------------------------------------------------------- # 2018-10-26 v1.0 <axel.hahn@iml.unibe.ch> -# 2020-03-05 v1.1 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions -# 2020-05-13 v1.2 <axel.hahn@iml.unibe.ch> update pre detect output of timedatectl +# 2020-03-05 v1.1 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions +# 2020-05-13 v1.2 <axel.hahn@iml.unibe.ch> update pre detect output of timedatectl # 2021-08-19 v1.3 <martin.gasser@iml.unibe.ch> update for chrony with timedatectl -# 2025-02-19 v1.4 <axel.hahn@unibe.ch> update help page +# 2025-02-19 v1.4 <axel.hahn@unibe.ch> update help page +# 2025-02-10 v1.5 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== -. $(dirname $0)/inc_pluginfunctions -self_APPVERSION=1.4 +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 + +self_APPVERSION=1.5 myos="$( ph.getOS )" tmpfile=/tmp/check_timesync.tmp @@ -30,7 +33,7 @@ tmpfile=/tmp/check_timesync.tmp # show help text function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/check_uptime b/check_uptime index d160254fcab1d6fbc0c8f94ba3582bfa5cdbefe7..4a7d851ff639f909be9ec56c662911ec98bbdfbf 100755 --- a/check_uptime +++ b/check_uptime @@ -20,11 +20,13 @@ # 2020-07-02 v1.3 <axel.hahn@iml.unibe.ch> use sec for performance data # 2022-10-21 v1.4 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space # 2025-02-19 v1.5 <axel.hahn@unibe.ch> add help: remove IML specific check for auto updates; add idletime +# 2025-02-10 v1.6 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 -. "$( dirname "$0" )/inc_pluginfunctions" -self_APPVERSION=1.5 +self_APPVERSION=1.6 # ---------------------------------------------------------------------- @@ -33,7 +35,7 @@ self_APPVERSION=1.5 # show help text function showHelp(){ - local _self; _self=$(basename $0) + local _self; _self="$( basename "$0" )" cat <<EOF $( ph.showImlHelpHeader ) diff --git a/docs/20_Checks/_index.md b/docs/20_Checks/_index.md index e1ba906545ef520a60777c983a4c27653d0151b7..386c02268384d3672af651048f53aa02d0e4978c 100644 --- a/docs/20_Checks/_index.md +++ b/docs/20_Checks/_index.md @@ -53,4 +53,4 @@ * [check_systemdunit](check_systemdunit.md) * [check_timesync](check_timesync.md) * [check_uptime](check_uptime.md) -* hello +* [hello](hello.md) diff --git a/docs/20_Checks/hello.md b/docs/20_Checks/hello.md new file mode 100644 index 0000000000000000000000000000000000000000..5a577716999878acb409e1b24a079e509101c368 --- /dev/null +++ b/docs/20_Checks/hello.md @@ -0,0 +1,63 @@ +## Hello + +Script: `hello` + +It prints a hello message to signal that a non reachable host is alive. +Use it for passive checks in private networks that can't be reached from an Icinga sattelite. + +## Requirements + +Nothing special. + +## Standalone installation + +From this repository ypu need next to this script: + +* `inc_pluginfunctions` shared function for all IML checks written in bash + +## Syntax + +Start the script with `-h` or `--help` to get the help. + +```txt +______________________________________________________________________ + +HELLO +v1.1 + +(c) Institute for Medical Education - University of Bern +Licence: GNU GPL 3 + +https://os-docs.iml.unibe.ch/icinga-checks/Checks/hello.html +______________________________________________________________________ + +Print a hello message to signal that a non reachable host is alive. +Use it for passive checks in private networks that can't be reached from an +Icinga sattelite. + +SYNTAX: + + hello [-h] + +OPTIONS: + + -h or --help show this help. + +PARAMETERS: + + None. + +``` + +## Examples + +No parameter is needed. + +`./hello` + +returns + +```txt +OK: Here I am! +Thu Feb 20 09:11:55 CET 2025 + ``` diff --git a/docs/30_Shared_functions/inc_pluginfunctions.md b/docs/30_Shared_functions/inc_pluginfunctions.md index d504796110f85817ee4d9d2455e1231b8797cc54..7ccfc500bf7aee5d1556716f1c5e6408d90ccf6f 100644 --- a/docs/30_Shared_functions/inc_pluginfunctions.md +++ b/docs/30_Shared_functions/inc_pluginfunctions.md @@ -3,7 +3,7 @@ All scripts start with sourcing a shared bash file ```shell -. $( dirname $0 )/inc_pluginfunctions +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 ``` In that script are several functions starting with prefix **ph.** (=plugin helper) diff --git a/hello b/hello index bb265daee0787620bea7062eb7e9639296294062..78a5efb576b79ac4c7f75e11f48bff3140f619ea 100755 --- a/hello +++ b/hello @@ -9,10 +9,51 @@ # # ---------------------------------------------------------------------- # 2021-06-04 v1.0 <axel.hahn@iml.unibe.ch> hello :-) +# 2025-02-20 v1.1 <axel.hahn@unibe.ch> add help # ====================================================================== -. `dirname $0`/inc_pluginfunctions +. "$( dirname "$0" )/inc_pluginfunctions" +self_APPVERSION=1.1 + + +# show help text +function showHelp(){ + local _self; _self="$( basename "$0" )" +cat <<EOF +$( ph.showImlHelpHeader ) + +Print a hello message to signal that a non reachable host is alive. +Use it for passive checks in private networks that can't be reached from an +Icinga sattelite. + +SYNTAX: + + $_self [-h] + +OPTIONS: + + -h or --help show this help. + +PARAMETERS: + + None. + +EOF +} + + +if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then + showHelp + exit 0; +fi + +if [ -n "$*" ]; then + echo "ERROR: no parameter expected." + exit 1 +fi + ph.status "Here I am!" +date ph.exit # ---------------------------------------------------------------------- diff --git a/inc_dockerfunctions.sh b/inc_dockerfunctions.sh index e34e4251638290a06201a834cd8b1f26bef36cb9..a131e310a4c1555f1173070977e32530039376e0 100644 --- a/inc_dockerfunctions.sh +++ b/inc_dockerfunctions.sh @@ -13,10 +13,11 @@ # ---------------------------------------------------------------------- # 2024-01-19 v1.0 <axel.hahn@unibe.ch> init # 2024-01-29 v1.1 <axel.hahn@unibe.ch> _detectDockererror +# 2025-02-10 v1.2 <axel.hahn@unibe.ch> harden sourcing files # ====================================================================== - -. $(dirname $0)/inc_pluginfunctions +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 _is_docker_rootless=0 _is_docker_detected=0 diff --git a/inc_pluginfunctions b/inc_pluginfunctions index bd102868d63e60471980f9a045f5292a1166e6b8..528fc7c67d430e10eee1d5cfe5ace6e3f533419d 100644 --- a/inc_pluginfunctions +++ b/inc_pluginfunctions @@ -373,7 +373,7 @@ function ph._getStorefile(){ local mydir="/tmp/icinga_counter_${USER}" test -n "$dir_data" && mydir="${dir_data}/_counter_${USER}" local _basename - _basename=$(basename $0) + _basename="$( basename "$0" )" test -d "${mydir}" || mkdir -p "${mydir}" echo "${mydir}/${_basename}${varName}.lastvalue" @@ -417,7 +417,7 @@ function ph._readlastvalue(){ # it creates a filename based on the started check script function ph._perfinit(){ local _basename - _basename=$(basename $0) + _basename="$( basename "$0" )" ph_perfdatafile="/tmp/perfdata_$(echo $_basename | sed "s#[^a-z0-9\-]#_#g")" rm -f "${ph_perfdatafile}" 2>/dev/null } @@ -578,12 +578,12 @@ function ph.execIfReady(){ # including a link to the online help ph.showImlHelpHeader(){ local _html; - _html=$(basename $0) + _html="$( basename "$0" )" _html=${_html//\-/_}.html cat <<EOF ______________________________________________________________________ -$( basename $0 | tr [:lower:] [:upper:] ) +$( basename "$0" | tr [:lower:] [:upper:] ) v$self_APPVERSION (c) Institute for Medical Education - University of Bern diff --git a/zz_template_check_xyz b/zz_template_check_xyz index 8419392e84bb5319d97d0782c4984dde90fc0402..d1a665913fbbecd4384fd9b2b8c48693fa002fd9 100644 --- a/zz_template_check_xyz +++ b/zz_template_check_xyz @@ -7,29 +7,30 @@ # 202n-nn-nn v0.0 <name@unibe.ch> initial version # ====================================================================== +# shellcheck source=/dev/null +. "$( dirname "$0" )/inc_pluginfunctions" || exit 1 + + +self_APPVERSION=0.0 -. `dirname $0`/inc_pluginfunctions # ---------------------------------------------------------------------- # functions # ---------------------------------------------------------------------- +# show help text function showHelp(){ + local _self; _self="$( basename "$0" )" cat <<EOF -______________________________________________________________________ - -CHECK_XYZ !!! add a short description - -(c) Institute for Medical Education - University of Bern -Licence: GNU GPL 3 -______________________________________________________________________ +$( ph.showImlHelpHeader ) !!! Add some information what the check does. !!! add / remove params in syntax, options and example SYNTAX: -`basename $0` [-w WARN_LIMIT] [-c CRITICAL_LIMIT] + + $_self [-h] OPTIONS: @@ -40,13 +41,15 @@ OPTIONS: PARAMETERS: - None. + None. EXAMPLE: -`basename $0` -w 60 -c 80 + + $_self -w 60 -c 80 EOF } + # ---------------------------------------------------------------------- # MAIN # ----------------------------------------------------------------------