Skip to content

Instantly share code, notes, and snippets.

@q1x
Last active December 16, 2015 12:08
Show Gist options
  • Save q1x/0b1078927049c1ed0991 to your computer and use it in GitHub Desktop.
Save q1x/0b1078927049c1ed0991 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# This script counts the number of returned lines from an SNMP walk.
#
COMMUNITY="$1"
IP="$2"
OID="$3"
FILTER="$4"
# Disable mibs to save time
export MIBS=
# Do the walk and count matching lines
snmpwalk -t 5 -On -v 2c -c "$COMMUNITY" "$IP" "$OID" | grep -v '(^$|No Such Instance currently exists at this OID$)' | grep -c "$FILTER"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment