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 <username> psql> create database zabbix; psql> \q shell> cd database/postgresql shell> psql -U <username> zabbix < schema.sql shell> psql -U <username> zabbix < images.sql shell> psql -U <username> zabbix < data.sql MySQL: shell> mysql -u<username> -p<password> mysql> create database zabbix character set utf8; mysql> quit; shell> mysql -u<username> -p<password> zabbix < database/mysql/schema.sql shell> mysql -u<username> -p<password> zabbix < database/mysql/images.sql shell> mysql -u<username> -p<password> 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
設定>ホスト>ホストの作成でホストを追加 ホスト名は後にインストールする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