Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re^2: snmpwalk in perl

by Nouhira (Initiate)
on May 17, 2019 at 08:53 UTC ( #11100156=note: print w/replies, xml ) Need Help??

in reply to Re: snmpwalk in perl
in thread snmpwalk in perl

yes, so sorry for that. Im still in learning phase in perl, i wanted to perform snmpwalk for 3 to 4 IP's using snmpwalk command and store the result in an array, After that i want to use a 'for' loop to iterate that array and print the output for one IP at a time. I hope u understood my query.

Replies are listed 'Best First'.
Re^3: snmpwalk in perl
by thanos1983 (Parson) on May 17, 2019 at 17:13 UTC

    Hello again Nouhira,

    On this case a simple foreach loop with all the IPs should do for your case.

    Sample of code:

    #!/usr/bin/perl use strict; use warnings; my $oid = ''; my @ips = qw(; my $community = 'public'; foreach my $ip (@ips) { chomp(my @array = `snmpwalk -v2c -c $community $ip $oid`); }

    As a next step you should find a way to store your data for each IP. On this case my approach would be HASHES OF ARRAYS but it can also be done by ARRAYS OF ARRAYS. I would highly recommend to read the documentation to understand the difference from one to the other and also how to add data to them and how to access the data after.

    Then Job done.

    If you have any problems after experimenting with the code then you can ask us again.

    Hope this helps, Thanos

    Seeking for Perl wisdom...on the process of learning...not there...yet!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11100156]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2021-04-22 03:28 GMT
Find Nodes?
    Voting Booth?

    No recent polls found