Created
September 15, 2016 12:59
Revisions
-
maxried revised this gist
Sep 15, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ #!/usr/bin/env bash oid="" community="" -
maxried created this gist
Sep 15, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ #!/bin/bash oid="" community="" host="" label="" unit="" while getopts "C:H:o:l:u:" o; do case "${o}" in C) community="$OPTARG" ;; H) host="$OPTARG" ;; o) oid="$OPTARG" ;; l) label="$OPTARG" ;; u) unit="$OPTARG" ;; esac done result=$(snmpget -v2c -c $community -Oq -mALL "$host" "$oid" 2> /dev/null) if [[ $? != 0 ]]; then echo "SNMP UNKNOWN - $?" exit 3 else declare -a 'a=('"$result"')' name=${a[0]} value=${a[1]} unitsnmp=${a[2]} if [[ "$label" != "" ]]; then name="$label" fi if [[ "$unit" != "" ]]; then unitsnmp="$unit" fi fi echo "SNMP OK - $name $value $unitsnmp | '$name'=$value"