【发布时间】:2012-02-13 20:08:54
【问题描述】:
我有以下(工作的)perl 脚本:
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 中创建了一个 snmp.conf 文件,其内容如下:
defSecurityName my_user_name
defContext ""
defAuthType SHA
defSecurityLevel authPriv
defAuthPassphrase my_auth_key here
defVersion 3
defPrivPassphrase my_privkey here
defPrivType DES
如我所见,我在脚本和 snmpget 中使用了相同的凭据。为什么我会收到 snmpget: Authentication failure (incorrect password, community or key) ?
【问题讨论】:
-
我曾经在一家公司工作,使用 Perl 进行多供应商网络管理。我的 0.02 美元是,那里有足够的不一致之处,如果某些东西适用于一个 SNMP 客户端库而不是另一个,你不应该过分惊讶,如果随机设备的 SNMP 代理是一块垃圾,你也不应该感到惊讶。 ;)