in reply to Writing SNMP walk to CSV file

If the problem is that you are only getting one interface per device, this is the programmed behavior. Your outer loop while (<NODES>) processes each device. Your inner loop (foreach $column) strips one value out of the output of the snmpwalk. The print at the end of the loop prints that one value.

If the device has more than one device, you'll need to get all the values from the snmpwalk output. Each should be on its own line and it might look like:

interfaces.ifTable.ifEntry.ifDescr.1 = STRING: Ethernet1 interfaces.ifTable.ifEntry.ifDescr.2 = STRING: Ethernet2 interfaces.ifTable.ifEntry.ifDescr.3 = STRING: Serial0
Code something like this untested example (I don't have any SNMP devices with multiple interfaces at this office):
my %values; foreach $column (@columns) { # get all the values for $column for $node $values{column} = [`snmpwalk $node VER143r $column`]; foreach (@($values{column})){ if (/=\s*(.*)$/) { $val = $1; } else { $val = "???"; } $_ = $value; } } # now we have all of each column foreach my $row (0..$#( $values{$columns[0]}}){ foreach my $col (keys %values){ #(for each column) my $line = ""; $line .= $values{$col}[$row] . ","; } print "-- $row, $val\n" if $debug; } chop $line; print CSV $line."\n";
The code is untested and maybe broken, but the idea should get you started.

Replies are listed 'Best First'.
Re^2: Writing SNMP walk to CSV file
by getwithrob (Initiate) on Sep 23, 2005 at 01:51 UTC
    Traveler, I see what you're stating. Can you help me a little more? I stink when it comes to programming. Can you give me a few more hints?
      unless the code is buggy, replace the section in your code that this replaces, beginning with the foreach. It should work.