Installing and Configuring Cacti 1.2.14: A Comprehensive Guide

Origins and Evolution of Cacti

The story begins in 2001 when Ian Berry, a high school student learning PHP and MySQL, developed a network monitoring solution for an obscure internet service provider. His goal was to create a more intuitive and flexible alternative to existing tools like RRDTool and MRTG.

Through his dedication, Ian created the first open-source version using PHP. Over subsequent years, the community embraced Cacti, leading to the release of version 0.8.6 on September 13, 2004. This milestone marked the beginning of Cacti's maturity, characterized by improved efficiency and extensibility.

The roadmap originally planned version 1.0.0 for late 2013, but the project's popularity led to numerous forks and custom versions. To address this fragmentation, Ian restructured development efforts in June 2012, focusing on improving efficiency and reducing release cycles. The current official version stands at 1.2.14.

Overview of Cacti

What is Cacti?

Cacti is a network traffic monitoring tool built with PHP, MySQL, SNMP, and RRDTool. It collects data via SNMP, stores it using RRDTool, and generates visualizations for users. The system provides robust user management features, allowing granular access control over hosts and graphs. Integration with LDAP for authentication and customizable templates make it highly adaptable.

The core components are:

  • SNMP for data collection
  • RRDTool for data storage and graph generation
  • MySQL for configuration and metadata

Data collected through SNMP is stored in RRD files within the RRA directory rather than in the MySQL database. These fixed-size files use a round-robin approach to maintain historical data efficiently.

Understanding SNMP

Simple Network Management Protocol (SNMP) enables network monitoring by running agents on managed devices that collect information and listen on UDP port 161. For proper operation, the monitored systems require net-snmp packages, while monitoring systems need net-snmp-utils.

Introduction to RRDTool

RRDTool manages Round Robin Databases, which store time-series data in circular buffers. This approach ensures consistent storage size and automatic data rotation, making it ideal for long-term monitoring scenarios.

System Architecture

Cacti operates on a client-server model where:

  • Monitored devices (servers, switches) run SNMP agents
  • Monitoring server collects data using SNMP
  • Data is stored in RRD files
  • Web interface displays graphs generated by RRDTool
  • PHP handles the web application layer

Common Monitoring Scenarios

  1. Network infrastructure
  2. Host system metrics:
    • Interface bandwidth utilization
    • CPU load and memory usage
    • Disk space and process counts
  3. Typical monitored entities:
    • Server resources (CPU, memory, disk)
    • Service types (Web, Mail, FTP, DB)
    • Network interfaces (traffic, packet loss)
    • Device performance and configurations
    • Security appliance metrics
    • Environmental conditions (temperature, power)

Installation Process

Prerequisites

  • CentOS 7.8.2003 (Core)
  • PHP 7.1
  • MariaDB or MySQL 5.7+

