コンテンツにスキップ

DEBUG_COUNTER テーブル

概要

SAI debug counter(パケットドロップ要因別の汎用カウンタ)を CONFIG_DB から定義するテーブル1debugcounterorch (orchagent) が消費し、SAI debug counter オブジェクトを作成する。各カウンタには別テーブル DEBUG_COUNTER_DROP_REASON でドロップ理由 (L3_ANYSMAC_EQUALS_DMAC 等) が紐付く。

データフロー (自動生成)

flowchart LR
  CDB[("CONFIG_DB<br/>DEBUG_COUNTER")]
  DM["DebugCounterOrch"]
  CDB --> DM
  SAI["SAI<br/>sai_debug_counter_api"]
  DM --> SAI

凡例

CONFIG_DB から SAI までの典型経路を docs/reference/config-db-orch-map.md から機械生成したミニ図。詳細・例外は本ページ本文と対応表を参照。

key 構造

DEBUG_COUNTER|<name>
DEBUG_COUNTER_DROP_REASON|<name>|<reason>
DEBUG_DROP_MONITOR|CONFIG          # global setting (container)

フィールド (DEBUG_COUNTER_LIST)

フィールド 既定値 説明
name string - カウンタ識別名(key)
alias string - カウンタ別名
desc string - カウンタ説明
group string - グルーピング名
drop_monitor_status stypes:admin_mode disabled ドロップモニタ機能の有効化
window uint64 (sec) 900 モニタ時間窓の長さ(秒)
incident_count_threshold uint64 3 syslog を発火させるインシデント数閾値
drop_count_threshold uint64 100 インシデント判定するドロップ数閾値
type stypes:debug_counter_type - (mandatory) スコープ/方向: PORT_INGRESS_DROPS / PORT_EGRESS_DROPS / SWITCH_INGRESS_DROPS / SWITCH_EGRESS_DROPS

派生テーブル

  • DEBUG_COUNTER_DROP_REASON_LIST (key: name reason)
  • name: 親 DEBUG_COUNTER_LIST.name 存在チェック付き (must 制約)
  • reason: stypes:counter_drop_reason 列挙(SAI のドロップ理由一覧)
  • DEBUG_DROP_MONITOR/CONFIG/status: 永続的ドロップ監視機能のグローバル ON/OFF(admin_mode、既定 disabled

制約

  • typemandatoryYANG mandatory true
  • DEBUG_COUNTER_DROP_REASON.name は親 DEBUG_COUNTER_LIST.name に存在することが必須

例外条件・特殊挙動

  • allPortsReady 未到達 → 全更新ペンディング: ポート初期化完了前は DebugCounterOrch::doTask() が即 return し全 DEBUG_COUNTER 更新を保留する。
  • 未サポートカウンタ種別 → task_failed: counter_typesupported_counter_types に含まれない場合 SWSS_LOG_ERROR("Specified counter type '%s' is not supported.")task_failed
  • 無効 / 未サポートな drop_reason → task_failed: isDropReasonValid() が false か supported_*_drop_reasons に含まれない場合 SWSS_LOG_ERRORtask_failed
  • counter 未存在への drop_reason 追加 → free_drop_counters で保留: DEBUG_COUNTER エントリより先に DROP_REASON 更新が来た場合、free_drop_reasons に保存し counter 作成時に reconcileFreeDropCounters() で適用 (順序非依存)。
  • 最後の drop_reason の削除 → task_ignore: drop_reasons が 1 件のときに removeDropReason() を呼ぶと SWSS_LOG_WARN("Attempted to remove all drop reasons from counter")task_ignore。drop counter は最低 1 つの理由が必要。
  • 更新はべき等・失敗は状態を変更しない: 失敗した更新はシステム状態を変更しない。同一リクエストの繰り返しは同一結果となる。

値依存挙動マトリクス

フィールド 挙動
type PORT_INGRESS_DROPS CounterType::PORT_DEBUG として扱い、ポート単位に SAI debug counter を作成(debugcounterorch.cpp:19)。各ポートの ingress ドロップを個別に集計。ポート削除時にカウンタも削除される。
type PORT_EGRESS_DROPS CounterType::PORT_DEBUG として扱い、ポート単位に SAI debug counter を作成(debugcounterorch.cpp:20)。各ポートの egress ドロップを個別に集計。
type SWITCH_INGRESS_DROPS CounterType::SWITCH_DEBUG として扱い、スイッチ全体のグローバルカウンタを作成(debugcounterorch.cpp:21)。全ポート合算の ingress ドロップを集計。
type SWITCH_EGRESS_DROPS CounterType::SWITCH_DEBUG として扱い、スイッチ全体のグローバルカウンタを作成(debugcounterorch.cpp:22)。全ポート合算の egress ドロップを集計。
drop_monitor_status enabled debug_monitor_enabled=true をセット。ドロップ検知時に syslog アラートを発火する(debugcounterorch.cpp:649, 708)。
drop_monitor_status disabled(既定) アラート発生なし。カウンタの蓄積は継続するが通知は行わない。
drop_monitor_status その他の値 SWSS_LOG_ERROR を出力して拒否。enabled/disabled 以外は無効(debugcounterorch.cpp:257)。

購読者

  • debugcounterorch (orchagent): SAI debug counter (sai_debug_counter) を作成し、ドロップ理由のセットを反映

関連 CONFIG_DB / YANG / CLI

  • 関連 CONFIG_DB: COUNTERS_DEBUG_NAME_MAP (COUNTERS_DB 側)
  • 関連 YANG: sonic-debug-counter
  • 関連 CLI: config debug counter / show debug counter

関連リファレンス

引用元

運用ヒント

典型値

  • key 形式: DEBUG_COUNTER|<name>
  • type: PORT_INGRESS_DROPS / PORT_EGRESS_DROPS / SWITCH_INGRESS_DROPS 等。reasons: drop reason の CSV。

よくある誤設定

  • プラットフォーム SAI が未対応の reason を指定すると CrmOrch がエラーを出してカウンタが作られない。

確認コマンド

sonic-db-cli CONFIG_DB keys 'DEBUG_COUNTER|*'
show dropcounters configuration