簡介
本文說明如何為網路服務協調器(NSO)設定簡易網路管理通訊協定(SNMP)。
必要條件
需求
思科建議您瞭解以下主題:
- SNMP配置載入到NSO配置資料庫(CDB)中。
- NSO上生成的警報。
- 伺服器上的「snmpwalk」命令支援。
採用元件
本文件所述內容不限於特定軟體和硬體版本。
本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您的網路運作中,請確保您瞭解任何指令可能造成的影響。
背景資訊
該配置已在CentOS 7上測試和驗證。在Ubuntu 18.04上,輸出與CentOS輸出類似,但不生成警報。
可以停止Linux提供的內建SNMP服務:
[root@nso-recreate ~]# service snmpd status
Redirectin to /bin/systemctl status snmpd.service
snmpd.service - Simple Network Management Protocol (SNMP) Daemon.
Loaded: loaded (/usr/lib/systemd/system/snmpd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
組態
在NSO CLI中,前往組態模式並進行這些變更;最終SNMP設定為:
admin@ncs# show running-config snmp
snmp agent enabled
snmp agent ip 0.0.0.0
snmp agent udp-port 4000
snmp agent version v1
snmp agent version v2c
snmp agent version v3
snmp agent engine-id enterprise-number 32473
snmp agent engine-id from-text testing
snmp agent max-message-size 50000
snmp system contact ""
snmp system name ""
snmp system location ""
snmp usm local user initial
auth sha password authpass
priv aes password privpass
!
snmp target monitor
ip 127.0.0.1
udp-port 162
tag [ monitor ]
timeout 1500
retries 3
v2c sec-name public
!
snmp community public
sec-name public
!
snmp notify foo
tag monitor
type trap
!
snmp vacm group initial
member initial
sec-model [ usm ]
!
access usm no-auth-no-priv
read-view internet
notify-view internet
!
access usm auth-no-priv
read-view internet
notify-view internet
!
access usm auth-priv
read-view internet
notify-view internet
!
!
snmp vacm group public
member public
sec-model [ v1 v2c ]
!
access any no-auth-no-priv
read-view internet
notify-view internet
!
!
snmp vacm view internet
subtree 1.3.6.1
included
!
!
snmp vacm view restricted
subtree 1.3.6.1.6.3.11.2.1
included
!
subtree 1.3.6.1.6.3.15.1.1
included
!
!
其他配置
要驗證SNMP是否工作,您可以建立警報,並使用 show alarms alarm-list
指令:
admin@ncs# show alarms alarm-list
alarms alarm-list number-of-alarms 2
alarms alarm-list last-changed 2022-03-31T09:26:58.912259+00:00
alarms alarm-list alarm ios0 connection-failure /devices/device[name='ios0'] ""
is-cleared false
last-status-change 2022-03-31T09:26:58.912259+00:00
last-perceived-severity major
last-alarm-text "Failed to connect to device ios0: connection refused: NEDCOM CONNECT: Connection refused (Connection refused) in new state"
status-change 2022-03-31T09:26:58.912259+00:00
received-time 2022-03-31T09:26:58.912259+00:00
perceived-severity major
alarm-text "Failed to connect to device ios0: connection refused: NEDCOM CONNECT: Connection refused (Connection refused) in new state"
alarms alarm-list alarm jun0 connection-failure /devices/device[name='jun0'] ""
is-cleared false
last-status-change 2022-03-31T09:26:57.507969+00:00
last-perceived-severity major
last-alarm-text "Failed to connect to device jun0: connection refused"
status-change 2022-03-31T09:26:57.507969+00:00
received-time 2022-03-31T09:26:57.507969+00:00
perceived-severity major
alarm-text "Failed to connect to device jun0: connection refused"
驗證
若要確認組態是否正確,請確認不同版本的SNMP:
附註:要獲取整個輸出,可以使用OID .1.3.6.1。要僅獲取警報,可以使用1.3.6.1.4.1。
版本1
snmpwalk -v 1 -c public 0.0.0.0:4000 .1.3.6.1
snmpwalk -v 1 -c public 0.0.0.0:4000 .1.3.6.1.4.1
版本2
snmpwalk -v 2c -c public 0.0.0.0:4000 .1.3.6.1
snmpwalk -v 2c -c public 0.0.0.0:4000 .1.3.6.1.4.1
版本3
snmpwalk -On -v3 -a SHA -x AES -A 'authpass' -X 'privpass' -l 'authPriv' -u 'initial' 0.0.0.0:4000 .1.3.6.1
snmpwalk -On -v3 -a SHA -x AES -A 'authpass' -X 'privpass' -l 'authPriv' -u 'initial' 0.0.0.0:4000 .1.3.6.1.4.1
的預期輸出 snmpwalk
命令為:
[root@nso-recreate ~]# snmpwalk -On -v3 -a SHA -x AES -A 'authpass' -X 'privpass' -l 'authPriv' -u 'initial' 0.0.0.0:4000 .1.3.6.1.4.1
.1.3.6.1.4.1.24961.2.103.1.1.1.0 = Gauge32: 2
.1.3.6.1.4.1.24961.2.103.1.1.2.0 = Hex-STRING: 07 E6 03 1F 09 1A 3A 09 2B 00 00
.1.3.6.1.4.1.24961.2.103.1.1.5.1.2.1 = STRING: "connection-failure"
.1.3.6.1.4.1.24961.2.103.1.1.5.1.2.2 = STRING: "connection-failure"
.1.3.6.1.4.1.24961.2.103.1.1.5.1.3.1 = STRING: "jun0"
.1.3.6.1.4.1.24961.2.103.1.1.5.1.3.2 = STRING: "ios0"
.1.3.6.1.4.1.24961.2.103.1.1.5.1.4.1 = STRING: "/ncs:devices/ncs:device[ncs:name='jun0']"
.1.3.6.1.4.1.24961.2.103.1.1.5.1.4.2 = STRING: "/ncs:devices/ncs:device[ncs:name='ios0']"
.1.3.6.1.4.1.24961.2.103.1.1.5.1.5.1 = OID: .0.0
.1.3.6.1.4.1.24961.2.103.1.1.5.1.5.2 = OID: .0.0
.1.3.6.1.4.1.24961.2.103.1.1.5.1.6.1 = ""
.1.3.6.1.4.1.24961.2.103.1.1.5.1.6.2 = ""
.1.3.6.1.4.1.24961.2.103.1.1.5.1.7.1 = ""
.1.3.6.1.4.1.24961.2.103.1.1.5.1.7.2 = ""
.1.3.6.1.4.1.24961.2.103.1.1.5.1.8.1 = INTEGER: 2
.1.3.6.1.4.1.24961.2.103.1.1.5.1.8.2 = INTEGER: 2
.1.3.6.1.4.1.24961.2.103.1.1.5.1.9.1 = Gauge32: 0
.1.3.6.1.4.1.24961.2.103.1.1.5.1.9.2 = Gauge32: 0
.1.3.6.1.4.1.24961.2.103.1.1.5.1.10.1 = Hex-STRING: 07 E6 03 1F 09 1A 39 05 2B 00 00
.1.3.6.1.4.1.24961.2.103.1.1.5.1.10.2 = Hex-STRING: 07 E6 03 1F 09 1A 3A 09 2B 00 00
.1.3.6.1.4.1.24961.2.103.1.1.5.1.11.1 = Hex-STRING: 07 E6 03 1F 09 1A 39 05 2B 00 00
.1.3.6.1.4.1.24961.2.103.1.1.5.1.11.2 = Hex-STRING: 07 E6 03 1F 09 1A 3A 09 2B 00 00
.1.3.6.1.4.1.24961.2.103.1.1.5.1.12.1 = INTEGER: 4
.1.3.6.1.4.1.24961.2.103.1.1.5.1.12.2 = INTEGER: 4
.1.3.6.1.4.1.24961.2.103.1.1.5.1.13.1 = INTEGER: 2
.1.3.6.1.4.1.24961.2.103.1.1.5.1.13.2 = INTEGER: 2
.1.3.6.1.4.1.24961.2.103.1.1.5.1.14.1 = STRING: "Failed to connect to device jun0: connection refused"
.1.3.6.1.4.1.24961.2.103.1.1.5.1.14.2 = STRING: "Failed to connect to
device ios0: connection refused: NEDCOM CONNECT: Connection refused (Connection refused) in new state"
疑難排解
已知問題包括:
發生超時的原因如下:
- NSO關閉
— 命令中使用的IP/埠不正確
關聯的使用者名稱錯誤/不正確,該值位於"-u"引數之後
初始使用者未分配給任何組。新增以下選項之一:
snmp usm local user admin
auth sha密碼…….
priv aes密碼…….
或
nacm groups group ncsoper user-name [ public initial ]