show snmptrap サブコマンド¶
概要¶
show snmptrap は SNMP Trap 送信先サーバの設定を表示する CLI グループ1。CONFIG_DB の SNMP_TRAP_CONFIG テーブルから登録された v1/v2/v3 Trap receiver を読み、整形して出力する。
コマンド一覧¶
| コマンド | 用途 |
|---|---|
show snmptrap |
SNMP Trap 送信先設定の表示 |
詳細¶
用法:
動作:
- CONFIG_DB に接続し、
get_table('SNMP_TRAP_CONFIG')でテーブルを取得 - テーブルの key(
v1TrapDest/v2TrapDest/v3TrapDest)から SNMP バージョン番号を決定 - 各エントリの
DestIp,DestPort,vrf,Communityを読み出し、tabulate で出力
表示ヘッダ:
📋 検証エビデンス: sonic-net/sonic-utilities/show/main.py#L606-L624 (sha: 39732bceb8bdefe706518ab40623bbbba6ff33b9)
出典:
sonic-net/sonic-utilities/show/main.py#L606-L624 (sha: 39732bceb8bdefe706518ab40623bbbba6ff33b9)
抜粋:
@cli.group('snmptrap', invoke_without_command=True)
def snmptrap(ctx):
config_db = ConfigDBConnector()
config_db.connect()
traptable = config_db.get_table('SNMP_TRAP_CONFIG')
header = ['Version', 'TrapReceiverIP', 'Port', 'VRF', 'Community']
body = []
for row in traptable:
if row == "v1TrapDest": ver=1
elif row == "v2TrapDest": ver=2
else: ver=3
body.append([ver, traptable[row]['DestIp'], traptable[row]['DestPort'],
traptable[row]['vrf'], traptable[row]['Community']])
関連する CONFIG_DB¶
| テーブル | キー | フィールド |
|---|---|---|
SNMP_TRAP_CONFIG |
v1TrapDest / v2TrapDest / v3TrapDest |
DestIp, DestPort, vrf, Community |
注意¶
- key は SNMP バージョンを文字列で表現する固定値 (
v1TrapDest,v2TrapDest,v3TrapDest)。各バージョンにつき 1 エントリしか保持できない構造になっている。 - v3 では
Communityフィールドは SNMPv3 ユーザ名/コンテキストとは別の意味で運用されるため、実環境では空文字や placeholder の場合がある。
データフロー (自動生成)¶
flowchart LR
CLI["show snmptrap"]
CDB0[("CONFIG_DB<br/>SNMP_TRAP_CONFIG")]
CDB0 --> CLI
凡例
show 系 (CONFIG_DB → CLI) のミニ図。テーブル → daemon 対応は docs/reference/config-db-orch-map.md から機械生成。
関連リファレンス¶
引用元¶
関連 CLI コマンド¶
config mirror session— config mirror_session サブコマンドconfig sflow— config sflow サブコマンドconfig snmp— config snmp / snmpagentaddress / snmptrap サブコマンドconfig syslog— config syslog サブコマンドshow flowcnt— show flowcnt-trap / flowcnt-route サブコマンド
-
show snmptrapグループ定義はshow/main.pyL603-L624。https://github.com/sonic-net/sonic-utilities/blob/39732bceb8bdefe706518ab40623bbbba6ff33b9/show/main.py#L603 ↩