harumaki.net

インフラ屋の覚書や、ラーメン食べある記とか。

GNU/Linux infra サーバー監視 運用

ZABBIXインストール(1.0)

投稿日:2005年3月23日

Last Updated on 2022年3月13日 by かんりにん

[pukiwiki]
 
システム監視ツールzabbixのインストールドキュメント。

【本家サイト】

http://www.zabbix.com/

日本語の情報はほとんどないので、サイトからダウンロードした
マニュアルPDFをもとにインストール作業を行う。sudo が面倒だったので全部rootで(汗

PDF:http://www.zabbix.com/Zabbix%20Manual.pdf

***1)ダウンロードと展開

[root@example httpd]# cd /usr/local/src/
[root@example src]# wget http://jaist.dl.sourceforge.net/sourceforge/zabbix/zabbix-1.0.tar.gz
[root@example zabbix-1.0]# ls -al
合計 360
drwxr-xr-x 11 user users 4096 3月 23 2004 .
drwxrwxrwx 32 root root 4096 3月 14 13:21 ..
-rw-r–r– 1 user users 185 2月 18 2002 AUTHORS
-rw-r–r– 1 user users 18006 12月 8 2001 COPYING
-rw-r–r– 1 user users 49587 3月 21 2004 ChangeLog
-rw-r–r– 1 user users 55 12月 8 2001 INSTALL
-rw-r–r– 1 user users 8827 2月 23 2002 Makefile.in
-rw-r–r– 1 user users 50 3月 28 2001 NEWS
-rw-r–r– 1 user users 68 3月 6 2004 README
-rw-r–r– 1 user users 2080 8月 11 2003 acconfig.h
drwxr-xr-x 2 user users 4096 3月 23 2004 autom4te.cache
drwxr-xr-x 2 user users 4096 3月 23 2004 bin
-rwxr-xr-x 1 user users 180006 3月 23 2004 configure
-rw-r–r– 1 user users 19054 2月 27 2004 configure.in
drwxr-xr-x 5 user users 4096 3月 23 2004 create
drwxr-xr-x 2 user users 4096 3月 23 2004 doc
drwxr-xr-x 3 user users 4096 3月 23 2004 frontends
drwxr-xr-x 2 user users 4096 3月 23 2004 include
drwxr-xr-x 6 user users 4096 3月 23 2004 misc
drwxr-xr-x 7 user users 4096 3月 23 2004 src
drwxr-xr-x 3 user users 4096 3月 23 2004 upgrades
-rw-r–r– 1 user users 4459 6月 19 2003 zabbix.spec

インストールドキュメントがdoc/にあるが
サイトからダウンロードしてもOK。

***2)コンパイルとインストール

ここから先はマニュアルPDFをみながら作業を実施。

 zabbixはDBにMysqlとpostglesqlを選べる。
 今回は他のアプリケーションでも使っているMysqlを使用。
 コンパイル前に各DB用の設定ファイルを編集。

▼MysqlにDBを作成。

[root@example zabbix-1.0]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1298 to server version: *****

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> create database zabbix;
Query OK, 1 row affected (0.02 sec)

mysql> quit
Bye
[root@example zabbix-1.0]#

▼コンパイルとインストール

configureオプションに–with-mysqlを追加。
postgreSQLの場合も同様。

[root@example zabbix-1.0]# ./configure –with-mysql –with-net-snmp
[root@example zabbix-1.0]# make
[root@example zabbix-1.0]# ls -al
合計 484
drwxr-xr-x 11 root root 4096 3月 14 13:39 .
drwxrwxrwx 32 root root 4096 3月 14 13:21 ..
-rw-r–r– 1 root root 185 2月 18 2002 AUTHORS
-rw-r–r– 1 root root 18006 12月 8 2001 COPYING
-rw-r–r– 1 root root 49587 3月 21 2004 ChangeLog
-rw-r–r– 1 root root 55 12月 8 2001 INSTALL
-rw-r–r– 1 root root 8891 3月 14 13:39 Makefile
-rw-r–r– 1 root root 8827 2月 23 2002 Makefile.in
-rw-r–r– 1 root root 50 3月 28 2001 NEWS
-rw-r–r– 1 root root 68 3月 6 2004 README
-rw-r–r– 1 root root 2080 8月 11 2003 acconfig.h
drwxr-xr-x 2 root root 4096 3月 23 2004 autom4te.cache
drwxr-xr-x 2 root root 4096 3月 14 13:41 bin
-rw-r–r– 1 root root 69848 3月 14 13:39 config.log
-rwxr-xr-x 1 root root 35198 3月 14 13:39 config.status
-rwxr-xr-x 1 root root 180006 3月 23 2004 configure
-rw-r–r– 1 root root 19054 2月 27 2004 configure.in
drwxr-xr-x 5 root root 4096 3月 23 2004 create
drwxr-xr-x 2 root root 4096 3月 23 2004 doc
drwxr-xr-x 3 root root 4096 3月 23 2004 frontends
drwxr-xr-x 2 root root 4096 3月 14 13:39 include
drwxr-xr-x 6 root root 4096 3月 23 2004 misc
drwxr-xr-x 7 root root 4096 3月 23 2004 src
drwxr-xr-x 3 root root 4096 3月 23 2004 upgrades
-rw-r–r– 1 root root 4459 6月 19 2003 zabbix.spec

