From c3ac5fae69cc4dd8582e00ae7e490fa79accc740 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch> Date: Mon, 18 Sep 2023 17:06:59 +0200 Subject: [PATCH] add snmpv3 support --- check_snmp_printer | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/check_snmp_printer b/check_snmp_printer index 72fad4d..94e4364 100755 --- a/check_snmp_printer +++ b/check_snmp_printer @@ -5,22 +5,33 @@ # # ------------------------------------------------------------ # 2021-03-22 <axel.hahn@iml.unibe.ch> v0.1 +# 2023-09-18 <axel.hahn@iml.unibe.ch> v0.2 snmpv3 support # ============================================================ # ------------------------------------------------------------ # CONFIG # ------------------------------------------------------------ -check='/usr/lib64/nagios/plugins/check_snmp_printer' +. $(dirname $0)/check_snmp_includes + +# check='/usr/lib64/nagios/plugins/check_snmp_printer' +# updated script is taken from https://github.com/Tylan/check_snmp_printer/tree/master +check='/usr/lib64/nagios/plugins/check_snmp_printer_v2.0.1' debug=0 # ------------------------------------------------------------ # MAIN # ------------------------------------------------------------ + sParams="$*" + # find host behind param -H -snmphost=$( echo $sParams | sed -Ee 's#.*\-H\ ([0-9a-z\.\-]*).*#\1#' ) +SNMPTARGET=$( echo $sParams | sed -Ee 's#.*\-H\ ([0-9a-z\.\-]*).*#\1#' ) + +# find SNMPTARGET in config +test -z "$SNMPAUTH" && read_config +sParams+=" $SNMPAUTH" what=$( echo $sParams | sed -Ee 's#.*\-\-([a-z]*).*#\1#' ) @@ -40,14 +51,5 @@ case "$what" in ;; esac - -if [ "$debug" = "1" ]; then - echo COMMAND @ `date` - echo $0 $* - echo "$what - `$check --model -H $snmphost` - IP $snmphost" - echo --- - echo calling $check $sParams - echo --- -fi - +test "$debug" = "1" && ( echo "$what:"; echo calling $check $sParams ; echo ) $check $sParams -- GitLab