LoginSignup
12
20

More than 3 years have passed since last update.

Zabbix4.0でSNMPトラップを監視

Last updated at Posted at 2019-02-18

環境

  • Zabbix4.0
  • CentOS7.5 minimal

Zabbixサーバー(ホストOS)の設定

  • SELinux = disabled
  • Firewallで開けてるポート = 80/tcp,443/tcp,162/udp

インストールするもの

  • epel-release
  • snmptt
  • net-snmp-perl
  • perl-Sys-Syslog

SNMP TrapをZabbixで監視する流れ

  1. ZABBIXサーバー(ホストOS)のSNMPTrapdでトラップを受け取る
  2. SNMPTrapdで受け取ったトラップはSNMPTTによってZABBIXに渡せるデータフォーマットに変換
  3. SNMPTTのlogに変換されたSNMPTrapをZABBIXが読み取る

やること

SNMPTrapdで受信したSNMPTrapをSNMPTTに渡すように設定

/etc/snmp/snmptrapd.conf
OPTIONS="-Ls6 -p /var/run/snmptrapd.pid"

SNMPTTに渡すSNMPTrapをOIDからシンボル名に変更しないように設定

/etc/snmp/snmptt.ini
mode = daemon
net_snmp_perl_enable = 1
net_snmp_perl_best_guess = 2
date_time_format = %Y/%m/%d %H:%M:%S
log_file = /var/log/snmptt/snmptt.log
mibs_environment = ALL

Zabbixに表示するSNMPTrapフォーマットをとりあえず適当に

/etc/snmp/snmptt.conf
EVENT general .* "General event" Normal
FORMAT ZBXTRAP $aA $*

ZabbixからSNMPTTを見れるようにConfig設定

/etc/zabbix/zabbix_server.conf
SNMPTrapperFile=/var/log/snmptt/snmptt.log
StartSNMPTrapper=1

設定の反映

$ systemctl enable snmptrapd
$ systemctl start snmptrapd
$ systemctl enable snmptt
$ systemctl start snmptt
$ systemctl restart zabbix-server

確認

SNMPTrap自体が受け取れているかどうか

$ tail -f /var/log/messages

SNMPTTで認識されているか

$ tail -f /var/log/snmptt/snmptt.log

*このファイルが無い場合はSNMPTrapを読み取れてません。SNMPTTで読み取れているとこのファイルは自動生成されます。

ローカルホスト上で適当にSNMPTrapを送ってみる

$ snmptrap -v 2c -c public 127.0.0.1 '' .1.3.6.1.4.1.8072.9999 .1.3.6.1.4.1.8072.9999 s 'TEST'

以上でサーバー側の設定は完了。
あとはZabbixのWebUI上で監視設定するだけです。

12
20
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
20