▼DBにスキーマをインポート。

対象ファイルは
$ZBBIXHOMEcreate/mysql/schema.sql
$ZBBIXHOMEcreate/data/data.sql

[root@example zabbix-1.0]# cd create/mysql/
[root@example mysql]# cat schema.sql | mysql -uroot -p zabbix
Enter password:
[root@example mysql]# cd ../data/
[root@example data]# cat data.sql | mysql -uroot -p zabbix
Enter password:
[root@example data]#

▼インポート後、テーブルを確認。

[root@example data]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1304 to server version: 3.23.58

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> use zabbix
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+——————+
| Tables_in_zabbix |
+——————+
| actions |
| alarms |
| alerts |
| config |
| functions |
| graphs |
| graphs_items |
| groups |
| history |
| history_str |
| hosts |
| hosts_groups |
| items |
| media |
| media_type |
| profiles |
| rights |
| screens |
| screens_items |
| service_alarms |
| services |
| services_links |
| sessions |
| stats |
| sysmaps |
| sysmaps_hosts |
| sysmaps_links |
| trends |
| trigger_depends |
| triggers |
| users |
| users_groups |
| usrgrp |
+——————+
33 rows in set (0.00 sec)

mysql> quit
Bye
[root@example data]#

▼ディレクトリをコピー

ホームディレクトリを/usr/local/zabbixにする。
特に指定がないようなので、基本的にコンパイルしたディレクトリを全コピー。
※シンボリックリンクを張っても良いが、元ファイルを残しておいてもいいかなと。

[root@example src]# cp -pr zabbix-1.0 ../zabbix

***3)サーバ設定

▼プロセスが使用するポートを登録

[root@example data]# cd /etc/
[root@example etc]# cp services services.20050314
[root@example etc]# vi services

《追記箇所》

デフォルトのポートは

zabbix_agent 10000/tcp
zabbix_trap 10001/tcp

となっているが、10000番はWebminに使用しているので
以下のとおりに変更。

zabbix_agent 10002/tcp # zabbix agent
zabbix_trap 10003/tcp # zabbix trap

▼inetdへ登録

/etc/inetd.confへ追記。
RHL9なので、代わりにxinetd.confに記述。

《追記箇所》

zabbix_trap stream tcp nowait.3600 zabbix /usr/local/zabbix/bin/zabbix_trapper

追記が完了したらxinetdを再起動。
[root@example etc]# /etc/init.d/xinetd restart
xinetdを停止中: [ OK ]
xinetdを起動中: [ OK ]

▼設定ファイルをコピー&編集

設定ファイルは$ZABBIXHOME/misc/conf/以下にあるファイル。
これらを/etc/zabbixへコピーして編集する。
zabbixはデフォルトでコンフィグファイルを/etc/zabbix/から
読み込むようになっている。

※理由は不明だが、$ZABBIXHOME/misc/にinetdディレクトリがあり
 chkconfigへ登録してパッケージ的にデーモンの管理が出来る様子。
 ここいらが理由か?

[root@example zabbix]# mkdir /etc/zabbix
[root@example zabbix]# cp misc/conf/* /etc/zabbix/

[root@example zabbix]# cd /etc/zabbix/
[root@example zabbix]# vi zabbix_agent.conf
[root@example zabbix]# vi zabbix_agentd.conf
[root@example zabbix]# vi zabbix_suckerd.conf
[root@example zabbix]# vi zabbix_trapper.conf
[root@example zabbix]# vi zabbix_trapperd.conf

※zabbix_agent.confは特に編集は不要?(←要確認)

”《記述箇所》”

基本的に全ファイルで同じ箇所を追記する。
・/etc/servicesで指定したポートを書き込む。
 またMysqlのパスワードを追記。

-zabbix_agentd.conf
 ポート番号を変更

ListenPort=10000

ListenPort=10002

-zabbix_suckerd.conf
 Mysqlのパスワードを記入

DBPassword=←パスワードを記入

-zabbix_trapper.conf
 Mysqlのパスワードを記入

DBPassword=←パスワードを記入

-zabbix_trapperd.conf

-1:ポート番号を変更

ListenPort=10001

ListenPort=10003

-2:Mysqlのパスワードを記入

DBPassword=←パスワードを記入

***4)GUI設定

▼GUI用ファイルをコピー&編集

[root@example include]# mkdir -p /var/www/html/zabbix/html/
[root@example zabbix]# cp -R frontends/php/* /var/www/html/zabbix/html/

