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
- Get Cacti (http://www.cacti.net/downloads/cacti-0.8.7a.tar.gz) and place in /var/tmp/
- cd /usr/local/share/
- tar xvfz /var/tmp/cacti-0.8.7.tar.gz
- mv cacti-0.8.7 cacti
Create Cacti DB in MySQL
Note: have your mysql root password ready
- mysqladmin --user=root -p create cacti
- mysql --user=root -p cacti < /usr/local/share/cacti/cacti.sql
- 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
- 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
- vi /etc/crontab
*/5 * * * * root /usr/local/bin/php /usr/local/share/cacti/poller.php > /dev/null 2>&1
Configure Apache for Cacti
- 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!
- http://x.x.x.x/cacti/
- Accept the defaults
- Login as admin/admin
- Change admin password
Extract Cacti Plugin Architecture (optional)
- get Cacti Plugin Archticture (http://cactiusers.org/downloads/cacti-plugin-arch.tar.gz) and place in /usr/src/
- cd /usr/src
- tar xvfz cacti-plugin-arch.tar.gz
- cp -R /usr/src/cacti-plugin-arch/files-0.8.7a/ /usr/local/share/cacti/
- 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)
- Get Weather map (http://www.network-weathermap.com/files/php-weathermap-0.941.zip) and place in /usr/src/
- cd /usr/src/
- unzip /var/tmp/php-weathermap-0.84.zip
- mv weathermap /usr/local/share/cacti/plugins/
- cd /usr/local/share/cacti/plugins/weathermap/
- cp editor-config.php-dist editor-config.php
- vi editor-config.php
$cacti_base = "/usr/local/share/cacti";
$cacti_url = http://x.x.x.x/cacti/; - vi /usr/local/share/cacti/include/global.php
$plugins[] = 'weathermap'; - chmod 777 /usr/local/share/cacti/plugins/weathermap/configs (don't hate on me security blokes, this is a get it working tech tip)
- Update permissions for user admin to view & edit Weathermap
- In the GUI menu on the left under Utilities, click User Management
- Click admin (and any other users you've created that need weathermap access)
- Under Realm Permissions,
- check Plugin->Weathermap: Configure/Manage
- check Plugin->Weathermap: View
- click Save
Import F5 Host Template
Download the latest template from the F5 Cacti Template Wiki Page.
- In the Cacti GUI menu on the left under Import/Export, Click Import Templates
- Click Browse, select the host template file (cacti_host_template_f5_big-ip.xml)
- Click Save
Copy Host Template Scripts to Appropriate Directories
Note: Assumption that the scripts included in the zip file placed in /var/tmp.
- cp /var/tmp/f5-bigip-tmm-cpu.pl /usr/local/share/cacti/scripts/
- cp /var/tmp/ss_f5-bigip-tmm-memory.php /usr/local/share/cacti/scripts/
- cp /var/tmp/f5_bigip_vs.xml /usr/local/share/cacti/resource/snmp_queries/
- 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?
- In the Cacti GUI menu on the left under Management, Click Devices
- Click Add at the far right
- Enter BigIP Name for Description
- Enter FQDN or IP for Hostname
- For Host Template, choose F5 BigIP
- For SNMP Version, select Version 2
- For SNMP Community, enter the SNMP Community string defined on the BigIP
- 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 Backwards | Success [40 Items, 20 Rows] | |
2) F5 BigIP - VS Statistics | (Verbose Query) | Uptime Goes Backwards | Success [28 Items, 7 Rows] |
Create Graphs
- Still in the device screen from above, click at the top right Create Graphs for this Host
- In this screen, you can select as many of the potential graphs as desired
- 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
- Click Create
- Accept the Defaults, Click Create again
Note: Created graphs will be listed at the top of the screen
Manage Graphs
- In the GUI menu on the left under Management, click Graph Trees
- Click Add
- Under Name, I define the F5 device hostname, but it can be anything
- Under Sorting Type, select your preference
- Click Create
- In the GUI menu on the left under Management, click Graph Management
- Select the Host you created
- Select the Graphs you created
- In the Choose an Action select box, select Place a tree (your new tree)
- Click Go
- Click Yes
- Click the Graphs Tab at the top of the screen
- Select the Tree you created
- 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
- In the GUI menu on the left under Management, click Weathermaps
- Click Add
- Click Add on simple.conf (the sample supplied with the plugin)
- 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.
- Baqar_Husain_81Nimbostratusthere was a lot of tweaking necessary with the changes in snmp.php, but I'm still having trouble with the memory graphs. I've started a new thread if someone could give me some help please --
- Baqar_Husain_81Nimbostratusanyone else have this problem with the Memory Graphs?
- Baqar_Husain_81NimbostratusIf anyone else experiences this issue with 0.8.7d, download the "SNMP value trim issue" patch release on 3/2/2009.
- mikeDOTd_61686NimbostratusI've got an issue where certain OID's are returning 0. Specifically "F5 BigIP - Global HTTP Requests", "F5 BigIP - Global HTTP Response Errors", and "F5 BigIP - Global HTTP Responses". If I manually snmpget those OID's I can validate the "0" response:
- JRahmAdminDo you have an http profile applied? I'm getting these returned just fine:
- Alex_Paoli_1136NimbostratusQuestion: Has anyone "truly" made the same thing for Pool Statistics as well. We use a lot of iRules under one VIP so, total connections there is nice, I need to see what a POOL or even a member is getting
- JRahmAdmin@xerlic...yes, the latest version of the template includes pool statistics for both GTM & LTM. Not pool members, though. You can get the latest template on the wiki page at http://devcentral.f5.com/wiki/default.aspx/AdvDesignConfig/CactiF5HostTemplate.html
- Bob_ZiuchkovskiNimbostratusHas anyone extended this to show HTTP requests / sec for a pool? We have client API traffic I'm trying to monitor for HTTP requests per second and connections/sec isn't accurate for this because most of our clients are keeping a single connection open for the multiple requests.
- JRahmAdminFor pool level HTTP stats, you'll need to build a stats profile and use an iRule to populate them. Then, you can poll the snmp oids for that profile. It's a complicated setup, but can be done.
- Bob_ZiuchkovskiNimbostratus@citizen_elah thanks for the info -- I was unaware of the existence of stats profiles. I dug around on the F5 and see it now. I also did some more digging with snmpwalk and noticed the F5s are keeping http stats per http profile. Ex: there's a ltmHttpProfileStatNumberReqs."http", ltmHttpProfileStatNumberReqs."http-lan-optimized-caching", ltmHttpProfileStatNumberReqs."http-wan-optimized-compression", etc. as well as the same for ltmFastHttpProfileStatNumberReqs."fasthttp". For the pools I want to track, I created new http profiles for use by the vservers using the pools, so now I have a ltmHttpProfileStatNumberReqs."http-api" and similar. Now I need to figure out how to add graphs for these to cacti -- I'm not much of a cacti expert. Anyway, mostly rambling to myself, but I thought someone else might find the tracking per http profile useful as well. I'm imagining it will save some overhead over using iRules to populate.