#!/bin/env bash # ============================================================ # # Wrapper for check_snmp_printer plugin # # ------------------------------------------------------------ # 2021-03-22 <axel.hahn@iml.unibe.ch> v0.1 # 2023-09-18 <axel.hahn@iml.unibe.ch> v0.2 snmpv3 support # ============================================================ # ------------------------------------------------------------ # CONFIG # ------------------------------------------------------------ . $(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 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#' ) case "$what" in consum) what="Consumables" ;; messages) what="Messages of the printer" ;; pagecount) what="Number of printed pages" ;; trays) what="Status of trays for paper" sParams="$sParams --nofeeder" ;; esac test "$debug" = "1" && ( echo "$what:"; echo calling $check $sParams ; echo ) $check $sParams