Graphing your F5 LTM Environment with Cacti

Capturing load balancer traffic flows is not something that is elegantly (or even rudimentarily) handled by most commercial applications, or at least the ones I've worked with.  Several can't even gather statistics on the F5 appliances because they lack the ability to index mibs.  Earlier this year, I worked through the process of building a Cacti server in the lab.  With the help of some excellent templates I found on the Cacti forums, I was able to successfully graph my virtual servers, interfaces, and memory.  CPU templates didn't exist, so I added this functionality and corrected some of the problems in the templates as I worked through my installation.  In summary, this article will walk the user through the steps required to install & configure Cacti to begin monitoring the F5 LTM Global Traffic, Virtual Server Traffic, Interface Traffic, Memory, & CPU.

Cacti Prerequisites

This tech tip assumes the packages below are already installed.  My version is in parentheses.

  • Web Server (apache, version 2.2.4)
  • MySQL (version 5.0.27)
  • PHP (version 5.2.1)
  • Perl (version 5.8.7)
  • NET-SNMP (version 5.2.3)
  • RRDTOOL (1.2.15)

Note 1: All the tools above on my system were installed via the BSD ports tree, so all the dependencies were solved automatically.  If you are not experience in resolving dependencies, I highly recommend a system that solves them for you.

Note 2: All the commands below reflect my system, so you may have to alter them if you install these packages into different directories.

Cacti Installation

