From 76c2d434ef692eee13342dcf3acbe35b127e00a3 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch>
Date: Thu, 23 Sep 2021 11:44:50 +0200
Subject: [PATCH] add template for checks

---
 zz_template_check_xyz | 95 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)
 create mode 100644 zz_template_check_xyz

diff --git a/zz_template_check_xyz b/zz_template_check_xyz
new file mode 100644
index 0000000..65f9b2d
--- /dev/null
+++ b/zz_template_check_xyz
@@ -0,0 +1,95 @@
+#!/bin/bash
+# ======================================================================
+#
+# Check !!!describe what it does!!!
+#
+# ----------------------------------------------------------------------
+# 202n-nn-nn  v0.0  <name@unibe.ch>  initial version
+# ======================================================================
+
+
+. `dirname $0`/inc_pluginfunctions
+
+# ----------------------------------------------------------------------
+# functions
+# ----------------------------------------------------------------------
+
+function showHelp(){
+cat <<EOF
+______________________________________________________________________
+
+CHECK_XYZ !!! add a short description
+
+(c) Institute for Medical Education - Univerity of Bern
+Licence: GNU GPL 3
+______________________________________________________________________
+
+!!! Add some information what the check does.
+
+!!! add / remove params in syntax, options and example
+
+SYNTAX:
+`basename $0` [-w WARN_LIMIT] [-c CRITICAL_LIMIT]
+
+OPTIONS:
+
+    -w VALUE       cpu usage warning level  (default: 75)
+    -c VALUE       cpu usage critical level (default: 90)
+
+    -h or --help   show this help.
+
+PARAMETERS:
+
+    None.
+
+EXAMPLE:
+`basename $0` -w 60 -c 80
+
+EOF
+}
+# ----------------------------------------------------------------------
+# MAIN
+# ----------------------------------------------------------------------
+
+# --- check param -h
+case "$1" in
+    "--help"|"-h")
+        showHelp
+        exit 0
+        ;;
+    *)
+esac
+
+
+# --- check required tools
+# !!! add needed tools here
+# ph.require bc top
+
+
+# set default / override from command line params
+typeset -i iWarnLimit=`     ph.getValueWithParam 75 w "$@"`
+typeset -i iCriticalLimit=` ph.getValueWithParam 90 c "$@"`
+
+
+# !!! add some logic for a check and fetch values from some output
+
+
+# !!! set status 
+# ph.setStatusByLimit $iMyvalue $iWarnLimit $iCriticalLimit
+# or with a condition:
+# ph.setStatus warning
+# ph.setStatus critical
+
+
+# !!! generate output
+# ph.status "my check sends value $iMyValue"
+
+
+# --- performance data usage
+# !!! add counters if Icinga must show a chart
+# ph.perfadd "checkname-countername"    "${iMyValue}" $iWarnLimit $iCriticalLimit 0 100
+
+
+# ph.exit
+
+# ----------------------------------------------------------------------
-- 
GitLab