diff --git a/check_snmp_printer b/check_snmp_printer index 72fad4daebb0d15dd79cf40b1fb733640c2a097c..94e4364a9493e327edbd0672b8333ccaa8fca7d6 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