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.

In reply to Re: Writing SNMP walk to CSV file by traveler
in thread Writing SNMP walk to CSV file by getwithrob

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.