Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

perl snmp doubt

Status
Not open for further replies.

Gassner

ISP
Jan 30, 2002
19
0
0
BR
Hi, im using snmp_util to walk some tables with perl, but mac-addresses are shown as strange values....

Anyone got ideas?

Thankz,

Rafael Gustavo Gassner


#! /usr/bin/perl -w
use SNMP_util;
#use SNMP_Session;
#use BER;

$ip="10.10.10.10";
$comm="public";
$poort="161";
$timeout="100";
$retries="2";
print "Coletando indices do equipamento $ip\n";
@indice=&snmpwalk("$comm\@$ip:$poort:$timeout:$retries","1.3.6.1.2.1.4.22.1.1");
print "Coletando enderecos MAC do equipamento $ip\n";
@fisico=&snmpwalk("$comm\@$ip:$poort:$timeout:$retries","1.3.6.1.2.1.4.22.1.2");
print "Coletando enderecos IP do equipamento $ip\n";
@rede=&snmpwalk("$comm\@$ip:$poort:$timeout:$retries","1.3.6.1.2.1.4.22.1.3");
print "Coletando tipos de endereco do equipamento $ip\n";
@tipo=&snmpwalk("$comm\@$ip:$poort:$timeout:$retries","1.3.6.1.2.1.4.22.1.4");

$i=int(@indice);
print "$i\n";
while($i ne 0)
{
$i--;
($oid, $indice[$i]) = split(/\:/, $indice[$i]);
($oid, $fisico[$i]) = split(/\:/, $fisico[$i]);
($oid, $rede[$i]) = split(/\:/, $rede[$i]);
($oid, $tipo[$i]) = split(/\:/, $tipo[$i]);

print " $indice[$i] $fisico[$i] $rede[$i] $tipo[$i]\n";
}
 
oops... problem solved.

just add
$fisico[$i] = unpack 'H*', $fisico[$i];

before printing the variable.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top