LoginSignup
4
3

More than 5 years have passed since last update.

Zabbix2.2(CentOS7.X)でSNMPTTを設定(Zabbix 2.2 インストール(CentOS 7.X)の続き)

Last updated at Posted at 2015-08-22

1、事前準備

■以下のファイルを対象サーバの任意の場所に配置
※本件では/tmp を使用する。
snmptt_1.4.tgz
perl-Config-IniFiles-2.83-4.1.noarch.rpm
perl-Net-SNMP-v5.0.1-1.pp-rh73.noarch.rpm

2、パッケージ のインストール

■yum からインストールを実行

# yum -y install perl-Crypt-DES perl-Digest-HMAC perl-Digest-SHA perl-Socket6 perl-Crypt-DES

# yum -y install perl-Sys-Syslog perl-List-MoreUtils perl-IO-stringy
# yum -y install net-snmp-utils net-snmp-perl perl perl-Net-SNMP perl-Config-IniFiles perl-Module-Build perl-Time-HiRes
# yum -y install perl-Digest-SHA1
# rpm -ivh perl-Config-IniFiles-2.83-4.1.noarch.rpm perl-Net-SNMP-v5.0.1-1.pp-rh73.noarch.rpm

# useradd -s /sbin/nologin snmptt

# cd /tmp
# cp -p snmptt_1.4.tgz /usr/src
# cd /usr/src
# tar xvfz snmptt_1.4.tgz

# cd snmptt_1.4

# cp ./snmptt /usr/sbin
# cp ./snmptthandler /usr/sbin/
# cp ./snmptthandler-embedded /usr/sbin/
# cp ./snmptt.ini /etc/snmp/
# cp ./snmpttconvertmib /usr/sbin/

# chmod 755 /usr/sbin/snmptt
# chmod 755 /usr/sbin/snmptthandler
# chmod 755 /usr/sbin/snmptthandler-embedded
# chmod 755 /usr/sbin/snmpttconvertmib

# mkdir /var/log/snmptt
# chown snmptt:snmptt /var/log/snmptt
# mkdir /var/spool/snmptt/
# chown snmptt:snmptt /var/spool/snmptt/

# cp snmptt-init.d /etc/rc.d/init.d/snmptt

# cd /usr/lib/systemd/system
# pwd

# touch snmptt.service
# vi snmptt.service

[Unit]
Description=SNMP Trap Translator
Wants=network-online.target
After=syslog.target network-online.target

[Service]
Environment="CONFIG=/etc/snmp/snmptt.ini"
ExecStart=/usr/sbin/snmptt -c ${CONFIG}
ExecReload=/bin/kill -HUP ${MAINPID}
Type=forking
PIDFile=/var/run/snmptt.pid
Restart=always
TimeoutStopSec=320s
KillMode=process
RestartSec=5s

[Install]
WantedBy=multi-user.target

# systemctl daemon-reload

# cd /usr/src/snmptt_1.4
# cp snmptt.logrotate /etc/logrotate.d/snmptt

3、関連ファイルの設定

■設定ファイルの編集
# cd /etc/snmp/
# vi snmptt.ini

以下の様に編集

# mode = standalone
mode = daemon

# net_snmp_perl_enable = 0
net_snmp_perl_enable = 1

# net_snmp_perl_best_guess = 0
net_snmp_perl_best_guess = 2

\# date_time_format =
date_time_format = %Y/%m/%d %Y %H:%M:%S

# sleep = 5
sleep = 1

# syslog_enable = 1
syslog_enable = 0

■メッセージファイルの編集
# vi snmptt.conf

以下の様に編集

EVENT general .* "LOGONLY" Normal
FORMAT zabbixtrap $aA $ar で未知のSNMP Trapが送信されました。$-*

■プロセスを起動
# systemctl start snmptt
# systemctl status snmptt
# systemctl enable snmptt
# systemctl is-enabled snmptt

■snmptrapdの設定を変更
# cd /etc/sysconfig/
# vi snmptrapd

以下の様に編集

OPTIONS="-m +ALL -On"

■プロセスを再起動
# systemctl restart snmptrapd
# systemctl restart snmptt

# cd /var/log/snmptt/
# touch snmptt.log
# chown snmptt:snmptt snmptt.log

■テスト
# snmptrap -v2c -c localhost '' .1.3.6.1.6.3.1.1.5.3 test i 0
# tail /var/log/snmptt/snmptt.log
※ 出力メッセージが書き足されていれば成功

おしまい

4
3
0

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
4
3