MIB SNMP Zabbix

Zabbix6.0.6でInterfaceのDown/Up監視設定を行う

2025年5月6日

Zabbix(ver.6.0.6)でCiscoルータのInterface状態を監視する設定を行います。
MIB値「IfOperStatus」でinterfaceのDown/Upを1分おきに監視し、状態に変化(トリガー発動)があれば、ユーザへメール通知を行うアクションを実行する設定を行います。

ホストの中に手動でアイテムとトリガーを作成する場合

インターフェース監視の1つ目の方法がホストの中に手動でアイテムとトリガーを作成する方法です。

相関図


①アイテムで設定したifOperStatusの監視にて、net.if.status[6]([]内はifIndexの値でイコールGigabitEthernet0/3)の状態が=2の時(1=up、2=down)にトリガーが発動する
②トリガー発動時に実行するオペレーション、ユーザに通知するメディアを指定
③トリガー発動時に実行するオペレーション、メディアを通知するユーザを指定
④ユーザが所属するユーザグループを確認
⑤ユーザグループ(ユーザ)に検知対象のホストへアクセスする権限があるかを確認
※仮にアクセス権がない場合、そのユーザはそのホストに関する通知を受け取る権利がないと判断されるので、アクションは実行されない

設定値

Host groups

Configuration → Host groups

設定項目設定値
Group nameSNMP_Router

Hosts

Configuration → Hosts

設定項目設定値備考
Host nameCisco-Router
 Items Interface ge3(): Operational statusName
  Type  SNMP agent
  Key  net.if.status[6]Triggerと紐付ける値、[]内はifindex値
  Type of information  Numeric(unsigned)Textにするとグラフが存在しなくなるからNG
  Host interface  192.168.9.253:161
  SNMP OID  1.3.6.1.2.1.2.2.1.8.6ifOperStatusのifindex値が6(GE0/3)
  Update interval  1mSNMPポーリング間隔
 Triggers Interface ge3(): Link downName
  Operational data  Current state:{ITEM.LASTVALUE1}
  Severity  Warningアラート発報時の重大度
  Problem exception  (last(/Cisco-Router/net.if.status[6])=2)net.if.status[6]が=2の時(1=up、2=down)に障害
  Recovery expression  (last(/Cisco-Router/net.if.status[6])=1)net.if.status[6]が=1の時(1=up、2=down)に復旧
GroupsSNMP_Router

Trigger actions

Configuration → Actions → Trigger actions

設定項目設定値備考
NameCISCO-ROUTER
Action
 Trigger Cisco-Router: Interface ge3(): Link downHostに紐づくTrigger
Operations
  Operation  Send message
  Send to users  ge3_kansi通知するUser
  Send only to  Email_ge3Userに通知するMedia type
Recovery operations
  Operation  Send message
  Send to users  ge3_kansi通知するUser
  Send only to  Email_ge3Userに通知するMedia type

Media types

Administration → Media types

設定項目設定値備考
NameEmail_ge3
Media type
 Type Email
 SMTP server mail.example.com中継サーバ
 SMTP server port  25中継サーバ
 SMTP email zabbix@example.com送信元アドレス
Message templates
 Problem障害時のメッセージ
  Message type   Problem
  Subject  Problem: {EVENT.NAME}
  Message  Problem started at {EVENT.TIME} on {EVENT.DATE}
  Problem name: {EVENT.NAME}
  Host: {HOST.NAME}
  Severity: {EVENT.SEVERITY}
  Operational data: {EVENT.OPDATA}
  Original problem ID: {EVENT.ID}
  {TRIGGER.URL}
 Problem recovery復旧時のメッセージ
  Message type  Problem recovery
  Subject  Resolved in {EVENT.DURATION}: {EVENT.NAME}
  Message  Problem has been resolved at {EVENT.RECOVERY.TIME} on {EVENT.RECOVERY.DATE}
  Problem name: {EVENT.NAME}
  Problem duration: {EVENT.DURATION}
  Host: {HOST.NAME}
  Severity: {EVENT.SEVERITY}
  Original problem ID: {EVENT.ID}
  {TRIGGER.URL}

Users

Administration → Users

設定項目設定値備考
Usernamege3_kansi
 Media
  Type  Email_ge3Media type
  Send to  sendto@test.com送信先アドレス
GroupsGuests

User groups

Administration → User groups

設定項目設定値備考
Group nameGuests
 Permissions
  Host group  SNMP_Router
  Permissions  ReadSNMP_Routerに対してRead権を付与
Usersge3_kansiメンバーを指定

ホストに既存のテンプレートを適用する場合

2つ目の方法がインターフェース監視用のテンプレートをホストに適用して、テンプレート内のディスカバリルールを使用して、自動的に検出されたインターフェースに対して監視する方法です。

Templates

Configuration → Templates

設定項目設定値備考
Template nameInterfaces by SNMPテンプレート名。プリセットが存在
 Discovery list(rule) Network interfaces discovery
  Item prototypes  Interface {#IFNAME}({#IFALIAS}): Operational status
   Type   SNMP agent
   Key   net.if.status[ifOperStatus.{#SNMPINDEX}]
   Type of information   Numeric (unsigned)
   SNMP OID   1.3.6.1.2.1.2.2.1.8.{#SNMPINDEX}
   Update interval   1m
  Trigger prototypes  Interface {#IFNAME}({#IFALIAS}): Link down
   Operational data   Current state: {ITEM.LASTVALUE1}
   Severity   Warning
   Problem expression   {$IFCONTROL:”{#IFNAME}”}=1 and last(/Interfaces by SNMP/net.if.status[ifOperStatus.{#SNMPINDEX}])=2 and (last(/Interfaces by SNMP/net.if.status[ifOperStatus.{#SNMPINDEX}],#1)<>last(/Interfaces by SNMP/net.if.status[ifOperStatus.{#SNMPINDEX}],#2))
   Recovery expression   last(/Interfaces by SNMP/net.if.status[ifOperStatus.{#SNMPINDEX}])<>2 or {$IFCONTROL:”{#IFNAME}”}=0
Problem expression/Recovery expressionについて

・<>はnot equal
・#は最新の値
#1 = 最新の値(現在の値)
#2 = 1つ前の値(直前の値)
#3 = 2つ前の値
条件①監視がON、条件②DOWN状態、条件③状態が変化した場合(#2から#1に変化)にProblem発動
条件①状態がDOWNではない、条件②監視対象から除外された場合にRecovery発動

CATEGORIES & TAGS

MIB, SNMP, Zabbix,

Author:


comment

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

関連記事

カテゴリー

むるし

フリーランスのインフラ系エンジニア。
備忘録で色々書いていきます。
お問い合わせは↓
mo-gyu@murci.net
保有:LPIC303 Security、CCNA