Help us understand the problem. What is going on with this article?

FreeBSDでZABBIX3を動かす

More than 1 year has passed since last update.

前提環境

LinuxでDocker使うと簡単に環境作れるのは分かってるけど、FreeBSD使いたいので、ちまちまと。
2017/9/21 追記:SNMP Trapを受けられるように変更
2018/7/25 追記:fping 4.0からIPv4/IPv6どちらもサポートするようになり、JailのネットワークI/FにIPv6アドレスを付けないと動作しないため、その部分を追記

  • OS
    • FreeBSD 11.1R
    • qjail
  • IPアドレス

    • 192.168.10.121を想定
  • データベース

    • MySQL(別サーバで構築済みを想定)
    • 192.168.10.120を想定
    • innodb_file_per_table オプションが必要な事を忘れない事!
  • Webサーバ

    • lighttpd

ホストの設定

# sysctl security.jail.sysvipc_allowed=1
# sysrc jail_sysvipc_allow=YES

Jailを作る

# qjail create -4 192.168.10.121 -6 fe80::121 -n hn0 zabbix
# qjail config -y zabbix
# qjail config -k zabbix

これ以降はJailの中の操作

インストール

# pkg install zabbix3-server
# pkg install zabbix3-frontend
# pkg install zabbix3-agent
# pkg install lighttpd
# pkg install ja-font-ipa-uigothic

設定

PHP

# cp -p /usr/local/etc/php.ini-production /usr/local/etc/php.ini

変更箇所のみ

php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Tokyo
always_populate_raw_post_data = -1

ZABBIX Server

# cd /usr/local/share/zabbix3/server
# mysql -h 192.168.10.120 -uzabbix3 -p zabbix3 < database/mysql/schema.sql
# mysql -h 192.168.10.120 -uzabbix3 -p zabbix3 < database/mysql/images.sql
# mysql -h 192.168.10.120 -uzabbix3 -p zabbix3 < database/mysql/data.sql

# cd /usr/local/etc/zabbix3/
# cp zabbix_server.conf.sample zabbix_server.conf

変更箇所のみ
別で構築済みのMySQLサーバの情報を設定

zabbix_server.conf
LogFile=/var/log/zabbix_server.log
DBHost=192.168.10.120
DBName=zabbix3
DBUser=zabbix3
DBPassword=foobar
Fping6Location=/usr/local/sbin/fping6
FpingLocation=/usr/local/sbin/fping
ListenIP=192.168.10.121
# sysrc zabbix_server_enable=YES
# touch /var/log/zabbix_server.log
# chown zabbix:zabbix /var/log/zabbix_server.log
# service zabbix_server start

# cd /usr/local/www/zabbix3/fonts/
# ln -s /usr/local/share/font-ipa-uigothic/ipagui.ttf ipagui.ttf
/usr/local/www/zabbix3/include/defines.inc.php
define('ZBX_GRAPH_FONT_NAME', 'ipagui');

ZABBIX Agent

# cd /usr/local/etc/zabbix3
# cp zabbix_agentd.conf.sample zabbix_agentd.conf

変更箇所のみ

zabbix_agentd.conf
LogFile=/var/log/zabbix_agentd.log
Server=192.168.10.121
# sysrc zabbix_agentd_enable=YES
# touch /var/log/zabbix_agentd.log
# chown zabbix:zabbix /var/log/zabbix_agentd.log
# service zabbix_agentd start

lighttpd

変更箇所のみ

lighttpd.conf
var.log_root    = "/var/log/lighttpd"
server.use-ipv6 = "disable"
server.bind = "192.168.10.121"
server.document-root = "/usr/local/www/zabbix3/"
$SERVER["socket"] == "192.168.10.121:80" { }
modules.conf
include "conf.d/fastcgi.conf"
conf.d/fastcgi.conf
fastcgi.server = ( ".php" =>
                   ( "php-local" =>
                     (
                       "socket" => socket_dir + "/php-fastcgi-1.socket",
                       "bin-path" => "/usr/local/bin/php-cgi",
                       "max-procs" => 1,
                       "broken-scriptfilename" => "enable",
                     )
                   ),
)
# mkdir -p /var/spool/lighttpd/sockets/
# sysrc lighttpd_enable=YES
# service lighttpd start

ZABBIX Frontendの設定

  • http://192.168.10.121/ へアクセス
  • データベース名・ユーザ名・パスワードなどを入力(別で構築済みのMySQLサーバの情報を設定)

ZABBIX Frontendへアクセス

あとは普通にZABBIXを設定

SNMP Trapを受けられるようにする

# cd ~
# fetch http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.2.2/zabbix-3.2.2.tar.gz/download
# tar xvzf download
# rm download
# cd zabbix-3.2.2/
# cp misc/snmptrap/zabbix_trap_receiver.pl /usr/local/share/zabbix3/
# chmod 755 /usr/local/share/zabbix3/zabbix_trap_receiver.pl
# sysrc snmptrapd_enable=YES
/usr/local/share/zabbix3/zabbix_trap_receiver.pl
$SNMPTrapperFile = '/var/log/zabbix_snmptrap.log';
/usr/local/share/snmp/snmptrapd.conf
authCommunity log,execute,net private
authCommunity log,execute,net public

perl do "/usr/local/share/zabbix3/zabbix_trap_receiver.pl"

disableAuthorization yes
pidfile /var/run/snmptrapd.pid
donotlogtraps no
logoption f /var/log/snmptrap.log
/usr/local/etc/zabbix3/zabbix_server.conf
SNMPTrapperFile=/var/log/zabbix_snmptrap.log
StartSNMPTrapper=1
# service snmptrapd start

SNMP Trapのテンプレートを作成し、該当ホストへ適用
- https://gist.github.com/tatsuyaueda/dabe513853f49f07527f9ef120e1374b

ZABBIXの監視データ→最新データでSNMP Trapの情報が確認出来ればOK

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした