FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


Top     SiteMap

Sidebar


Top     SiteMap

Manager Server

Target Server

$FHHOME/bin/xxx.sh | xxxx.exp













.

fhscripts:check:check_snmp.sh.html



FastHandle Scripts

Script for Check SNMP with one-line

About check_snmp.sh


How to use check_snmp.sh


check_snmp.sh

$FHHOME/bin/check_snmp.sh

#!/bin/sh
#=======================================================
# check_snmp.sh
#
# How to use
#   check_snmp.sh -h  #HELP
#   check_snmp.sh  x.x.x.x community name
#=======================================================
# Note
# snmpwalk -v 2c -c public localhost TEXT  #output with Text
# snmpwalk -v 2c -c public -O n localhost TEXT  #output with OID
# snmptranslate OID # OID to Text
# snmptranslate -Td OID # OID's description
# /usr/share/snmp/mibs/

VERSION=2c
HOST=$1
COMMUNITY=$2
OID=$3



HELP () {
    echo "How to use"
    cat $0 |grep ")" |egrep "snmpwalk|:" |grep -v print |awk -F")" {'print "  check_snmp.sh x.x.x.x community "  $1'}
    exit 0
}

case ${1} in
  -h|-l) HELP
     ;;
esac

case ${OID} in
  sysname) snmpwalk -v $VERSION -c $COMMUNITY $HOST .1.3.6.1.2.1.1.5.0 #sysname
      ;;
  linux.network) :
      echo "" ; echo "## interfaces (OID .1.3.6.1.2.1.2) ##"
      # 32bit counter (OID .1.3.6.1.2.1.2)
      snmpwalk -v $VERSION -c $COMMUNITY $HOST .1.3.6.1.2.1.2.2.1.1 # ifIndex
      snmpwalk -v $VERSION -c $COMMUNITY $HOST .1.3.6.1.2.1.2.2.1.2 # ifDescr
      echo "## 1000000000 bps = 1,000,000,000 bps = 1Gbps"
      snmpwalk -v $VERSION -c $COMMUNITY $HOST .1.3.6.1.2.1.2.2.1.5 # ifSpeed
      snmpwalk -v $VERSION -c $COMMUNITY $HOST .1.3.6.1.2.1.2.2.1.6 # ifPhysAddress
      snmpwalk -v $VERSION -c $COMMUNITY $HOST .1.3.6.1.2.1.2.2.1.8 # ifOperStatus

      # 64bit counter (OID .1.3.6.1.2.1.31.1.1.1)
      #snmpwalk -v $VERSION -c $COMMUNITY $HOST ifName
      snmpwalk -v $VERSION -c $COMMUNITY $HOST .1.3.6.1.2.1.31.1.1.1.15 # ifHighSpeed

      echo "" ; echo "## ip (OID .1.3.6.1.2.1.4) ##"
      snmpwalk -v $VERSION -c $COMMUNITY $HOST .1.3.6.1.2.1.4.20.1.1 # ipAdEntAddr
      snmpwalk -v $VERSION -c $COMMUNITY $HOST .1.3.6.1.2.1.4.20.1.3 # ipAdEntNetMask
      snmpwalk -v $VERSION -c $COMMUNITY $HOST .1.3.6.1.2.1.4.20.1.2 # ipAdEntIfIndex
      ;;
  linux.cpu) :
      echo "## Cpu Type"
      snmpwalk -v $VERSION -c $COMMUNITY $HOST -O n .1.3.6.1.2.1.25.3.2.1.3 |grep CPU # hrDeviceDescr

      echo "" ; echo "## Cpu Usage"
      echo "## The average, over the last minute, of the percentage of time that this processor was not idle."
      snmpwalk -v $VERSION -c $COMMUNITY $HOST .1.3.6.1.2.1.25.3.3.1.2 # hrProcessorLoad

      echo "" ; echo "## Cpu Load Average"
      snmpwalk -v $VERSION -c $COMMUNITY $HOST .1.3.6.1.4.1.2021.10.1.2 # laNames
      snmpwalk -v $VERSION -c $COMMUNITY $HOST .1.3.6.1.4.1.2021.10.1.3 # laLoad
      ;;
  linux.memory) :
      snmpwalk -v $VERSION -c $COMMUNITY $HOST .1.3.6.1.4.1.2021.4.5 #memTotalReal
      snmpwalk -v $VERSION -c $COMMUNITY $HOST .1.3.6.1.4.1.2021.4.6 # memAvailReal
      ;;
  *) snmpwalk -v $VERSION -c $COMMUNITY $HOST ${OID} ;;
esac








FastHandle Scripts



fhscripts/check/check_snmp.sh.html.txt ยท Last modified: 2018/03/29 00:04 by kurihara