From 59b35806c43e6495872cc5dc1ff9ccb06e381c96 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Tue, 11 Feb 2025 15:57:11 +0100
Subject: [PATCH 1/6] create markdown help for check_file_age

---
 docs/20_Checks/check_file_age.md | 85 ++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)
 create mode 100644 docs/20_Checks/check_file_age.md

diff --git a/docs/20_Checks/check_file_age.md b/docs/20_Checks/check_file_age.md
new file mode 100644
index 0000000..2bb9986
--- /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)
-- 
GitLab


From 2c29a17e1268f18cb2637236d39d32c49712c6fc Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Tue, 11 Feb 2025 15:59:18 +0100
Subject: [PATCH 2/6] check_psqlserver: add iml default help header

---
 check_file_age   | 4 ++--
 check_psqlserver | 9 ++-------
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/check_file_age b/check_file_age
index 6fadc6c..63cc4b4 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 4e1afb4..47c0e7f 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
-- 
GitLab


From 2ed5bae7207729618b2b98695693f5d6af1c3071 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Tue, 11 Feb 2025 16:44:22 +0100
Subject: [PATCH 3/6] reboot: add default banner for IML checks; add support
 for manjaro

---
 check_reboot_required | 59 +++++++++++++++++++++++++++++++++----------
 1 file changed, 45 insertions(+), 14 deletions(-)

diff --git a/check_reboot_required b/check_reboot_required
index 423ea64..4b00ad7 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,39 @@ 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)."
+    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
 
-- 
GitLab


From 24df053806f9deaf72245077df4c0b3237e9e060 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Tue, 11 Feb 2025 16:50:18 +0100
Subject: [PATCH 4/6] shared functions: update in comment block

---
 inc_pluginfunctions | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/inc_pluginfunctions b/inc_pluginfunctions
index 8b7a9fd..bd10286 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=
 
-- 
GitLab


From c9022a9d175f1e607bb133d64c25bfd78dfe48e4 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Tue, 11 Feb 2025 16:50:45 +0100
Subject: [PATCH 5/6] reboot: on unknown distro show additional hint

---
 check_reboot_required | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/check_reboot_required b/check_reboot_required
index 4b00ad7..4fad651 100755
--- a/check_reboot_required
+++ b/check_reboot_required
@@ -130,7 +130,8 @@ case $distro in
     ;;
 
   *)
-    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
-- 
GitLab


From bd470143221a72158104dc8ae87a43d92e3b8c91 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Tue, 11 Feb 2025 16:51:02 +0100
Subject: [PATCH 6/6] reboot: update markdown help

---
 docs/20_Checks/check_reboot_required.md | 38 ++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/docs/20_Checks/check_reboot_required.md b/docs/20_Checks/check_reboot_required.md
index 56406b4..7e7b6aa 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.
 ```
-- 
GitLab