[root@example include]# cp db.inc.php db.inc.php.org
[root@example include]# vi db.inc.php

”《記述箇所》”
ここにもMysqlのパスワードを記入

$DB_PASSWORD =””; ←パスワードを記入

***5)起動

【通常起動】

[zabbix@example zabbix]$ cd /usr/local/zabbix/
[zabbix@example zabbix]$ cd bin/
[zabbix@example bin]$ ./zabbix_trapper
[zabbix@example bin]$ ./zabbix_trapperd
[zabbix@example bin]$ ./zabbix_agentd
[root@example bin]# ps -aef | grep zabbix
zabbix 31672 1 0 17:14 ? 00:00:00 ./zabbix_agentd
zabbix 31673 31672 0 17:14 ? 00:00:00 ./zabbix_agentd
zabbix 31674 31672 0 17:14 ? 00:00:00 ./zabbix_agentd
zabbix 31675 31672 0 17:14 ? 00:00:00 ./zabbix_agentd
zabbix 31676 31672 0 17:14 ? 00:00:00 ./zabbix_agentd
zabbix 31677 31672 0 17:14 ? 00:00:00 ./zabbix_agentd
zabbix 31690 1 1 17:14 ? 00:00:00 ./zabbix_suckerd
zabbix 31692 31690 0 17:14 ? 00:00:00 ./zabbix_suckerd
zabbix 31693 31690 0 17:14 ? 00:00:00 ./zabbix_suckerd
zabbix 31694 31690 0 17:14 ? 00:00:00 ./zabbix_suckerd
zabbix 31695 31690 0 17:14 ? 00:00:00 ./zabbix_suckerd
zabbix 31848 1 0 17:14 ? 00:00:00 ./zabbix_trapperd
root 32136 27779 0 17:14 pts/2 00:00:00 grep zabbix

なお、/usr/local/zabbix/misc/init.d/に
debianとredhat用にinit.dで実行できるスクリプトがある。
(但しredhat用は8.0だけど、それ以降のバージョンでも使用可能)

***【init.dでのプロセス操作】

-1:スクリプトを/etc/rc.d/init.d/へコピー
ファイルは/usr/local/zabbix/misc/init.d/redhat/8.0/にある。

[root@example include]# cd /usr/local/zabbix/misc/init.d/redhat/8.0/
[root@example 8.0]# cp zabbix_* /etc/rc.d/init.d/
[root@example 8.0]# cd /etc/rc.d/init.d/
[root@example init.d]# chmod 755 zabbix_*

-2:init.dから起動

※通常起動している場合は停止もできる。
 他のコマンドも同様。

[root@example init.d]# /etc/rc.d/init.d/zabbix_agentd start
zabbix_agentdを起動中: [ OK ]
[root@example init.d]#

ちなみに使用できるコマンドは以下のような感じ。

[root@example init.d]# /etc/rc.d/init.d/zabbix_agentd –help
Usage: /etc/rc.d/init.d/zabbix_agentd {start|stop|restart|condrestart}

-3:chkconfigへ登録。

これでOSブート時の自動起動もOK。

[root@example init.d]# chkconfig –add zabbix_agentd
[root@example init.d]# chkconfig –add zabbix_suckerd
[root@example init.d]# chkconfig –add zabbix_trapperd
[root@example init.d]#
[root@example init.d]# chkconfig –list | grep zabbix
zabbix_agentd 0:オフ 1:オフ 2:オフ 3:オフ 4:オフ 5:オフ 6:オフ

[/pukiwiki]

-GNU/Linux, infra, サーバー監視, 運用
-

執筆者:


comment

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA


関連記事

no image

超久々にmuninをインストール

[pukiwiki] 新規システムを作ったので、それに合わせてかれこれ5~6年ぶり位にmuninのインストールを。 サーバーはCentOS6.*。 *1)rrdtoolのアップデート デフォルトリポジ …

no image

net-snmp snmpd.logの設定を追加、変更

[pukiwiki] 某VPSサービスで借りた仮想サーバーでsnmpdを動かしたところ、ログがどこにも出ていなかったのでログ出力設定を追加。 たまたまだと思いつつ、設定状況は環境によって様々だと思うの …

no image

VMware Management Interface インストール

[pukiwiki] *▼VMware Management Interface インストール 2006/09/20 VMware server console のほか、ブラウザからステータス情報の表 …

no image

postfix設定変更(inet_protocols)

参考:お世話になっております。 Postfix IPv6サポート http://www.postfix-jp.info/trans-2.2/jhtml/IPV6_README.html EC2のCen …

no image

OpenSSHのMatchディレクティブを利用したアクセスコントロール

OpenSSH4.4以上で利用できるようになったMatch(条件分岐)ディレクティブを使った、アクセスコントロールを検証。 参考:お世話になっております! OpenSSH-5.9p1 日本語マニュアル …

宅麺