O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Cacti Beginner's Guide - Second Edition

Book Description

A comprehensive guide to learning Cacti and using it to implement performance measurement and reporting within a Network Operations Center

About This Book

  • A complete Cacti book that focuses on the basics as well as the advanced concepts you need to know for implementing a Network Operations Center
  • A step-by-step Beginner's Guide with detailed instructions on how to create and implement custom plugins
  • Written by Thomas Urban – creator of the "Cereus" and "NMID" plugins for Cacti known as Phalek in the Cacti forum

Who This Book Is For

If you are a network operator and want to use Cacti for implementing performance measurement for trending, troubleshooting, and reporting purposes, then this book is for you. You only need to know the basics of network management and SNMP.

What You Will Learn

  • Setting up Cacti on Linux and Windows systems
  • Extending the core functionality by using the plugin architecture
  • Building your own custom plugins
  • Creating your own custom data input method to retrieve data from your systems
  • Using SNMP, SSH, and WMI to retrieve remote performance data
  • Designing and create enterprise-class reports with the reporting plugins
  • Implementing threshold-based alerting using the Thold plugin
  • Automating common administrative tasks utilizing the command-line interface and the automate functionality
  • Migrating Cacti to new servers
  • Building a multi remote-poller environment

In Detail

Cacti is a performance measurement tool that provides easy methods and functions for gathering and graphing system data. You can use Cacti to develop a robust event management system that can alert on just about anything you would like it to. But to do that, you need to gain a solid understanding of the basics of Cacti, its plugin architecture, and automation concepts.

Cacti Beginner's Guide will introduce you to the wide variety of features of Cacti and will guide you on how to use them for maximum effectiveness. Advanced topics such as the plugin architecture and Cacti automation using the command-line interface will help you build a professional performance measurement system. Designed as a beginner's guide, the book starts off with the basics of installing and using Cacti, and also covers the advanced topics that will show you how to customize and extend the core Cacti functionalities. The book offers essential tutorials for creating advanced graphs and using plugins to create enterprise-class reports to show your customers and colleagues. From data templates to input methods and plugin installation to creating your own customized plugins, this book provides you with a rich selection of step-by-step instructions to reach your goals. It covers all you need to know to implement professional performance measurement techniques with Cacti and ways to fully customize Cacti to fit your needs. You will also learn how to migrate Cacti to new servers. Lastly you will also be introduced to the latest feature of building a scalable remote poller environment.

By the end of the book, you will be able to implement and extend Cacti to monitor, display, and report the performance of your network exactly the way you want.

Style and approach

