in reply to Formating snmpwalk output

You have such a list and snmpwalk is a command line tool? then write a wrapper for that tool that loads this list in a hash and parses the output like this:
use strict; use warnings; my %lookup = ( 'SNMPv2-SMI::enterprises.54321.1.1.1' => 'number of udp + connections'); # data can be a filehandle with the output generated # by File::Temp while (my $line = <DATA>) { chomp $line; my ($oid, $cnt) = $line =~ m{ \A (.*) \s = \s INTEGER: \s ([+- +]?\d+) \z}xms; $oid = $lookup{$oid} if defined $lookup{$oid}; print "$oid, $cnt\n"; } __DATA__ SNMPv2-SMI::enterprises.54321.1.1.1 = INTEGER: 0 SNMPv2-SMI::enterprises.54321.1.1.2 = INTEGER: 1 SNMPv2-SMI::enterprises.54321.1.1.3 = INTEGER: 1 SNMPv2-SMI::enterprises.54321.1.1.5 = INTEGER: 1 SNMPv2-SMI::enterprises.54321.1.1.8 = INTEGER: -1 SNMPv2-SMI::enterprises.54321.1.1.9 = INTEGER: 1 SNMPv2-SMI::enterprises.54321.1.1.12 = INTEGER: 0 SNMPv2-SMI::enterprises.54321.1.1.13 = INTEGER: 0

Replies are listed 'Best First'.
Re^2: Formating snmpwalk output
by just dave (Acolyte) on Apr 09, 2006 at 14:45 UTC
    Thanks, this is a good solution, but I hoped I could avoid it.
    I hoped that there might be a way to "tell" the netsnmp library that I want to send another string or something like this.
    You see, using these libraries , I merely give the integer value and "tell" it that it's an integer that I'm sending, all the rest is done for me (using : $request->setValue($type, $value), where type is INTEGER and value is my value;).
    I hoped that maybe I could add another var or something that will hold the info I want to send (thinking about it, aesthetics don't matter so I don't really mind keeping the message and adding the info I want)
    maybe somebody knows the netsnmp library and can help here ?