プラグインインストール

プラグインを利用するためには、プラグインを利用するための「Plugin Architecture」と呼ばれるパッチを適用する必要があります。このパッチはパッケージ化されていないため、手動でダウンロード・適用する必要があります。
また、プラグインを利用する場合は、Cacti のインストールをパッケージから行わずに直接配置した方が簡単に適用できます。
※現状 0.8.7 系ではプラグインを利用するためにプラグインアーキテクチャというパッケージ(パッチ)をインストールする必要がありますが、0.8.8(2008年3Qリリース予定) からは Cacti 自体に組み込まれる予定です。

Plugin Architecture のダウンロード

下記のページから Plugin Architecture をダウンロード
http://cactiusers.org/downloads/patches/

 $ cd <適当な作業用ディレクトリ>
 $ wget http://cactiusers.org/downloads/cacti-plugin-arch.zip

Plugin Architecture の適用

 $ unzip cacti-plugin-arch.zip

※インストールの詳細は展開した中にある Readme.txt を参照
※または、下記のページを参照
http://cactiusers.org/wiki/PluginArchitectureInstall

  • パッチファイルのコピー

Debian にて Cacti のコンテンツがインストールされるのは /usr/share/cacti/siteなので、ここに、プラグイン用のパッチをコピーする。

 # cp cacti-plugin-0.8.7a-PA-v1.4.diff 
  • パッチの適用


# patch -p1 -N < cacti-plugin-0.8.7a-PA-v1.4.diff
patching file auth_changepassword.php
patching file auth_login.php
patching file data_sources.php
patching file graph_image.php
patching file graph.php
patching file graphs_new.php
patching file graphs.php
patching file host.php
patching file include/auth.php
patching file include/global_arrays.php
patching file include/global_form.php
patching file include/global.php
patching file include/global_settings.php
patching file include/plugins.php
patching file include/top_graph_header.php
patching file include/top_header.php
patching file index.php
patching file lib/api_device.php
patching file lib/functions.php
Hunk #1 succeeded at 1528 (offset 52 lines).
Hunk #3 succeeded at 1618 (offset 52 lines).
patching file lib/html_form.php
patching file lib/html.php
patching file lib/html_tree.php
patching file lib/poller.php
patching file lib/rrd.php
patching file lib/variables.php
patching file plugins/index.php
patching file poller.php
patching file user_admin.php
patching file utilities.php

  • Config ファイルの修正
 # cd /var/www/cacti/include
 # vi global.php
 下記の行を見つけて、実際のパスを入力する(/cacti/)など
 $config['url_path'] = '/';

Debian パッケージでインストール

パッケージ

パッケージ名 説明
cacti cacti のパッケージ
cacti-cactid C で書かれた poller プログラムで、通常のものより軽く高速

その他依存パッケージ

パッケージリストの更新

 # apt-get update

パッケージ確認

 # apt-cache search cacti
 cacti - Frontend to rrdtool for monitoring systems and services
 cacti-cactid - Multi-Threading poller for cacti

2008年1月現在では上記二つのパッケージがある。

パッケージの依存関係確認

 # apt-cache show cacti
 # apt-cache show cacti-cactid

cacti インストール

 # apt-get install cacti

依存するパッケージもインストールされる

cacti-cactid インストール

 # apt-get install cacti-cactid

MySQL 設定

通常インストール後に MySQL 上にデータベースを作成する必要がありますが、 Debian Package の場合自動的にデータベースの作成まで行ってくれます。データベース名やアカウント・パスワードは下記のファイルに記述されます。

 /etc/cacti/debian.php
 /etc/cacti/cactid.conf

Apache 設定

下記の設定ファイルに記述されています。

 /etc/cacti/apache.conf

RPM でのインストール

パッケージ
  • 主に必要な rpm パッケージ
パッケージ名 今回インストールしたパッケージバージョン
httpd 2.2.3-11.el5.centos
php 5.1.6-15.el5
php-mysql 5.1.6-15.el5
php-snmp 5.1.6-15.el5
mysq 5.0.22-2.2.el5_1.1
mysql-server 5.0.22-2.2.el5_1.1
net-snmp 5.3.1-19.el5_1.3
rrdtool 1.2.23-1.el5.rf
cacti 0.8.7a-1.el5.rf
cacti-cactid(cacti-spine) 0.8.7-1.el5.rf

yum を使ったインストール


# yum install httpd
# yum install php
# yum install php-mysql
# yum install php-snmp
# yum install mysql
# yum install mysql-server
# yum install net-snmp

Cacti インストール

