Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: snmpwalk in perl

by thanos1983 (Parson)
on May 17, 2019 at 17:13 UTC ( #11100194=note: print w/replies, xml ) Need Help??


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

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 = '1.3.6.1.2.1.25.2.2.0'; my @ips = qw(127.0.0.1 127.0.0.1); 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2020-06-03 09:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (22 votes). Check out past polls.

    Notices?