#!/usr/bin/perl -w use warnings; use strict; use Net::SNMP qw(snmp_dispatcher oid_lex_sort); #use Smart::Comments '###'; my $startip = $ARGV[0] || die "Missing Starting IP"; my $endip = $ARGV[1] || die "Missing Ending IP"; my $community = $ARGV[2] || die "Missing community string"; my @ip_start = split(/\./,$startip); my @ip_end = split(/\./,$endip); my $contadr = 0; my($i,$j,$k,$l); { for ($l="$ip_start[0]";$l<="$ip_end[0]";$l++){ for ($i="$ip_start[1]";$i<="$ip_end[1]";$i++){ for ($j="$ip_start[2]";$j<="$ip_end[2]";$j++){ for ($k="$ip_start[3]";$k<="$ip_end[3]";$k++){ my ($session,$error)=Net::SNMP->session(-hostname=>"$l.$i.$j.$k", -version => 'snmpv2c', -nonblocking=>1, -community=>"$community", -timeout=>3, -retries=>1, ); if (defined($session)) { my $serialno='.1.3.6.1.3.83.1.1.4.0'; my $mac='.1.3.6.1.2.1.2.2.1.6.2'; my @msoids=($hfcmac,$serialno); my $result=$session->get_request( -varbindlist=>\@msoids, callback=>[\&getms,$session,"$l.$i.$j.$k"] ); $session->close; ## reason for all this close, is that they dont seem to get #closed no matter where i put them }else{ print "Session not defined! $error\n"; }; $session->close; }; snmp_dispatcher(); }; }; }; }; exit; { sub getms { my $obj = shift; my $session = shift; my $hfcip = shift; if (!defined($obj->var_bind_list)) { warn "$hfcip SNMP Error.",$obj->error(),"\n"; return; }; ## print values for the oids }; };