Installation CACTI:
- yum install php php-mysql mysql mysql-server mysql-devel net-snmp net-snmp* rrdtool rrdtool*
- useradd -u 104 cactiuser -d /var/www/cacti -s /sbin/nologin
- cd /var/www
tar zxvf cacti-0.8.6j.tar.gz
mv cacti-0.8.6j cacti
chown -R root:root cacti - chown -R cactiuser /var/www/cacti/rra
chown -R cactiuser /var/www/cacti/log - mysql> GRANT ALL on cacti.* to cactiuser@localhost identified by 'cactiuser';
mysql> flush privileges
mysql> create database cacti - mysql -u cactiuser -p cacti < /var/www/cacti/cacti.sql
- crontab -e
#
# CACTI
#
*/5 * * * * php /var/www/cacti/poller.php > /dev/null 2>&1 - 本來應該不要以root權限執行
*/5 * * * * cactiuser php /var/www/cacti/poller.php > /dev/null 2>&1)
但如果你會用到ping的功能. 目前cacti中lib/ping.php, 我還無法解決非root如何執行, 所以直接用root執行
如果你沒用到任何plugin, 其實就用cactiuser去執行crontab, 但如果這樣... 那要改/etc/passwd中cactiuser由/sbin/nologin改為/bin/bash
- Edit /etc/logrotate.d/cacti
/var/www/cacti/log/cacti.log {
daily
rotate 8
create 0644 cactiuser cactiuser
} - Edit /var/www/cacti/include/config.php
$database_default = "cacti"
$database_hostname = "localhost"
$database_username = "cactiuser"
$database_password = "cacti" - Edit /etc/http/conf.d/cacti.conf
<VirtualHost *:80>
ServerAdmin tommy@ttn.com.tw
DocumentRoot /var/www/cacti
ServerName ncccacti1.ttn.net
</VirtualHost> - http://ncccacti1.ttn.net/
ID: admin
pw: admin
Installation Plugins Architecture:
不論用不用的到Plugins, 我建議一開始還沒用前就先裝, 不要使用後才開始做, 因為他有改變一些Files, 一開始做若有問題, 要處理就比較容易:
- download [Plugin Architecture Zip]
- cd /usr/local/src
mkdir mkdir cacti-plugin
cd cacti-plugin
unzip cacti-plugin-arch.zip - cd /var/www/cacti
patch -p1 -N < /usr/local/src/cacti-plugin/cacti-plugin-0.8.6j.diff
(因為我是0.8.6j, 如果是不同版本就要選不同的) - Modified /var/www/cacti/include/config.php
- check 之前設定沒改掉
$database_default = "cacti"
$database_hostname = "localhost"
$database_username = "cactiuser"
$database_password = "cacti" - 修改url_path:
$config['url_path'] = '/';
下面開始安裝一些scripts/plugins等五四三:
Install Advance Ping:
- 至http://forums.cacti.net/about10049.html
- 將ss_fping.zip解開放至/var/www/cacti/scripts
- 將cacti_graph_template_ping_advanced_ping_v1_3.xml import至console
- Console -> Import Templates:
Import Template from Local File: cacti_graph_template_ping_advanced_ping_v1_3.xml - save
- 檢查:
Console -> Graph Templates: 可以看到PING - Advanced Ping v1.3
Install Monitor Plugin:
- 至http://cactiusers.org/downloads download monitor
- cd /var/www/cacti/plugins
mkdir monitor
cd monitor
unzip /root/monitor-0.7.zip
cd ..
chown -R root:root monitor/ - modify /var/www/cacti/include/config.php
$plugins = array();
$plugins[] = 'monitor';
Install Discovery:
- 至http://cactiusers.org/downloads download discovery
- mkdir /var/www/cacti/plugins/discovery
cd /var/www/cacti/plugins/discovery
unzip /root/discovery-0.7.zip
mysql -u cactiuser -p cacti < discover.sql
chown -R root:root discovery/ - modify /var/www/cacti/include/config.php
$plugins = array();
$plugins[] = 'discovery'; - 參考http://cactiusers.org/wiki/DiscoverDocs 相關資料
- 設定
- Console 右邊Configuration下的Settings進入Console -> Cacti Settings
- 選Misc
save - 至Console -> User Management, 設定User使用權限
save
- Trouble Shooting:
- cd /var/www/cacti/plugins/discovery
- 執行 php -q findhosts.php -f -d
Install Network Weathermap:
- 至http://www.network-weathermap.com/download download
參考: http://www.network-weathermap.com/manual/latest/pages/install-cacti-editor.html - cd /var/www/cacti/plugins
unzip /root/php-weathermap-0.92.zip
chown -R root:root weathermap/
cd weathermap
chown -R cactiuser:apache output/
chmod -R g+w output/ - Edit /var/www/cacti/include/config.php
$plugins[] = 'weathermap'; - 至Console -> User Management, 設定User使用權限
save - 設定Editor
- 設定完後可以至http://your.server/plugins/weathermap/editor.php進行編輯
- 把要監控的weathermap加入
- 至Console -> Weathermaps
- 按Add加入Config File
- 若點選"Recalculate All Maps Now", 則會立即產生Weahtermaps
Install Cisco Memory Usage Template:
- 至http://forums.cacti.net/about2870.html download xml
- 至Console -> Import Templates
選擇cacti_graph_template_cisco_memory_usage.xml所在路徑

save
建立自己的Data Query:
ex: 希望圖上都要顯示ifAlias
- 至Console右邊Collection Methods下Data Queries: 點選"Snmp - Interface Statistics"
- 點選In/Out Bits
- 至Graph Template - Interface - Traffic (bits/sec)下
輸入|host_description| - Traffic - |query_ifName| - |query_ifAlias|
Fild Name: Titme
Add - 把剛加的那行Move UP到最上面
save
建立自己的Host Template
- 至Console 右邊Templates下的Host Templates
- 點右上角Add
- 設定Host Template Name: Cisco Switch
create
- Associated Graph Templates: Add
Cisco - CPU Usage
Cisco - Memory Usage - Associated Data Queries: Add
SNMP - Interface Statistics - save
Start to Add Device:
- Console -> Devices: Add
- 設定Detail
- create
- Add Associated Graph Templates: EX: 加"Cisco - CPU Usage", "PING - Advanced Ping v1.3"
save - 至Console -> Devices: 點選要產生圖的Device
- 點選"Create Graphs for this Host"
- 勾選要產生圖的: 包括CPU, Advance Ping, Interfaces
create - 設定CPU/Adavance Ping等相關參數
create - 設定顯示方式:
- Console -> Graph Trees: Add
- 設定Name
create - 把Device加入Tree
- Tree Item Type: Host
選擇要加的Host
create - save
- User Management可以至Console -> User Management, 設定User使用權限
Authentication with AD:
- 至Console右邊Configuration下的Settings, 然後點選Authentication
save - 建立GuestLDAP的Template
- Console -> User Management: 點選Add
create - 修改"Graph Permissions"權限
save
結論:
CACTI是一個很強的看流量工具, 但因為很強所以很複雜, 如果只是單純看cisco router/switch, 我建議就用MRTG, 別找麻煩. CACTI要用的好, 就要好好研究... 目前我覺得我的掌握度也只到七成.
其實最強最好, 不代就就最適合你...