Home | Mirror | Search

3. Cacti

Cacti is a complete network graphing solution designed to harness the power of RRDTool's data storage and graphing functionality. Cacti provides a fast poller, advanced graph templating, multiple data acquisition methods, and user management features out of the box. All of this is wrapped in an intuitive, easy to use interface that makes sense for LAN-sized installations up to complex networks with hundreds of devices.

homepage: http://www.cacti.net/

3.1. Install Cacti for Ubuntu

過程 99.2. Step by step Install Cacti

  • Install Cacti for

    Ubuntu

    netkiller@shenzhen:~$ sudo apt-get install cacti
    				
    				
       ┌────────────────┤ Configuring libphp-adodb ├────────────────────┐
       │                                                                                            │
       │ WARNING: include path for php has changed!                                                 │
       │                                                                                            │
       │ libphp-adodb is no longer installed in /usr/share/adodb. New installation path is now      │
       │ /usr/share/php/adodb.                                                                      │
       │                                                                                            │
       │ Please update your php.ini file. Maybe you must also change your web-server configuraton.  │
       │                                                                                            │
       │                                           <Ok>                                             │
       │                                                                                            │
       └─────────────────────────────────────────────────────┘
    				
    				
    				
     ┌─────────────────────┤ Configuring cacti ├─────────────────────┐
     │                                                                                               │
     │ cacti must have a database installed and configured before it can be used.  If you like,      │
     │ this can be handled with dbconfig-common.                                                     │
     │                                                                                               │
     │ If you are an advanced database administrator and know that you want to perform this          │
     │ configuration manually, or if your database has already been installed and configured, you    │
     │ should refuse this option.  Details on what needs to be done should most likely be provided   │
     │ in /usr/share/doc/cacti.                                                                      │
     │                                                                                               │
     │ Otherwise, you should probably choose this option.                                            │
     │                                                                                               │
     │ Configure database for cacti with dbconfig-common?                                            │
     │                                                                                               │
     │                           <Yes>                              <No>                             │
     │                                                                                               │
     └───────────────────────────────────────────────────────┘
    				
    				
    				
      ┌───────────────────┤ Configuring cacti ├──────────────────────┐
      │ What is the password for the administrative account with which this package should create   │
      │ its MySQL database and user?                                                                │
      │                                                                                             │
      │ Password of your database's administrative user:                                            │
      │                                                                                             │
      │ ___________________________________________________________________________________________ │
      │                                                                                             │
      │                          <Ok>                              <Cancel>                         │
      │                                                                                             │
      └──────────────────────────────────────────────────────┘
    				
    				

reset password of admin

		
mysql> use cacti;
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> select * from user_auth;
+----+----------+----------------------------------+-------+---------------+----------------------+-----------+-----------+--------------+----------------+------------+---------------+--------------+--------------+------------------------+---------+
| id | username | password                         | realm | full_name     | must_change_password | show_tree | show_list | show_preview | graph_settings | login_opts | policy_graphs | policy_trees | policy_hosts | policy_graph_templates | enabled |
+----+----------+----------------------------------+-------+---------------+----------------------+-----------+-----------+--------------+----------------+------------+---------------+--------------+--------------+------------------------+---------+
|  1 | admin    | 21232f297a57a5a743894a0e4a801fc3 |     0 | Administrator | on                   | on        | on        | on           | on             |          1 |             1 |            1 |            1 |                      1 | on      |
|  3 | guest    | 43e9a4ab75570f5b                 |     0 | Guest Account | on                   | on        | on        | on           | on             |          3 |             1 |            1 |            1 |                      1 |         |
+----+----------+----------------------------------+-------+---------------+----------------------+-----------+-----------+--------------+----------------+------------+---------------+--------------+--------------+------------------------+---------+
2 rows in set (0.00 sec)


mysql> update user_auth set password=md5("chen") where id='1' and username='admin';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0
		
		
		

3.2. Source Install

Cacti requires MySQL, PHP, RRDTool, net-snmp, and a webserver that supports PHP such as Apache.

sudo apt-get install rrdtool
sudo apt-get install snmp snmpd
sudo apt-get install php5-snmp
		

At first, install snmp for linux

  1. wget http://www.cacti.net/downloads/cacti-0.8.7b.tar.gz

  2. tar zxvf cacti-0.8.7b.tar.gz

  3. mv cacti-0.8.7b /home/netkiller/public_html/cacti

  4. mysqladmin --user=root create cacti

  5. mysql -uroot -p cacti < cacti.sql

  6. echo "GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'somepassword';" | mysql -uroot -p

  7. echo "flush privileges;" | mysql -uroot -p

  8. vi include/config.php

    例 99.2. cacti config.php

    					
    $database_type = "mysql";
    $database_default = "cacti";
    $database_hostname = "localhost";
    $database_username = "cactiuser";
    $database_password = "somepassword";
    $database_port = "3306";
    					
    					

  9. crontab -e

    */5 * * * * php /var/www/neo.6600.org/html/cacti/poller.php > /dev/null 2>&1

    or

    /etc/crontab

    */5 * * * * nobody php /home/netkiller/public_html/cacti/poller.php > /dev/null 2>&1

  10. mkdir -p /var/log/cacti/

configure cacti

http://your-server/cacti/

3.3. Template

MySQL Template: http://code.google.com/p/mysql-cacti-templates/

$ cd /usr/local/src/
$ wget http://mysql-cacti-templates.googlecode.com/files/better-cacti-templates-1.1.7.tar.gz
$ tar zxvf better-cacti-templates-1.1.7.tar.gz
$ cd better-cacti-templates-1.1.7/
$ cp scripts/ss_get_mysql_stats.php /usr/share/cacti/site/scripts
		

default password

		
vim /usr/share/cacti/site/scripts/ss_get_mysql_stats.php.cnf
<?php
$mysql_user = "root";
$mysql_pass = "s3cret";
?>		
		
		

Import Templates

		
Import/Export -> Import Templates -> Import Template from Local File -> Save
		
		

設置模版

Templates -> 

X MyISAM Indexes DT
X MyISAM Key Cache DT
X MySQL Binary/Relay Logs DT
X MySQL Command Counters DT
X MySQL Connections DT
X MySQL Files and Tables DT
X MySQL Handlers DT
X MySQL Network Traffic DT
X MySQL Processlist DT
X MySQL Query Cache DT
X MySQL Query Cache Memory DT
X MySQL Replication DT
X MySQL Select Types DT
X MySQL Sorts DT
X MySQL Table Locks DT
X MySQL Temporary Objects DT
X MySQL Threads DT
X MySQL Transaction Handler DT

->

Custom Data
Hostname
Username	#單擊複選框,並輸入預設用戶名
Password	#單擊複選框,並輸入預設密碼
Port

-> Save
		
		
comments powered by Disqus