How can I get the name of the node being walked to display for each port or at least at the beginning of the ports for that node?

If including the IP address at the beginning of each csv data row is good enough to satisfy this, I already mentioned how to do that at the bottom of my first reply. (Maybe that wasn't clear enough?)

If you mean that you need to include the host name string from the original host list input file, that's not too much to add, given that the @hosts array and the @iplist array are parallel. Changing the print loop to read as follows ought to suffice -- I'm just adding a line after the first "for" statement, and making a slight change to the line following the second "for" statement:

for my $ip ( @iplist ) { my $host = shift @hosts; # get host name for this $ip for my $portid ( 0 .. $ipdata{$ip}{lastport} ) { my $outstr = "$host,"; for my $info ( @infolist ) { $outstr .= '"' . $ipdata{$ip}{$info}[$portid] . '",'; } $outstr =~ s/,$/\n/; # replace trailing comma print O $outstr; } }
If/when you learn more about programming, you should be able to look at the script as it stands and see ways of improving it (e.g. putting the host name into the hash along with all the port data, so that all the printing is done from data in the hash). Anyway, good luck.

In reply to Re^5: snmpwalk to CSV #2 by graff
in thread snmpwalk to CSV #2 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.