Written for beginners to Cacti, this book contains step-by-step instructions and hands-on tutorials for network operators to learn how to implement and use the core Cacti functions.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Preface
    1.  What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Conventions
    5. Reader feedback
    6. Customer support
      1. Downloading the example code
      2. Downloading the color images of this book
      3. Errata
      4. Piracy
      5. Questions
  2. Installing Cacti
    1. Preparing the system - basic prerequisites
      1. Web server
      2. PHP
      3. MySQL database
      4. NET-SNMP package
    2. Installing Cacti on a CentOS 7 system
      1. Preparing the system
        1. Time for action - installing the missing packages and preparing the system
        2. What just happened?
      2. Downloading and extracting Cacti
        1. Time for action - downloading Cacti
        2. What just happened?
      3. Creating the database
        1. Time for action - creating the database
        2. What just happened?
      4. Configuring Cacti
        1. Time for action - configuring Cacti
        2. What just happened?
      5. Creating the poller cron entry and Cacti's system user
        1. Time for action - creating the poller's cron entry and Cacti's system account
        2. What just happened?
      6. Installing the Spine poller
        1. Time for action - installing Spine
        2. What just happened?
      7. Differences between source and APT/yum installations
        1. Have a go hero - remote server for database hosting
    3. Installing Cacti on a Windows system
      1. The community-built Windows installer
        1. Time for action - starting the Windows setup
        2. What just happened?
      2. Installing the Spine poller under Windows
    4. Upgrading Cacti
      1. Time for action - upgrading Cacti
        1. What just happened?
    5. Using Cacti for the first time
      1. Time for action - configuring Cacti
        1. What just happened?
    6. The Cacti web interface explained
      1. The Console tab
        1. Create section
        2. Management section
        3. Data Collection section
        4. Templates section
        5. Automation section
        6. Presets section
        7. Import/Export section
        8. Configuration section
        9. Utilities section
      2. The graphs tab
      3. The nectar tab
      4. The clog tab
    7. Before we continue
      1. Pop quiz - a few questions about Chapter 1
    8. Summary
  3. Using Graphs to Monitor Networks and Devices
    1. An introduction to Cacti graphs and RRDtool
      1. Creating graphs with RRDtool
      2. Basic RRDtool graph creation
      3. Advanced RRDtool graph creation
        1. Adding a label and title to the graph
        2. Adding a legend to the graph
        3. Adding a threshold line to the graph
        4. Adding threshold breaches to the graph
        5. Variable definition (VDEF)
      4. Further reading
        1. Have a go hero - create your own visual warnings
    2. Adding devices to Cacti
      1. Creating a new site
        1. Time for action - creating a new site in Cacti
      2. Creating a device
        1. Time for action - creating a new device in Cacti
      3. Selecting host templates for the device
        1. Time for action - adding a host template to the device
      4. Adding graphs to the device
        1. Time for action - adding graphs to the device
      5. Adding interface graphs to a device
        1. Time for action - adding interface graphs to a device
    3. Adding devices to the Cacti tree
      1. Creating a tree
        1. Time for action - creating a Cacti tree
      2. Sub-tree items
        1. Time for action - adding a sub-tree
      3. Adding the device to the tree
        1. Time for action - adding a device to the Cacti tree
    4. Before we continue
      1. Pop quiz - a few questions about Chapter 2
    5. Summary
  4. Creating and Using Templates
    1. An introduction to templates
      1. Data Source templates
        1. Data input methods
        2. Data queries
      2. Graph templates
      3. Device templates
    2. Defining a data source template
      1. Time for action - defining a data source template
      2. What just happened?
      3. Have a go hero - create your own TCP connections template
    3. Defining a graph template
      1. CDEF definition
        1. Time for action - defining a CDEF in Cacti
      2. Defining the graph template
        1. Time for action - defining the graph template
      3. Adding the threshold line
        1. Time for action - Adding new graph template items
      4. Adding the green, yellow, and red areas
        1. Time for action - adding the color areas
      5. Adding a legend to the graph
        1. Time for action - adding a legend
      6. Back to the basics - rrdtool graph command
    4. Defining a device template
      1. Time for action - defining a host template
      2. Assigning a host template to a device
    5. Importing/exporting templates
      1. Importing templates
        1. Time for action - importing a template
      2. Exporting templates
        1. Time for action - exporting a template
    6. The template repository
    7. Before we continue
      1. Pop quiz - a few questions about Chapter 3
    8. Summary
  5. User Management
    1. An introduction to Cacti user management
      1. Users
      2. Groups
      3. Permissions
    2. Creating a user
      1. Time for action - creating the first Cacti user
    3. General User Settings
      1. Graph Options
      2. Login Options
      3. Authentication Realm
    4. Permissions tabs
      1. Permissions
        1. Normal User permissions
        2. Template Editor
        3. General Administration
        4. System Administration
        5. External Link Permissions
        6. Plugin Permissions
      2. Group Membership
      3. Graph Permissions
      4. Device Permissions
      5. Template Permissions
      6. Tree Permissions
      7. User Settings
        1. Time for action - setting general permissions
      8. Tree Permissions
        1. Time for action - setting Tree Permissions
    5. User Groups
      1. Time for action - creating a User Group for Customer A
    6. The template user
      1. Time for action - installing the missing packages
      2. Copying permissions - the Batch Copy mode
        1. Time for action - Batch Copy
    7. Integrate LDAP/Active Directory authentication
      1. External User management
        1. Time for action - setting up Active Directory authentication
    8. Managing users with the Cacti CLI
      1. Importing a list of users
        1. Time for action - importing users from the CLI
        2. Input validation
        3. Checking the existence of the template user
        4. Reading in the import file
    9. Before we continue
      1. Pop quiz - a few questions about Chapter 4
    10. Summary
  6. Data Management
    1. An introduction to Cacti data management
      1. Data input methods
      2. Data queries
    2. Creating data input methods
      1. Preparation - creating the script
        1. Gathering the data
        2. Preparing the data for output
        3. Installation of the script
        4. Modifying the secure log permissions
          1. Time for action - creating a data input method - step 1
          2. Time for action - creating a data input method - step 2
      2. The data template
    3. Creating data queries
      1. Building the XML data file
        1. XML header
        2. XML input
        3. XML output
        4. Installing the XML file
      2. Creating the data query within Cacti
        1. Time for action - creating a data query - step 1
        2. Time for action - creating a data query - step 2
    4. Creating a remote SSH data input method
      1. Preparation
        1. The remote script
        2. The local script
          1. Input variables
          2. The SSH command execution
          3. Preparing the data
        3. SSH public key authentication
          1. Time for action - create SSH keys with ssh-keygen tool
      2. Creating the data input method
        1. Time for action - creating the data input method
      3. Creating the data template
      4. Creating the graph template
      5. Adding the graph to the device
      6. Alternative methods
        1. Have a go hero - remote command execution using SNMP
    5. Before we continue
      1. Pop quiz - a few questions about Chapter 5
    6. Summary
  7. Cacti Maintenance
    1. An introduction to Cacti maintenance
      1. Database
      2. RRD files
    2. The Cacti directory structure
      1. The cache directory
      2. The cli directory
      3. The docs directory
      4. The include directory
      5. The install directory
      6. The lib directory
      7. The locales directory
      8. The log directory
      9. The mibs directory
      10. The plugin directory
      11. The resource directory
      12. The rra directory
      13. The scripts directory
    3. Backup and restore procedures
      1. The MySQL/MariaDB database
        1. Time for action - backup your Cacti database
          1. What just happened?
      2. Enhancing the database backup
        1. Automatic file naming
        2. Remove old backup files
        3. The database backup
        4. Compress the backup
        5. The whole script
      3. The Cacti files
        1. Building the backup file list
          1. Time for action - backup your Cacti files
      4. Enhancing the database backup script
        1. Time for action - enhancing the backup script
          1. What just happened?
      5. Adding remote transfer with SCP
        1. Time for action - Adding SCP to the backup script
          1. What just happened?
      6. Creating the cronjob - automating the backup
        1. Time for action - creating a cronjob
          1. What just happened?
      7. Restoring from a backup
        1. Restoring the Cacti database
          1. Time for action - Restoring the Cacti database
          2. What just happened?
        2. Restoring the Cacti files
          1. Restoring all Cacti files
          2. Restoring a single file from the backup
    4. Log file management
      1. Time for action - configuring logrotate
        1. What just happened?
    5. Cacti maintenance
      1. List RRD files with no associated host
        1. Time for action - finding orphaned RRD files
          1. What just happened?
    6. A short overview of the Cacti CLI functionality
      1. Repairing templates
      2. Repairing the database
    7. Pop quiz - a few questions about Chapter 6
    8. Summary
  8. Network and Server Monitoring
    1. An introduction to network and server monitoring
      1. Network devices
      2. VMware ESX
      3. Linux server
      4. Windows WMI monitoring
    2. Monitoring a network device
      1. Configuring SNMP access on Cisco Switch
        1. Time for action - setup SNMP on Cisco devices
          1. What just happened?
      2. Adding Cisco Switch to Cacti
        1. Time for action - adding a Cisco Switch to Cacti
          1.  What just happened?
      3. Configuring SNMP access on a Cisco PIX firewall
        1. Time for action - setting up SNMP access on Cisco PIX
          1. What just happened?
      4. Adding Cisco PIX firewall to Cacti
        1. Time for action - adding a Cisco PIX firewall to Cacti
          1. What just happened?
    3. Monitoring VMware ESX servers
      1. Preparing the SNMP access for VMware ESXi 6/6.5
        1. Time for action - enabling SSH access on a ESXi 6/6.5 server
          1. What just happened?
      2. Enabling the SNMP service on a VMware ESXi 6/6.5 server
        1. Time for action - enabling the SNMP service on a VMware ESXi host
          1. What just happened?
      3. Adding VMware ESX servers to Cacti
        1. Time for action - adding a VMware ESX host to Cacti
    4. Windows monitoring
      1. Windows SNMP setup
        1. Time for action - enabling the SNMP server feature
          1. What just happened?
        2. Configuration of the Windows SNMP service
          1. Time for action - configuring the Windows SNMP service
      2. WMI setup
        1. Time for action - setting up a Windows WMI user
          1. What just happened?
      3. Installing the CactiWMI add-on
        1. Installing the wmi.php Cacti interface
          1. Time for action - installing the CactiWMI add-on - Part 1
        2. Installing the wmic command
          1. Time for action - installing the CactiWMI add-on - Part 2
          2. What just happened?
      4. Performance measurement with CactiWMI
        1. Time for action - measuring performance with CactiWMI
          1. What just happened?
    5. Linux monitoring
      1. Linux SNMP setup
        1. Time for action - enabling SNMP on a Linux server
          1. What just happened?
    6. Pop quiz - a few questions about Chapter 7
    7. Summary
  9. Plugin Architecture
    1. Introduction to the plugin architecture
      1. Why plugins?
      2. Plugin features
      3. Common plugins
        1. MAC Track plugin
        2. Network Weathermap
        3. Thold
    2. Configuring the plugin architecture
      1. Time for action - configuring the plugin architecture
        1. What just happened?
    3. Downloading and installing plugins
      1. Plugin architecture (PIA) directory structure
      2. Pre-Cacti 1.x plugins
      3. The plugin repository
        1. The Graph Export (gexport) plugin
          1. Time for action - installing the gexport plugin
          2. What just happened?
      4. Removing a plugin
        1. Time for action - removing the gexport plugin
          1. What just happened?
    4. Updating a plugin
    5. Adding plugin permissions
    6. Pop quiz - a few questions about Chapter 8
    7. Summary
  10. Plugins
    1. Plugin design
      1. Plugin hooks
      2. Plugin settings
        1. The cycle_config_settings function
      3. Displaying plugin data within Cacti
        1. The cycle_show_tab function
    2. Commonly used plugins
    3. Creating a new plugin
      1. File structure
      2. Concept and design
        1. PIA hooks
          1. The tree_after hook
          2. The draw_navigation_text hook
          3. The config_arrays hook
          4. The config_settings hook
          5. The config_form hook
          6. The api_device_save hook
      3. The plugin setup
        1. The plugin_cbEnhancedInfo_install function
          1. Time for action - adding the realm permission functions
          2. What just happened?
        2. The cbEnhancedInfo_draw_navigation_text function
        3. The cbEnhancedInfo_config_form function
        4. The cbEnhancedInfo_api_device_save function
        5. The cbEnhancedInfo_setup_table_new function
          1. Time for action - adding additional fields to the host table
          2. What just happened?
        6. The cbEnhancedInfo_config_settings function
        7. The cbEnhancedInfo_config_arrays function
      4. Data presentation
        1. Retrieving data from the database
          1. Time for action - retrieving data from the database
          2. What just happened?
        2. Presenting data on the tree view page
          1. Time for action - presenting data on the tree view page
          2. What just happened?
      5. Creating the table list web page
        1. The action section
          1. Deleting data
          2. What just happened?
        2. The data retrieval section
          1. Time for action - sorting and retrieving data
          2. What just happened?
        3. Data presentation
          1. Time for action - presenting the data
          2. What just happened?
      6. Creating the add items form
        1. The form_display function
          1. The data retrieval section
          2. The data presentation section
        2. The form_save function
          1. Time for action - retrieving data from the form post
          2. What just happened?
          3. Time for action - creating a new database item
          4. What just happened?
          5. Time for action - updating an existing item
          6. What just happened?
      7. Installing the plugin
      8. Publishing
        1. Pop Quiz - A few questions about Chapter 9
    4. Summary
  11. Threshold Monitoring with Thold
    1. Threshold monitoring
      1. Thold
    2. Installing Thold
      1. Downloading and installing Thold
        1. Time for action - installing Thold
          1. What just happened?
    3. Configuring Thold
      1. General options
      2. Default alerting options
      3. Default email options
      4. Default baseline options
      5. Syslog and SNMP notification
    4. Using Thold
      1. Assigning permissions and setting up an email address
        1. Time for action - giving permission to a user
          1. What just happened?
      2. Creating a notification list
        1. Time for action - creating a notification list
          1. What just happened?
      3. Creating a threshold
        1. Time for action - creating your first threshold - Part 1
          1. What just happened?
        2. The threshold creation page
          1. Template and General Settings section
          2. Threshold setup section
          3. Other Settings section
          4. Time for action - creating your first threshold - Part 2
        3. Testing the threshold
          1. Time for action - creating an artificial load
      4. Viewing threshold breaches
        1. Time for action - viewing breached thresholds
          1. What just happened?
      5. Creating threshold templates
        1. Time for action - creating your first threshold template
          1. What just happened?
      6. Assigning threshold templates
        1. Time for action - assigning a threshold template
          1. What just happened?
      7. Thold daemon
        1. Time for action - enabling the thold daemon
          1. What just happened?
    5. Pop quiz - a few questions about Chapter 10
    6. Summary
  12. Enterprise Reporting
    1. Overview of Nectar and CereusReporting
      1. Nectar
      2. CereusReporting
    2. Nectar
      1. Report generation
        1. Time for action - create your first Nectar report
          1. What just happened?
        2. Time for action - adding report items
          1. What just happened?
    3. CereusReporting
      1. Installation
        1. Time for action – installing CereusReporting
          1. What just happened?
      2. Plugin configuration
        1. Time for action - configuring CereusReporting
          1. What just happened?
      3. Report generation
        1. On-demand report generation
          1. Time for action - creating an on-demand report
        2. Pre-defined report generation
          1. Time for action - creating a pre-defined report
      4. Scheduling a report
        1. Time for action - scheduling a pre-defined report
          1. What just happened?
      5. Report backup and restore
        1. Time for action - backing up and restoring a pre-defined report
          1. What just happened?
    4. Report scheduling and polling performance
      1. Time for action - setting up cron-based report generation
        1. What just happened?
    5. Advanced reporting features of CereusReporting
      1. TCPDF report engine
      2. Cacti Data Source Statistics (DSSTATS) reports
      3. Availability reports
      4. SmokePing reports
      5. Report templates
    6. Pop quiz - a few questions about Chapter 11
    7. Summary
  13. Cacti Automation for NOC
    1. Overview of Cacti automation
      1. The Cacti CLI
        1. Users
        2. Permissions
        3. Trees
        4. Devices
        5. Graphs
      2. Overview of automation
        1. Trees
        2. Graphs
    2. Using the Cacti CLI
      1. Adding permissions
        1. Time for action - adding permissions to a user
          1. What just happened?
      2. Adding a Cacti tree
        1. Time for action - adding a Cacti tree
          1. What just happened?
      3. Adding a device
        1. Time for action - adding a single device to Cacti
          1. What just happened?
      4. Importing a list of devices into Cacti
      5. Adding a graph to a device
    3. Automation - true Cacti automation
      1. Automation rules
        1. Tree rules
          1. Time for action - adding a new tree rule
          2. Time for action - applying an automation rule to devices
        2. Graph rules
          1. Time for action - adding a graph rule
        3. Further information
          1. Pop quiz - Let's test your knowledge about Chapter 12
    4. Summary
  14. Migrating Cacti to a New Server
    1. Overview of a Cacti migration
      1. The Cacti files
      2. The database
      3. RRD files
      4. The poller
      5. Firewall/network settings
      6. Differences between a 32-bit and 64-bit system
    2. Cacti files
      1. Enhancing the backup script
        1. Time for action - enhancing your Cacti backup
        2. What just happened?
        3. Time for action - removing RRD files from your Cacti backup
        4. What just happened?
    3. The RRD files
      1. Time for action - dumping and loading an RRD file
      2. What just happened?
      3. Enhancing the backup script to dump RRD data
        1. Time for action - enhancing your Cacti backup
        2. What just happened?
    4. Creating the initial cacti backup
      1. Time for action - creating the complete Cacti backup
    5. What just happened?
    6. Preparing the target system
      1. Restoring the Cacti files
        1. Time for action - restoring Cacti files
        2. What just happened?
      2. Restoring the database
        1. Time for action - restoring the Cacti database
        2. What just happened?
      3. Restoring the RRD files
        1. Time for action - restoring the RRD files
        2. What just happened?
      4. Updating the Cacti configuration
        1. Time for action - updating the Cacti configuration
        2. What just happened?
    7. Further information
      1. Pop quiz - let's test your knowledge
    8. Summary
  15. Multiple Poller with Cacti
    1. Overview of the remote poller architecture
      1. The master server
      2. The remote poller server
      3. The network
      4. The database
      5. Firewall/network settings
    2. Setting up the master system
      1. Time for action – configuring the master system
      2. What just happened?
    3. Setting up the remote poller system
      1. Time for action – setting up the remote poller system
      2. What just happened?
    4. Prepare the remote poller
      1. Time for action – setting up the remote poller system
      2. What just happened?
    5. Final configuration of the master poller
      1. Time for action – setting up the remote poller system
      2. What just happened?
    6. Adding devices to the remote poller
      1. Time for action – setting up the remote poller system
      2. What just happened?
    7. Further information
      1. Pop quiz – let's test your knowledge about Chapter 14
    8. Summary
  16. Online Resources
    1. Cacti website
      1. Spine
      2. Plugin architecture hook API reference
      3. Cacti documentation
      4. Cacti forum
      5. Cacti GitHub page
      6. Cacti bug reporting
      7. Cacti GitHub plugin repository
      8. Howie's stuff
      9. RRDTool
      10. Tobi Oetiker
      11. RRDTool, Cacti, and time zones
      12. Xing German Cacti group
      13. LinkedIn Cacti group
      14. NMID plugins and CereusReporting
  17. Further Information
    1. The Round Robin database tool
      1. The RRD file architecture
    2. SNMP - the Simple Network Management Protocol
      1. The Management Information Base
      2. SNMPv1
        1. Security
      3. SNMPv2/SNMPv2c
        1. Security
      4. SNMPv3
      5. SNMP support in Cacti
      6. MRTG - Multi Router Traffic Grapher
    3. Where to get support?
      1. Cacti forums
      2. Mailing list
      3. Commercial support
  18. Pop Quiz Answers
    1. Chapter 1 — Installing Cacti
    2. Chapter 2 — Using Graphs to Monitor Networks and Devices
    3. Chapter 3 — Creating and Using Templates
    4. Chapter 4 — User Management
    5. Chapter 5 — Data Management
    6. Chapter 6 — Cacti Maintenance
    7. Chapter 7 — Network and Server Monitoring
    8. Chapter 8 — Plugin Architecture
    9. Chapter 9 — Plugins
    10. Chapter 10 — Threshold Monitoring with Thold
    11. Chapter 11 — Enterprise Reporting
    12. Chapter 12 — Cacti Automation for NOC
    13. Chapter 13 — Migrating Cacti to a New Server
    14. Chapter 14 — Multiple Poller with Cacti