====== Zabbixでサーバ監視 ======
===== 試した環境 =====
* FreeBSD 9.2-RELEASE-p1
* Zabbix 2.2.4
* MySQL 5.6
* PHP 5.4
===== Zabbixサーバのインストール =====
sudo portmaster net-mgmt/zabbix22-server
オプションはLIBXML2, SSHを追加してみた(特に理由はない)
For Zabbix server and proxy daemons, as well as Zabbix frontend, a database is required. It is not needed to run Zabbix agent.
% cd /usr/local/share/zabbix22/server/database
PostgreSQL:
shell> psql -U
psql> create database zabbix;
psql> \q
shell> cd database/postgresql
shell> psql -U zabbix < schema.sql
shell> psql -U zabbix < images.sql
shell> psql -U zabbix < data.sql
MySQL:
shell> mysql -u -p
mysql> create database zabbix character set utf8;
mysql> quit;
shell> mysql -u -p zabbix < database/mysql/schema.sql
shell> mysql -u -p zabbix < database/mysql/images.sql
shell> mysql -u -p zabbix < database/mysql/data.sql
SQLite:
shell> cd database/sqlite3
shell> sqlite3 /var/lib/sqlite/zabbix.db < schema.sql
shell> sqlite3 /var/lib/sqlite/zabbix.db < images.sql
shell> sqlite3 /var/lib/sqlite/zabbix.db < data.sql
IBM DB2:
shell> db2 "create database zabbix using codeset utf-8 territory us pagesize 32768"
shell> cd database/ibm_db2
shell> db2batch -d zabbix -f schema.sql
shell> db2batch -d zabbix -f images.sql
shell> db2batch -d zabbix -f data.sql
Upgrade notes for 2.2.0
Minimum supported PHP version changed from 5.1.6 to 5.3.0
Minimum supported MySQL version changed from 5.0.0 to 5.0.3
Accepted data limit when using Zabbix protocol was changed from 128MB to 64MB.
New upgrade procedure
There are no upgrade SQL scripts anymore - database upgrade is performed by the Zabbix server.
To upgrade an existing database, see the scripts in
Upgrade notes for 2.2.0 https://www.zabbix.com/documentation/2.2/manual/installation/upgrade_notes_220
Please see https://www.zabbix.com/documentation/2.2/manual/installation for installation instructions.
For use NMAP please edit sudoers
という事なので、MySQLにZabbix用のDBを作る。
zabbixユーザー追加
mysql> create database zabbix character set utf8;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
flush privileges;
quit;
SQLをインポート
cd /usr/local/share/zabbix22/server/database/mysql
mysql -u zabbix -p zabbix < schema.sql
mysql -u zabbix -p zabbix < images.sql
mysql -u zabbix -p zabbix < data.sql
設定ファイルを編集
cd /usr/local/etc/zabbix22
sudo cp zabbix_server.conf.sample zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
PidFile=/var/run/zabbix/zabbix_server.pid
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
FpingLocation=/usr/local/sbin/fping
ListenIP=127.0.0.1
mkdir /var/log/zabbix /var/run/zabbix
chown zabbix:zabbix /var/log/zabbix /var/run/zabbix
echo 'zabbix_server_enable="YES"' | sudo tee -a /etc/rc.conf
sudo /usr/local/etc/rc.d/zabbix_server start
57417:20140722:165802.049 Starting Zabbix Server. Zabbix 2.2.4 (revision 46772).
57417:20140722:165802.049 ****** Enabled features ******
57417:20140722:165802.049 SNMP monitoring: YES
57417:20140722:165802.049 IPMI monitoring: NO
57417:20140722:165802.049 WEB monitoring: YES
57417:20140722:165802.049 VMware monitoring: YES
57417:20140722:165802.049 Jabber notifications: YES
57417:20140722:165802.050 Ez Texting notifications: YES
57417:20140722:165802.050 ODBC: YES
57417:20140722:165802.050 SSH2 support: YES
57417:20140722:165802.050 IPv6 support: YES
57417:20140722:165802.050 ******************************
57417:20140722:165802.050 using configuration file: /usr/local/etc/zabbix22/zabbix_server.conf
57417:20140722:165802.162 current database version (mandatory/optional): 02020000/02020001
57417:20140722:165802.162 required mandatory version: 02020000
57418:20140722:165802.208 server #1 started [configuration syncer #1]
57419:20140722:165802.208 server #2 started [db watchdog #1]
57427:20140722:165802.212 server #10 started [trapper #2]
===== Zabbixフロントエンドのインストール =====
sudo portmaster net-mgmt/zabbix22-frontend
この時、PHP GDのインストールが走った場合「Enable JIS-mapped Japanese font support」オプションは付けない事。
Zabbixが生成するグラフ内の日本語が文字化けしてしまうので。
cd /usr/local/etc
sudo cp php.ini-development php.ini
sudo chmod +w php.ini
sudo emacs php.ini
cd /usr/local/www/zabbix22
sudo ln -s /usr/local/share/font-migmix/migmix-1m-regular.ttf fonts/MigMix-1M-R.ttf
sudo chmod +w include/defines.inc.php
sudo emacs include/defines.inc.php
{{ :freebsd:zabbix:install_zabbix_frontend_1.jpg |}}
{{ :freebsd:zabbix:install_zabbix_frontend_2.jpg |}}
{{ :freebsd:zabbix:install_zabbix_frontend_3.jpg |}}
{{ :freebsd:zabbix:install_zabbix_frontend_4.jpg |}}
{{ :freebsd:zabbix:install_zabbix_frontend_5.jpg |}}
{{ :freebsd:zabbix:install_zabbix_frontend_6.jpg |}}
{{ :freebsd:zabbix:install_zabbix_frontend_7.jpg |}}
{{ :freebsd:zabbix:login_zabbix_frontend.jpg |}}
設定>ホスト>ホストの作成でホストを追加
ホスト名は後にインストールするZabbixエージェントでの値と一致させなければならない。
===== Zabbixエージェントのインストール =====
cd /usr/local/etc/zabbix22/
sudo cp zabbix_agentd.conf.sample zabbix_agentd.conf
sudo emacs zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
Server=127.0.0.1
ListenIP=127.0.0.1
Hostname=Freyja
echo 'zabbix_agentd_enable="YES"' | sudo tee -a /etc/rc.conf
===== 参考サイト =====
* [[http://freebsd.fkimura.com/zabbix-a0.html|統合監視ツールZabbixを試すメモ [FreeBSD](fkimura.com)]]
* [[http://freebsd.fkimura.com/zabbix-a1.html|Zabbixのウェブ管理画面導入・設定 [FreeBSD](fkimura.com)]]
* [[http://www.adminweb.jp/apache/php/index2.html|拡張子の登録 - PHP利用のための設定 - Apache入門]]
* [[http://kanjuku-tomato.blogspot.jp/2013/07/php-gdjis-mapped-japanese-font.html|PHP GDの"JIS-mapped Japanese font support"オプションが有効になっている場合にZabbixグラフの日本語文字が文字化けする - 完熟トマト]]