diff --git a/check_file_age b/check_file_age index 6fadc6ca4a820bfeb302a214b01f0eaa4a44ebb1..63cc4b41ba44f3853ed9ad6c44f38270de237804 100755 --- a/check_file_age +++ b/check_file_age @@ -62,10 +62,10 @@ PARAMETERS: -c, --critical VALUE critical level in days (default: $iLimitCritical) - -w. --warning VALUE + -w, --warning VALUE warning level in days (default: $iLimitWarning) - -f --filter FILTER + -f, --filter FILTER filter for filenames (default: ${filter_files} EXAMPLE: diff --git a/check_psqlserver b/check_psqlserver index 4e1afb465ba9a035e05a020f9bdf8527594675d3..47c0e7f03ce2fd43b5f26d63936d6de3030b6939 100755 --- a/check_psqlserver +++ b/check_psqlserver @@ -21,6 +21,7 @@ # 2023-06-16 v0.7 <axel.hahn@unibe.ch> update help text # 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 # ====================================================================== @@ -111,13 +112,7 @@ EOF function _usage(){ local _self=$( basename $0 ) cat <<EOH -______________________________________________________________________ - -${self_APPNAME} :: v${self_APPVERSION} - -(c) Institute for Medical Education - University of Bern -Licence: GNU GPL 3 -______________________________________________________________________ +$( ph.showImlHelpHeader ) USAGE: $_self [OPTIONS] -m METHOD diff --git a/check_reboot_required b/check_reboot_required index 423ea64938ec170d282bc5561f6b4df93abf098f..4fad65100c71325d00e712f567b2b45eb38ca20c 100755 --- a/check_reboot_required +++ b/check_reboot_required @@ -5,23 +5,24 @@ # # ---------------------------------------------------------------------- # works for sure on -# - centos7,8 -# - debian6..10 -# - ubuntu10,12 +# - centos7+ +# - debian6+ +# - 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-7 v1.4 <martin.gasser@unibe.ch> add rocky 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 # ====================================================================== . $(dirname $0)/inc_pluginfunctions self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] ) -self_APPVERSION=1.3 +self_APPVERSION=1.5 distro=$( ph.getOS ) @@ -31,21 +32,20 @@ distro=$( ph.getOS ) function showHelp(){ cat <<EOF -______________________________________________________________________ - -$self_APPNAME -v$self_APPVERSION - -(c) Institute for Medical Education - University of Bern -Licence: GNU GPL 3 -______________________________________________________________________ +$( ph.showImlHelpHeader ) Check if a reboot is required. -It works for Centos and Debian/ Ubuntu. +It works for Centos and Debian/ Ubuntu and Manjaro If the reboot is required: + * On Centos it shows the kernel number that will be installed, * On Debian/ Ubuntu it shows the packages that require the reboot, +* On Manjaro it shows if a newer kernel or which libs require the reboot. + The check for libs uses lsof. + +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) @@ -99,8 +99,40 @@ case $distro in fi ;; + # + "manjaro") + kernel_current="$( uname -r | sed 's/-[a-z]*$//i' )" + kernel_installed="$( pacman -Q linux | cut -f 2 -d " " )" + + sReason="" + if [ "$kernel_current" != "$kernel_installed" ]; then + sReason+="Kernel $kernel_installed was installed ... " + fi + + libs="" + if which lsof > /dev/null; then + libs=$(lsof -n +c 0 2> /dev/null | grep 'DEL.*lib' | awk '1 { print $1 ": " $NF }' | sort -u) + if [[ -n $libs ]]; then + sReason+="Libs reqire a reboot ... " + fi + fi + + if [ -n "$sReason" ]; then + ph.setStatus "warning" + ph.status "[$distro] $sReason" + cat <<< $libs + else + ph.status "[$distro] No reboot required." + if ! which lsof > /dev/null; then + echo "Remark: Install lsof to search for libs that require a reboot." + fi + fi + ;; + *) - ph.abort "UNKNOWN: distro [$distro] was detected but is not supported (yet)." + ph.setStatus "unknown" + ph.status "distro [$distro] was detected but is not supported (yet)." + echo "If your distro is based on Arch, Centos or Debian then it easily can be added in the script. Report the distro name to the author." ;; esac diff --git a/docs/20_Checks/check_file_age.md b/docs/20_Checks/check_file_age.md new file mode 100644 index 0000000000000000000000000000000000000000..2bb9986aa902605b6b62fce6d34142275052f6d8 --- /dev/null +++ b/docs/20_Checks/check_file_age.md @@ -0,0 +1,85 @@ +## Check filesystem errors + +Script: `check_file_age` + +**check_file_age** checks if files are not out of date. +You can find non finisheing processes that do not write an output file or logfile anymore. + +This check sends performance data. + +## Requirements + +* sudo permission on /bin/journalctl to scan for the information + +```txt +icingaclient ALL=(ALL) NOPASSWD: /bin/journalctl +``` + +## Standalone installation + +From this repository ypu need next to this script: + +* `inc_pluginfunctions` shared function for all IML checks written in bash + +## Syntax + +```txt +______________________________________________________________________ + +CHECK_FILE_AGE +v1.0 + +(c) Institute for Medical Education - University of Bern +Licence: GNU GPL 3 + +https://os-docs.iml.unibe.ch/icinga-checks/Checks/check_file_age.html +______________________________________________________________________ + +Check if files are not out of date. +You can customize the values for +* directory +* limits for warning and critical +* filename filter pattern + +This plugin sends performancedata. + +SYNTAX: + + check_file_age [-h] [--dir PATH] [--filter FILTER] [--critical VALUE] [--warning VALUE] + +OPTIONS: + + -h, --help + this help + +PARAMETERS: + + -d, --dir PATH + set installation dir of iml deployment to find its check skript + default dir: /var/iml-backup + + -c, --critical VALUE + critical level in days (default: 14) + + -w. --warning VALUE + warning level in days (default: 7) + + -f --filter FILTER + filter for filenames (default: *.* + +EXAMPLE: + + check_file_age + Check backup data with initial values + + check_file_age -d /data/mybackups + Check iso files a given directory + + check_file_age -d /data/mybackups -w 14 -c 28 + Check iso files a given directory and customized limits + +``` + +### Parameters + +(none) diff --git a/docs/20_Checks/check_reboot_required.md b/docs/20_Checks/check_reboot_required.md index 56406b4855bb9f0bd830f7701d369ccdd9045de9..7e7b6aa1fadfc901f7507518a81266519acdb3bc 100644 --- a/docs/20_Checks/check_reboot_required.md +++ b/docs/20_Checks/check_reboot_required.md @@ -20,16 +20,45 @@ From this repository ypu need next to this script: `$ check_reboot_required [-h]` -### Parameters +```txt +______________________________________________________________________ + +CHECK_REBOOT_REQUIRED +v1.5 + +(c) Institute for Medical Education - University of Bern +Licence: GNU GPL 3 + +https://os-docs.iml.unibe.ch/icinga-checks/Checks/check_reboot_required.html +______________________________________________________________________ + +Check if a reboot is required. +It works for Centos and Debian/ Ubuntu and Manjaro + +If the reboot is required: + +* On Centos it shows the kernel number that will be installed, +* On Debian/ Ubuntu it shows the packages that require the reboot, +* On Manjaro it shows if a newer kernel or which libs require the reboot. + The check for libs uses lsof. + +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: +check_reboot_required -```text OPTIONS: -h or --help show this help. PARAMETERS: - None + None. + +EXAMPLE: +check_reboot_required + ``` ## Examples @@ -54,5 +83,6 @@ WARNING: [centos] need to reboot for kernel package kernel is not installed (c ```txt ./check_reboot_required -UNKNOWN: distro [manjaro] was detected but is not supported (yet). +UNKNOWN: distro [otherlinux] was detected but is not supported (yet). +If your distro is based on Arch, Centos or Debian then it easily can be added in the script. Report the distro name to the author. ``` diff --git a/inc_pluginfunctions b/inc_pluginfunctions index 8b7a9fdac07e3027c63f13e78f0c764939786962..bd102868d63e60471980f9a045f5292a1166e6b8 100644 --- a/inc_pluginfunctions +++ b/inc_pluginfunctions @@ -100,7 +100,13 @@ function ph.exit(){ # ---------------------------------------------------------------------- # detect LINUX DISTRO as lowercase -# returns one of centos|debian|ubuntu|... +# returns string; one of ... +# almalinux +# centos +# debian +# manjaro +# rocky +# ubuntu function ph.getOS(){ local distro=