Extract Cacti

  1. Get Cacti (http://www.cacti.net/downloads/cacti-0.8.7a.tar.gz) and place in /var/tmp/
  2. cd /usr/local/share/
  3. tar xvfz /var/tmp/cacti-0.8.7.tar.gz
  4. mv cacti-0.8.7 cacti

Create Cacti DB in MySQL

Note: have your mysql root password ready

  1. mysqladmin --user=root -p create cacti
  2. mysql --user=root -p cacti < /usr/local/share/cacti/cacti.sql
  3. mysql --user=root -p mysql
    GRANT ALL ON cacti.* TO cactiuser@localhost;
    GRANT USAGE ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactipassword';
    GRANT ALL ON cacti.* TO cactiuser@"%";
    GRANT USAGE ON cacti.* TO cactiuser@"%" IDENTIFIED BY 'cactipassword';
    flush privileges;
    exit

Update Cacti with DB username/password

  1. vi /usr/local/share/cacti/include/config.php
     $database_default = "cacti";
     $database_hostname = "localhost";
     $database_username = "cactiuser";
     $database_password = "cactipassword";

Add Cacti Poller to Crontab

  1. vi /etc/crontab
     */5 * * * * root /usr/local/bin/php /usr/local/share/cacti/poller.php > /dev/null 2>&1

Configure Apache for Cacti

  1. vi /usr/local/etc/apache22/httpd.conf
     <Directory /usr/local/share/cacti/>
            AllowOverride None
            Order allow,deny
            Allow from all
     </Directory>
     Alias /cacti/ /usr/local/share/cacti/

Log in for the 1st time!

  1. http://x.x.x.x/cacti/
    1. Accept the defaults
    2. Login as admin/admin
    3. Change admin password

Extract Cacti Plugin Architecture (optional)

  1. get Cacti Plugin Archticture (http://cactiusers.org/downloads/cacti-plugin-arch.tar.gz) and place in /usr/src/
  2. cd /usr/src
  3. tar xvfz cacti-plugin-arch.tar.gz
  4. cp -R /usr/src/cacti-plugin-arch/files-0.8.7a/ /usr/local/share/cacti/
  5. vi /usr/local/share/cacti/include/global.php
     $database_default = "cacti";
     $database_hostname = "localhost";
     $database_username = "cactiuser";
     $database_password = "cactipassword";
     $config['url_path'] = '/cacti/';

Extract & Initialize Weathermap (optional)

  1. Get Weather map (http://www.network-weathermap.com/files/php-weathermap-0.941.zip) and place in /usr/src/
  2. cd /usr/src/
  3. unzip /var/tmp/php-weathermap-0.84.zip
  4. mv weathermap /usr/local/share/cacti/plugins/
  5. cd /usr/local/share/cacti/plugins/weathermap/
  6. cp editor-config.php-dist editor-config.php
  7. vi editor-config.php
     $cacti_base = "/usr/local/share/cacti";
     $cacti_url = http://x.x.x.x/cacti/;
  8. vi /usr/local/share/cacti/include/global.php
     $plugins[] = 'weathermap';
  9. chmod 777 /usr/local/share/cacti/plugins/weathermap/configs (don't hate on me security blokes, this is a get it working tech tip)
  10. Update permissions for user admin to view & edit Weathermap
    1. In the GUI menu on the left under Utilities, click User Management
    2. Click admin (and any other users you've created that need weathermap access)
    3. Under Realm Permissions,
      1. check Plugin->Weathermap: Configure/Manage
      2. check Plugin->Weathermap: View
    4. click Save

Import F5 Host Template

Download the latest template from the F5 Cacti Template Wiki Page.

  1. In the Cacti GUI menu on the left under Import/Export, Click Import Templates
  2. Click Browse, select the host template file (cacti_host_template_f5_big-ip.xml)
  3. Click Save

Copy Host Template Scripts to Appropriate Directories

Note: Assumption that the scripts included in the zip file placed in /var/tmp.

  1. cp /var/tmp/f5-bigip-tmm-cpu.pl /usr/local/share/cacti/scripts/
  2. cp /var/tmp/ss_f5-bigip-tmm-memory.php /usr/local/share/cacti/scripts/
  3. cp /var/tmp/f5_bigip_vs.xml /usr/local/share/cacti/resource/snmp_queries/
  4. cp /var/tmp/f5_bigip_ifStat.xml /usr/local/share/cacti/resource/snmp_queries/

Update: Also brought to my attention is the fact that my CPU perl script didn't take a 10s delta of each value before reporting, which is recommended in the documentation.  There is an additional CPU script in the host template that accounts for the delta.  If you choose to use this one instead of the one mentioned in the steps above, just rename it as f5-bigip-tmm-cpu.pl and place it in the scripts directory under the cacti archive.

Build Complete!  Now let's add an LTM, shall we?

  1. In the Cacti GUI menu on the left under Management, Click Devices
  2. Click Add at the far right 
  3. Enter BigIP Name for Description
  4. Enter FQDN or IP for Hostname
  5. For Host Template, choose F5 BigIP
  6. For SNMP Version, select Version 2
  7. For SNMP Community, enter the SNMP Community string defined on the BigIP
  8. Click Save

Note: If successful, you should see something like this at the top:

SNMP Information
System: Linux myHostname.lab 2.4.21-9.4.3.1.0smp #2 SMP Wed Oct 17 19:47:50 PDT 2007 i686
Uptime: 85990646 (9 days, 22 hours, 51 minutes)
Hostname: myHostname.lab
Location: St Louis
Contact: Citizen_Elah

you should see something like this under the VS & interface Data Queries at the bottom:

1) F5 BigIP - Interface Statistics(Verbose Query)Uptime Goes BackwardsSuccess [40 Items, 20 Rows]Reload Data Query  Delete Data Query Association
2) F5 BigIP - VS Statistics(Verbose Query)Uptime Goes BackwardsSuccess [28 Items, 7 Rows]Reload Data Query  Delete Data Query Association

Create Graphs

  1. Still in the device screen from above, click at the top right Create Graphs for this Host
  2. In this screen, you can select as many of the potential graphs as desired
    1. For the Virtual Server, you will need to create the Connection Rate, Connections/s, & the Traffic graphs in separate steps via the select box at the bottom
  3. Click Create
  4. Accept the Defaults, Click Create again

Note: Created graphs will be listed at the top of the screen

Manage Graphs

  1. In the GUI menu on the left under Management, click Graph Trees
  2. Click Add
  3. Under Name, I define the F5 device hostname, but it can be anything
  4. Under Sorting Type, select your preference
  5. Click Create
  6. In the GUI menu on the left under Management, click Graph Management
  7. Select the Host you created
  8. Select the Graphs you created
  9. In the Choose an Action select box, select Place a tree (your new tree)
  10. Click Go
  11. Click Yes
  12. Click the Graphs Tab at the top of the screen
  13. Select the Tree you created
  14. View your graphs!

Here's a graph summary page snapshot:

 

Create a Weathermap (optional)

If you installed the Plugin Architecture & the Weathermap plugin, you can create maps to visualize the traffic flow through your F5 device

  1. In the GUI menu on the left under Management, click Weathermaps
  2. Click Add
  3. Click Add on simple.conf (the sample supplied with the plugin)
  4. This will launch the weathermap editor.  You can select your Data Sources for the links from Cacti within the editor, which is very nice.  For more support, check out http://www.network-weathermap.com

Here's a rudimentary Weathermap from toying around with the technology:

 

Future Developments

I am trying for the life of me to expand the support of this host template to include Pool Member statistics.  The problem with the SNMP approach is the index is in the middle of the oid, not at the end as in the virtual server and interface statistics.  I modified the PoolStatsv4v9 perl script to pull the appropriate data out, but I haven't figured out how to tell Cacti to figure the index on the pool name, then loop through all the pool members and dump the data into the RRD files.  If anyone wants to tackle that, you'd be my hero.

Published Dec 07, 2007
Version 1.0

Was this article helpful?

72 Comments