スイッチを検索して、特定のIPアドレスをホストしているスイッチを見つけるPerlスクリプトがあります。このスクリプトは、net-snmp
ライブラリを使用して、ホストが接続されている正しいスイッチが見つかるまで、イーサネットスイッチのデイジーチェーン(コア/ディストリビューション/アクセスを考えてください)をポーリングします。
このスクリプトはほとんどのLinuxマシンで正常に機能しますが、SNMPv2-SMI
に「zeroDotZero」がないことを把握するSTDERRメッセージをスローするスクリプトがあります。
[mpenning@lnxlmf ietf]$ Perl ~/findhost2.pl 192.0.2.30
192.0.2.30, 192.0.2.30, No log handling enabled - turning on stderr logging
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/Cisco/IP-MIB.my)
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/Cisco/EVENT-MIB.my)
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/DISMAN-SCHEDULE-MIB.txt)
No log handling enabled - turning on stderr logging
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/Cisco/IP-MIB.my)
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/Cisco/EVENT-MIB.my)
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/DISMAN-SCHEDULE-MIB.txt)
No log handling enabled - turning on stderr logging
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/Cisco/IP-MIB.my)
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/Cisco/EVENT-MIB.my)
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/DISMAN-SCHEDULE-MIB.txt)
No log handling enabled - turning on stderr logging
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/Cisco/IP-MIB.my)
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/Cisco/EVENT-MIB.my)
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/DISMAN-SCHEDULE-MIB.txt)
No log handling enabled - turning on stderr logging
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/Cisco/IP-MIB.my)
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/Cisco/EVENT-MIB.my)
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/DISMAN-SCHEDULE-MIB.txt)
0:1e:b:26:78:d9, No log handling enabled - turning on stderr logging
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/Cisco/IP-MIB.my)
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/Cisco/EVENT-MIB.my)
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/DISMAN-SCHEDULE-MIB.txt)
No log handling enabled - turning on stderr logging
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/Cisco/IP-MIB.my)
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/Cisco/EVENT-MIB.my)
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/DISMAN-SCHEDULE-MIB.txt)
No log handling enabled - turning on stderr logging
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/Cisco/IP-MIB.my)
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/Cisco/EVENT-MIB.my)
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/DISMAN-SCHEDULE-MIB.txt)
No log handling enabled - turning on stderr logging
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/Cisco/IP-MIB.my)
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/Cisco/EVENT-MIB.my)
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/DISMAN-SCHEDULE-MIB.txt)
No log handling enabled - turning on stderr logging
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/Cisco/IP-MIB.my)
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/Cisco/EVENT-MIB.my)
Did not find 'zeroDotZero' in module SNMPv2-SMI (/usr/share/snmp/mibs/DISMAN-SCHEDULE-MIB.txt)
192.0.2.254, Gi5/44
[mpenning@lnxlmf ietf]$
エラーメッセージを停止するにはどうすればよいですか?
net-snmp
のデフォルトのSNMPv2-SMI
コピーにはzeroDotZero ..の定義があります。
[mpenning@lnxlmf ietf]$ cd /usr/share/snmp/mibs/
[mpenning@lnxlmf mibs]$ grep zeroDotZero SNMPv2-SMI.txt
zeroDotZero OBJECT-IDENTITY
[mpenning@lnxlmf mibs]$
CiscoMIBディレクトリにSNMPv2-SMI.my
の古いコピーをインストールしたことが判明しました...このSNMPv2-SMI.my
のコピーにはzeroDotZeroがなく、net-snmp
のコピーを上書きしていたので削除しました。
[mpenning@lnxlmf mibs]$ cd /usr/share/snmp/mibs/Cisco/
[mpenning@lnxlmf Cisco]$ grep zeroDotZero SNMPv2-SMI.my
[mpenning@lnxlmf Cisco]$ Sudo rm SNMPv2-SMI.my
これで、スクリプトは問題なく実行されます...
[mpenning@lnxlmf ~]$ Perl findhost2.pl 192.0.2.29
192.0.2.29, 192.0.2.29, 0:27:e:22:9a:d5, core-switch2, 7/37
[mpenning@lnxlmf ~]$