EVOLUTION-MANAGER
Edit File: build_snmp_mappings.sh
#!/bin/bash # # (C) 2022 - ntop # # This tool is used to generate automatically the SNMP mappings file # to be used with nProbe # function help { echo "Usage: build_snmp_mappings.sh <SNMP agent IP> <SNMP version 1|2c> <SNMP community>" echo "" echo "Example: build_snmp_mappings.sh 127.0.0.1 2c public > snmp_mappings.txt" echo " nprobe --snmp-mappings snmp_mappings.txt ..." exit 0 } # Check if snmpwalk is present WALK=`which snmpwalk` if [ -z "$WALK" ]; then echo "ERROR: snmpwalk not found" echo "" echo "Please install the snmp package (e.g. 'sudo apt-get install snmp')" echo "and run this tool again" exit fi if [ "$#" -ne 3 ]; then help else AGENT=$1 VERSION=$2 COMMUNITY=$3 if [ "$VERSION" != "1" ] && [ "$VERSION" != "2c" ]; then echo "ERROR: Invalid SNMP version" help fi IFNAME_OID="1.3.6.1.2.1.2.2.1.2" ALIAS_OID="1.3.6.1.2.1.31.1.1.1.18" $WALK -On -v $VERSION -c $COMMUNITY $AGENT $IFNAME_OID | cut -d '.' -f 12 | cut -d ' ' -f 1,4 | while IFS= read -r line; do echo "$AGENT $line" done echo "# Agent InterfaceId Name" fi