我有以下的(工作)perl脚本:SNMP v3与NET :: SNMP工作,但snmpwalk/snmpget没有?
use Net::SNMP;
# create session to the host
my ($session, $error) = Net::SNMP->session(
-hostname => $hostname,
-version => 'snmpv3',
-username => 'my_user_name',
-authkey => 'my_authkey',#actually, here stands the real authkey as configured on the switch
-privkey => 'my_privkey',#same as on switch
-authprotocol => 'sha',
-privProtocol => 'des'
);
if (!defined($session)) {
print $error . "\n";
last;
}
# retrieve a table from the remote agent
my $result = $session->get_table(
-baseoid => $MAC_OID
);
if (!defined($result)) {
print $session->error . "\n";
$session->close;
last;
}
#print out the result of the snmp query
#....
现在我想用snmpwalk的或相同的按键SNMPGET。对于这一点,我创建了一个snmp.conf文件中.snmp我的主目录包含以下内容组成:
defSecurityName my_user_name
defContext ""
defAuthType SHA
defSecurityLevel authPriv
defAuthPassphrase my_auth_key here
defVersion 3
defPrivPassphrase my_privkey here
defPrivType DES
当我看到它,我用的是相同的凭据的脚本和SNMPGET。为什么我会收到snmpget:身份验证失败(密码错误,社区或密钥)?
我曾经在一家使用Perl进行多厂商网络管理的公司工作。我的0.02美元就是存在足够的不一致性,如果某个SNMP客户端库可以使用某个SNMP客户端库而不是另一个,那么您应该不会感到过分惊讶,并且如果随机设备的SNMP代理是一件垃圾,那么双倍不会感到惊讶。 ;) – fennec 2012-02-15 03:05:44