最近要把公司的 Mrtg 主機轉到 Hyper-V 上,想說順便改用 Cacti 來取代 Mrtg,畢竟 Mrtg 也是很老的一支程式,有時要新增偵測點也挺麻煩的。
一、環境需求
1. RRDTool 1.0.49 or 1.2.x or greater
2. MySQL 4.1.x or 5.x or greater
3. PHP 4.3.6 or greater, 5.x greater highly recommended for advanced features
4. A Web Server e.g. Apache or IIS
二、套件需求
1. httpd
2. php
3. php-mysql
4. php-snmp
5. mysql
6. mysql-server
7. net-snmp
三、PHP 支援模組
1. mysql (For configuration, see note below)
2. SNMP (For configuration, see note below)
3. XML
4. Session
5. Sockets
6. LDAP (Required only when using LDAP authentication)
7. GD (Required only for some Plugins)
執行 php -m 可查看
四、安裝 Cacti
Cacti 是架構在 rrdtool 之上,rrdtool 是取代 Mrtg 的套件,但聽說功能強大,指令複雜。使用 RPM 或 Tar 安裝時,總是缺東缺西的很麻煩,還好找到可用 yum 安裝的方法。
1. 下載 rpmforge-release 安裝非官方套件庫
註:至 http://dag.wieers.com/rpm/FAQ.php#B 依自己的作業系統版本執行適合的指令安裝。
# rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
2. 安裝 rrdtool
# yum install rrdtool
3. 安裝 Cacti
# yum install cacti
五、設定 Cacti
1. 啟動 httpd 與 mysqld
# service httpd start
# service mysqld start
2. 設定開機啟動 httpd 與 mysqld
# chkconfig httpd on
# chkconfig mysql on
3. 建立資料庫帳號
# mysql -u root -p ←初始密碼為空值 Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 277
Server version: 5.0.77 Source distribution
1. RRDTool 1.0.49 or 1.2.x or greater
2. MySQL 4.1.x or 5.x or greater
3. PHP 4.3.6 or greater, 5.x greater highly recommended for advanced features
4. A Web Server e.g. Apache or IIS
二、套件需求
1. httpd
2. php
3. php-mysql
4. php-snmp
5. mysql
6. mysql-server
7. net-snmp
三、PHP 支援模組
1. mysql (For configuration, see note below)
2. SNMP (For configuration, see note below)
3. XML
4. Session
5. Sockets
6. LDAP (Required only when using LDAP authentication)
7. GD (Required only for some Plugins)
執行 php -m 可查看
四、安裝 Cacti
Cacti 是架構在 rrdtool 之上,rrdtool 是取代 Mrtg 的套件,但聽說功能強大,指令複雜。使用 RPM 或 Tar 安裝時,總是缺東缺西的很麻煩,還好找到可用 yum 安裝的方法。
1. 下載 rpmforge-release 安裝非官方套件庫
註:至 http://dag.wieers.com/rpm/FAQ.php#B 依自己的作業系統版本執行適合的指令安裝。
# rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
2. 安裝 rrdtool
# yum install rrdtool
3. 安裝 Cacti
# yum install cacti
五、設定 Cacti
1. 啟動 httpd 與 mysqld
# service httpd start
# service mysqld start
2. 設定開機啟動 httpd 與 mysqld
# chkconfig httpd on
# chkconfig mysql on
3. 建立資料庫帳號
# mysql -u root -p ←初始密碼為空值 Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 277
Server version: 5.0.77 Source distribution
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
mysql> create database cacti default character set utf8;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, INDEX, ALTER, CREATE, LOCK TABLES, CREATE TEMPORARY TABLES, DROP, REFERENCES ON cacti.* TO cactiuser@localhost IDENTIFIED BY '自訂密碼'; mysql> flush privileges; mysql> exit
4. 修改配置文件
# vi /var/www/cacti/include/config.php $database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "密碼";
$database_port = "3306";
5. 匯入資料庫欄位
# cd /var/www/cacti # mysql -u cactiuser -p cacti資料庫名稱 < cacti.sql
6. 建立 Symbolic link 在 /var/www/html
# cd /var/www/html # ln -s /var/www/cacti cacti
7. 修改 Apache 的 Cacti 參數
# vi /etc/httpd/conf.d/cacti.conf Alias /cacti/ /var/www/cacti/
<Directory /var/www/cacti/>
DirectoryIndex index.php
Options -Indexes
AllowOverride all
order deny,allow
allow from all
allow from 127.0.0.1
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc on
php_flag track_vars on
</Directory>
# service httpd restart
8. 建立 Crontab
# crontab -e */5 * * * * cacti php /var/www/cacti/poller.php &>/dev/null
六、登入 Cacti
1. 開啟 http://ip_address/cacti 2. 按 next,選擇 new install,按 next 直至完成。
3. 預設登入帳號/密碼為 admin/admin。
資料參考來源:
1. http://dag.wieers.com/rpm/FAQ.php#B
2. http://www.cacti.net/downloads/docs/html/index.html
3. http://hi.baidu.com/user_xia/blog/item/0273b362ca80ea690d33fa4e.html
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, INDEX, ALTER, CREATE, LOCK TABLES, CREATE TEMPORARY TABLES, DROP, REFERENCES ON cacti.* TO cactiuser@localhost IDENTIFIED BY '自訂密碼'; mysql> flush privileges; mysql> exit
4. 修改配置文件
# vi /var/www/cacti/include/config.php $database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "密碼";
$database_port = "3306";
5. 匯入資料庫欄位
# cd /var/www/cacti # mysql -u cactiuser -p cacti資料庫名稱 < cacti.sql
6. 建立 Symbolic link 在 /var/www/html
# cd /var/www/html # ln -s /var/www/cacti cacti
7. 修改 Apache 的 Cacti 參數
# vi /etc/httpd/conf.d/cacti.conf Alias /cacti/ /var/www/cacti/
<Directory /var/www/cacti/>
DirectoryIndex index.php
Options -Indexes
AllowOverride all
order deny,allow
allow from all
allow from 127.0.0.1
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc on
php_flag track_vars on
</Directory>
# service httpd restart
8. 建立 Crontab
# crontab -e */5 * * * * cacti php /var/www/cacti/poller.php &>/dev/null
六、登入 Cacti
1. 開啟 http://ip_address/cacti 2. 按 next,選擇 new install,按 next 直至完成。
3. 預設登入帳號/密碼為 admin/admin。
資料參考來源:
1. http://dag.wieers.com/rpm/FAQ.php#B
2. http://www.cacti.net/downloads/docs/html/index.html
3. http://hi.baidu.com/user_xia/blog/item/0273b362ca80ea690d33fa4e.html
沒有留言:
張貼留言