FreeBSD/cacti

cacti

MRTGと同じように、SNMPエージェントが取得した値や、
プログラム/スクリプトの出力結果をグラフ化することが出来ます。

MRTGよりも優れている点はいくつもあります

サンプル

http://ma21.ath.cx/cacti/index.php

ID:   guest
PASS: guest

phpの再コンパイル

下記のオプションを追加して再コンパイル、インストール

--enable-sockets 
--with-snmp 
--with-mysql

コマンド

# ./configure --with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=/usr/local/mysql \
--enable-cli \
--enable-pear \
--with-tsrm-pth \
--with-gd --with-zlib \
--with-freetype-dir=/usr/local \
--with-jpeg-dir=/usr/local \
--with-png-dir=/usr/local \
--enable-force-cgi-redirect \
--enable-mbstring \
--enable-mbstr-enc-trans \
--enable-trans-sid \
--enable-versioning \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--enable-sockets \
--with-snmp=/usr/local

# make
# make install
# /usr/local/etc/rc.d/apache22 restart

rrdtoolのインストール

# cd /usr/ports/databases/rrdtool
# make install clean

cactiインストール

ソースを取得
http://www.cacti.net/download_cacti.php

# fetch http://www.cacti.net/downloads/cacti-0.8.7d.tar.gz
# mv /home/matsui/public_html/cacti

■親切に日本語化してくれた人がいました。

# fetch http://ftp.momo-i.org/pub/other/cacti-0.8.7d-i18n.tar.bz2
# tar jxvf cacti-0.8.7d-i18n.tar.bz2
# mv cacti-0.8.7d-i18n /home/matsui/public_html/cacti

Apacheの設定

# vi httpd.conf
--------------------------------------------
# cacti
Alias /cacti "/home/matsui/public_html/cacti"

MySQLにデータベースを作成&データをインポート&cacti用のユーザーを作成。

# mysqladmin --user=root create cacti
# mysql cacti < cacti.sql
# mysql
mysql> grant all on cacti.* to cacti@localhost identified by 'パスワード';
mysql> flush privileges;
mysql> exit

cactiの設定ファイル中のデータベース関連項目を修正。

# vi include/config.php以下デフォルト。

usernameとかpasswordを適宜修正。

/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactiuser";
$database_port = "3306";

cacti.sqlをインポート

# mysql -u cactiuser -pcactiuser < /home/matsui/public_html/cacti.sql

クーロン設定追加。

# crontab -u root -e
*/5 * * * * /usr/local/bin/php /home/matsui/public_html/poller.php > /dev/null 2>&1

ブラウザでアクセス

ブラウザでアクセス。

デフォルトはadmin:admin

管理画面が出てくればOK。初期化処理っぽいことを行えばログインページが出現。ユーザー&パスワードを入力してログインしてコントロールパネルから操作。

cacti-spineのインストール

MySQL

libmysqlclient_r.so」が必要とのことなので、MySQLのライブラリディレクトリにlibmysqlclient_r.soが無い場合は、
あらかじめconfigureオプション「--enable-thread-safe-client」を指定してMySQLをビルドしなおしておく。

--enable-thread-safe-client

portsから

# cd /usr/ports/net-mgmt/cacti-spine
# make install clean

ソースから

# wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.7a.tar.gz 
# tar zxvf cacti-spine-0.8.7a.tar.gz 
# cd cacti-spine-0.8.7a
# ./configure; make ;make install

設定ファイルなど編集

# chmod 644  /usr/local/etc/spine.conf
# vi /etc/crontab
---------------------------------------------------------
# spine
*/5 * * * * matsui /usr/local/bin/spine > /dev/null 2>&1

cactiにWeb上からログインし、[setting] ⇒ [Paths]で[Spine Poller File Path]にspineのパスを入力
[Poller]で[Poller Type]をspineに変更する。

グラフ作成の流れ

データテンプレート ⇒ デバイス(ホスト名) ⇒ データソース ⇒ 新規グラフ

参考サイト

http://cacti.loaded.jp/

・インストール、グラフの追加など
http://www.stackasterisk.jp/tech/systemManagement/snmp05_01.jsp#1

日本語http://www.momo-i.org/chapter5/cacti.html

・テンプレート http://www.debianhelp.co.uk/cactitemplates.htm