#=== FUNCTION ================================================================ # NAME: snmp_get # PURPOSE: fetch the Physical Address of the eth0 int # PARAMETERS: $sess, the snmp_session returned by the init. #=============================================================================== sub snmp_get($){ my ($interfaces_table, @interfaces_oids, $int_id, $error, $snmp_res); my $snmp_sess = shift; unless ($snmp_sess){ print STDERR "snmp_session object has fallen out of scope\n" if $debug; return; } my @interface_names_oid='1.3.6.1.2.1.2.2.1.2'; $interfaces_table=$snmp_sess->get_entries(-columns => \@interface_names_oid); if ($interfaces_table){ foreach my $int_oid (keys %{$interfaces_table} ){ ( $int_id ) = ( $int_oid =~ m{\.(\d+)$} ); push(@interfaces_oids, "1.3.6.1.2.1.2.2.1.6.$int_id") if $interfaces_table->{$int_oid}=~m{eth0}; } $snmp_res = $snmp_sess->get_request( -varbindlist => \@interfaces_oids ); }else{ $error=$snmp_sess->error(); } return ($snmp_res,$error); }