From 09461ab648a35b26921eab653c2133ed3f8c4508 Mon Sep 17 00:00:00 2001 From: Thomas Constans Date: Mon, 26 Jun 2023 16:06:36 +0200 Subject: [PATCH] check epson ink level --- check_snmp_epson.sh | 61 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 check_snmp_epson.sh diff --git a/check_snmp_epson.sh b/check_snmp_epson.sh new file mode 100644 index 0000000..98238a1 --- /dev/null +++ b/check_snmp_epson.sh @@ -0,0 +1,61 @@ +#! /bin/bash + +set -eu -o pipefail + +function _usage { + echo "Usage: $O -H addresse -C public -w W% -c X%" + exit 3 +} +black=SNMPv2-SMI::mib-2.43.11.1.1.9.1.1 +blue=SNMPv2-SMI::mib-2.43.11.1.1.9.1.2 +magenta=SNMPv2-SMI::mib-2.43.11.1.1.9.1.3 +yellow=SNMPv2-SMI::mib-2.43.11.1.1.9.1.4 + +if [ $# -lt 1 ] ; then _usage ; fi + +while getopts "hH:w:c:C:i:" opt ; do + case $opt in + (i) + color=$OPTARG + ;; + (C) + community=$OPTARG + ;; + (H) + host=$OPTARG + ;; + (h) + _usage + ;; + (w) + warning=$OPTARG + ;; + (c) + critical=$OPTARG + ;; + (*) + _usage + ;; + esac +done + +test -x /usr/bin/snmpwalk || exit 3 + +v=$(snmpwalk -v2c -c "${community}" "${host}" ${!color} -Oq | awk '{print $2}') + +if [ "$v" -lt "$critical" ] ; then + echo "$color critical level" + exit 2 +fi + +if [ "$v" -lt "$warning" ] ; then + echo "$color warning level" + exit 1 +fi + +echo "$color ok level" +exit 0 + + + +