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 name | SNMP_Router |
Hosts
Configuration → Hosts
設定項目 | 設定値 | 備考 |
Host name | Cisco-Router | |
Items | Interface ge3(): Operational status | Name |
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.6 | ifOperStatusのifindex値が6(GE0/3) |
Update interval | 1m | SNMPポーリング間隔 |
Triggers | Interface ge3(): Link down | Name |
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)に復旧 |
Groups | SNMP_Router |
Trigger actions
Configuration → Actions → Trigger actions
設定項目 | 設定値 | 備考 |
Name | CISCO-ROUTER | |
Action | ||
Trigger | Cisco-Router: Interface ge3(): Link down | Hostに紐づくTrigger |
Operations | ||
Operation | Send message | |
Send to users | ge3_kansi | 通知するUser |
Send only to | Email_ge3 | Userに通知するMedia type |
Recovery operations | ||
Operation | Send message | |
Send to users | ge3_kansi | 通知するUser |
Send only to | Email_ge3 | Userに通知するMedia type |
Media types
Administration → Media types
設定項目 | 設定値 | 備考 |
Name | Email_ge3 | |
Media type | ||
Type | ||
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
設定項目 | 設定値 | 備考 |
Username | ge3_kansi | |
Media | ||
Type | Email_ge3 | Media type |
Send to | sendto@test.com | 送信先アドレス |
Groups | Guests |
User groups
Administration → User groups
設定項目 | 設定値 | 備考 |
Group name | Guests | |
Permissions | ||
Host group | SNMP_Router | |
Permissions | Read | SNMP_Routerに対してRead権を付与 |
Users | ge3_kansi | メンバーを指定 |
ホストに既存のテンプレートを適用する場合
2つ目の方法がインターフェース監視用のテンプレートをホストに適用して、テンプレート内のディスカバリルールを使用して、自動的に検出されたインターフェースに対して監視する方法です。
Templates
Configuration → Templates
設定項目 | 設定値 | 備考 |
Template name | Interfaces 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発動