in reply to Writing SNMP walk to CSV file
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:
Code something like this untested example (I don't have any SNMP devices with multiple interfaces at this office):interfaces.ifTable.ifEntry.ifDescr.1 = STRING: Ethernet1 interfaces.ifTable.ifEntry.ifDescr.2 = STRING: Ethernet2 interfaces.ifTable.ifEntry.ifDescr.3 = STRING: Serial0
The code is untested and maybe broken, but the idea should get you started.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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Writing SNMP walk to CSV file
by getwithrob (Initiate) on Sep 23, 2005 at 01:51 UTC | |
by traveler (Parson) on Sep 23, 2005 at 15:06 UTC |