#!/bin/sh
# Autor Torstein Eide
# Script to do full SNMP dump of device for development.

## define variables.
while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do case $1 in
  -v | --version )
    shift; VER=$1
    ;;
  -c | --communitiy )
    shift; SNMPCOM=$1
    ;;
  -n | --NAME )
    shift; NAME=$1
    ;;
  -r | --remote )
    shift; WHERE=$1
    ;;
esac; shift; done
if [[ "$1" == '--' ]]; then shift; fi

CRED="-v ${VER:-2c} -c ${SNMPCOM:-public} -r0"

## check if missing parameteres
if [[ -z "$WHERE" || -z "$NAME" ]]; then
  echo '
  missing parametere
 -r | --remote REMOTE device = remote device that is doing the work
 -n | --NAME   NAME = filename

 Optional:
 -c | --communitiy (public) SNMPcomunity
 -v | --version    (2c) SNMP version'
  exit 2
fi
snmpwalk -v2c $CRED -t 3 -Cc --hexOutputLength=0 -ObentxU $WHERE .1 > ${NAME}.snmpwalk
snmpwalk -v2c $CRED -t 3 -Cc --hexOutputLength=0 -ObentxU $WHERE .1.3.6.1.4.1 >> ${NAME}.snmpwalk