Step-by-Step Installation

  1. Remove bundled MariaDB components:

    yum remove mariadb-libs
    
  2. Enable EPEL repository:

    yum install epel-release
    
  3. Add whsir repository:

    rpm -ivh http://mirrors.whsir.com/centos/whsir-release-centos.noarch.rpm
    
  4. Install required packages:

    yum install wnginx wphp71 wmysql57
    
  5. Install additional dependencies:

    yum install wphp71-ldap wphp71-snmp wrrdtool wnet-snmp wspine-1.2.2 sendmail
    
  6. Configure environment variables:

    echo 'export PATH=$PATH:/usr/local/nginx/sbin/:/usr/local/php/bin/:/usr/local/mysql/bin/' >> /etc/profile
    source /etc/profile
    
  7. Create symbolic links:

    ln -sv /usr/local/mysql/lib/libmysqlclient.so.20 /usr/lib64/libmysqlclient.so.20
    ln -sv /usr/local/mysql/lib/libmysqlclient.so /usr/lib64/libmysqlclient.so
    
  8. Modify PHP settings to enable necessary functions:

    vi /usr/local/php/etc/php.ini
    

    Remove shell_exec, exec, popen from disable_functions, then restart PHP:

    /etc/init.d/php-fpm71 restart
    
  9. Start services:

    /etc/init.d/nginx start
    /etc/init.d/mysql start
    /etc/init.d/snmpd start
    
  10. Secure MySQL installation:

    mysql -uroot -p
    mysql> set password = password('whsir');
    mysql> CREATE DATABASE cacti DEFAULT CHARACTER SET utf8;
    mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'blog.whsir.com';
    mysql> GRANT SELECT ON mysql.time_zone_name TO cacti@localhost IDENTIFIED BY 'blog.whsir.com';
    mysql> ALTER DATABASE cacti CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
    mysql> flush privileges;
    mysql> quit
    
  11. Load timezone data:

    /usr/local/mysql/bin/mysql_tzinfo_to_sql /usr/share/zoneinfo/ | mysql -uroot -pwhsir mysql
    
  12. Download and extract Cacti:

    mkdir /data/www
    cd /data/www
    wget https://www.cacti.net/downloads/cacti-1.2.14.tar.gz
    tar xf cacti-1.2.14.tar.gz
    mv cacti-1.2.14 cacti
    
  13. Configure database connection:

    cd /data/www/cacti/include
    vi config.php
    

    Set parameters:

    $database_type = 'mysql';
    $database_default = 'cacti';
    $database_hostname = 'localhost';
    $database_username = 'cacti';
    $database_password = 'blog.whsir.com';
    $database_port = '3306';
    $database_retries = 5;
    $database_ssl = false;
    
  14. Import database schema:

    mysql -ucacti -pblog.whsir.com cacti < /data/www/cacti/cacti.sql
    
  15. Create log files:

    touch /data/www/cacti/log/cacti.log
    touch /data/www/cacti/log/cacti_stderr.log
    
  16. Create symbolic links:

    ln -sv /usr/local/rrdtool/bin/rrdtool /usr/local/bin/rrdtool
    ln -sv /usr/local/php/bin/php /usr/bin/php
    ln -sv /usr/local/snmp/bin/snmpwalk /usr/local/bin/snmpwalk
    ln -sv /usr/local/snmp/bin/snmpget /usr/local/bin/snmpget
    ln -sv /usr/local/snmp/bin/snmpbulkwalk /usr/local/bin/snmpbulkwalk
    ln -sv /usr/local/snmp/bin/snmpgetnext /usr/local/bin/snmpgetnext
    ln -sv /usr/local/snmp/bin/snmptrap /usr/local/bin/snmptrap
    
  17. Set proper permissions:

    chown -R www:www /data/www/cacti/
    
  18. Update Nginx configuration:

    vi /usr/local/nginx/conf/vhost/demo.conf
    

    Adjust root path and enable PHP processing

  19. Restart Nginx:

    nginx -t
    /etc/init.d/nginx restart
    
  20. Configure Spine poller:

    cd /usr/local/spine/etc
    cp spine.conf.dist spine.conf
    vi spine.conf
    

    Configure database settings:

    DB_Host localhost
    DB_Database cacti
    DB_User cacti
    DB_Pass blog.whsir.com
    DB_Port 3306
    

    Verify installation:

    /usr/local/spine/bin/spine
    
  21. Complete web installation: Access http://IP/cacti with default credentials admin/admin Change password after first login Follow setup wizard and adjust php.ini and my.cnf as needed

  22. Configure MySQL settings in my.cnf: Add these parameters:

    [client]
    port = 3306
    socket = /tmp/mysql.sock
    
    [mysqld]
    port = 3306
    socket = /tmp/mysql.sock
    pid_file = /data/mysql/mysql.pid
    datadir = /data/mysql
    
    slow_query_log=off
    long_query_time=2
    slow_query_log_file=/data/mysql/mysql_slow_query.log
    log-error = /data/mysql/error.log
    
    skip-external-locking
    key_buffer_size = 32M
    max_allowed_packet = 100M
    max_heap_table_size = 100M
    table_open_cache = 1024
    sort_buffer_size = 1m
    net_buffer_length = 8K
    read_buffer_size = 1m
    read_rnd_buffer_size = 512K
    myisam_sort_buffer_size = 8M
    thread_cache_size = 16
    query_cache_size = 32M
    tmp_table_size = 200M
    performance_schema_max_table_instances = 500
    join_buffer_size = 120M
    
    explicit_defaults_for_timestamp = true
    max_connections = 500
    max_connect_errors = 2000
    open_files_limit = 65535
    
    log-bin=mysql-bin
    binlog_format=mixed
    server-id = 100
    expire_logs_days = 10
    
    default_storage_engine = InnoDB
    innodb_file_per_table = 1
    innodb_data_home_dir = /data/mysql
    innodb_data_file_path = ibdata1:64M:autoextend
    innodb_log_group_home_dir = /data/mysql/
    innodb_buffer_pool_size = 1280M
    innodb_log_file_size = 32M
    innodb_log_buffer_size = 8M
    innodb_flush_log_at_trx_commit = 1
    innodb_lock_wait_timeout = 50
    collation-server=utf8mb4_unicode_ci
    innodb_flush_log_at_timeout = 3
    innodb_read_io_threads = 32
    innodb_write_io_threads = 16
    innodb_buffer_pool_instances = 17
    innodb_io_capacity = 5000
    innodb_io_capacity_max = 10000
    
    [mysqldump]
    quick
    max_allowed_packet = 100M
    
    [myisamchk]
    key_buffer_size = 128M
    sort_buffer_size = 128M
    read_buffer = 2M
    write_buffer = 2M
    
    [mysqlhotcopy]
    interactive-timeout
    

    Restart MySQL:

    /etc/init.d/mysql restart
    
  23. Configure poller type in Cacti UI: Navigate to Settings → Poller → Change to Spine

  24. Setup cron job for data collection:

    yum install crontabs -y
    crontab -e
    

    Add entry:

    */5 * * * * /usr/bin/php /data/www/cacti/poller.php >> /tmp/cacti_rrdtool.log 2>&1
    

Troubleshooting Common Issues

  1. Incorrect system time causing delayed graphs
  2. Missing RRD files requiring manual regeneration:
    /usr/bin/php /data/www/cacti/poller.php --force
    
  3. Permission issues:
    chmod 777 -R /data/www/cacti/rra
    
  4. Corrupted database tables:
    mysqlcheck --auto-repair --databases cacti
    
  5. SNMP connectivity verification:
    snmpwalk -v 2c -c public localhost
    
  6. Cron job verification
  7. Confirm RRDTool version compatibility

Tags: cacti network-monitoring SNMP rrdtool PHP

Posted on Mon, 24 Aug 2026 16:53:07 +0000 by skali