rrdtoolcactiCentOS のパッケージサーバから提供されていないため、rpmforge から直接 rpm ファイルを取得するか、yum にレポジトリを追加するかして取得します。
rpmforge を使うには、rpmforge-release package をインストールする必要があります。

 # wget http://apt.sw.be/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
 # rpm -Uhv rpmforge-release-0.3.6-1.el5.rf.i386.rpm
 http://dag.wieers.com/rpm/FAQ.php#B1
 # yum install rrdtool
  • cacti インストール
 # yum install cacti

rrdtool の際と同様に rpmforge の設定を行っておく必要があります。

  • cactid(spine) インストール
 # yum install cacti-cactid
 もしくは
 # yum install cacti-spine

rrdtool の際と同様に rpmforge の設定を行っておく必要があります。
※不必要なパッケージがインストールされてしまう前に rrdtoolcacti をインストールした後は rpmforge の設定を解除したほうがいいと思われます。

Official Patch

下記のページからパッチをダウンロード
http://www.cacti.net/download_patches.php

 # cd /var/www/cacti
 # wget http://www.cacti.net/downloads/patches/0.8.7a/graph-issue-wrra-specs.patch
 # wget http://www.cacti.net/downloads/patches/0.8.7a/cmd-php-non-unique-hosts.patch
 # patch -p1 -N < graph-issue-wrra-specs.patch
 patching file lib/functions.php
 # patch -p1 -N < cmd-php-non-unique-hosts.patch
 patching file cmd.php

MySQL DB 作成

 # /etc/init.d/mysql start
  • root アカウント設定
 ※ここからは root でも user でも実施可能
 $ mysqladmin --user=root password 
 $ mysqladmin --user=root --password reload
 Enter password:  <--設定したパスワードを入力
 $ mysqladmin -p --user=root create cacti
 Enter password:  <--root のパスワードを入力
 $ cd /var/www/cacti
 $ mysql -p --user=root cacti < cacti.sql
 Enter password: <--root のパスワードを入力
  • cacti 用のユーザ作成


$ mysql --user=root -p mysql
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 50 to server version: 5.0.22

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

mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cacti';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

  • cacti の設定ファイル編集
 # cd /var/www/cacti/include
 # vi config.php
 $database_type = "mysql";
 $database_default = "cacti";
 $database_hostname = "localhost";
 $database_username = "cactiuser";
 $database_password = "cacti";
  • Spine(cactid) の設定ファイル編集
 # vi /etc/spine.conf
 spine の config も cacti と同様に設定
 DB_Host         localhost
 DB_Database     cacti
 DB_User         cactiuser
 DB_Pass         cacti
 DB_Port         3306

httpd 設定

 # cd /etc/httpd/conf.d
 # vi cacti.conf
 下記の行をコメントアウト
 #       deny from all
 #       allow from 127.0.0.1
 下記の行を追加
        allow from all
 ※ httpd の再起動 or reload を行ってください。
 # /etc/init.d/httpd restart

ブラウザでの動作確認

ここまで設定すれば、ブラウザから閲覧可能です。
ブラウザから対象ノードを開いてみてください。
標準のログインアカウントとパスワードは共に admin です。
※もし閲覧できない場合は httpd の error.log を確認してください。
SELinux を稼動させていると、PHP にてエラーが発生します。

インストール

cacti のインストールには MySQL, PHP, RRDTool, net-snmp, Apache or IIS が必要となります。
それぞれのソフトについて cacti の動作が確認されているバージョンは下記のページを参照してください。

http://cacti.net/downloads/docs/html/requirements.html

また、マニュアルは下記のページを参照してください。

http://cacti.net/downloads/docs/html/index.html

概要

cacti のインストールは非常に簡単です。cacti 自体は PHP をベースとしたファイル群なので、動作に必要な環境が整っていれば、cacti のファイル群を Web サーバ上のドキュメントルート以下に配置し、MySQL にデータベースを作成するだけで完了です。
下記の章にて具体的名インストール例を記載します。
※各アプリケーションのバージョンにより違いがあるかもしれませんので、マニュアルや readme を確認してください。

ディレクトリ構造

Cactiディレクトリで知っておくべきものは下記の通りです。

動作概要

Cacti は、PHP のファイル群で、Web ページ上でグラフを取得する設定やグラフの描画を行います。設定やグラフ表示は HTTP または HTTPS 経由で行います。

グラフ化するために必要なデータは RRDTool に蓄積し、デバイスと呼ばれるデータの取得対象の情報や、表示などの設定情報は MySQL に登録して稼動します。

通常 cron にて 5 分間隔でデータの取得を行います。