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.
- JRahmAdmin@ziuchkov - if you take a look at some of the articles/videos I've done on Cacti, you should get an idea how to approach it. Here's the Wiki page on the F5 cacti templates:
- dkraut_23236Nimbostratuscool, but doesn't look much more granular than what's already available in the F5 Performance Stats? We're looking for a way to show the "top talkers" of SSL TPS (transactions/sec). Specifically, which VIP's are using most of the SSL connections? Anyone know if this is possible? Thanks!
- JRahmAdmin@dkraut .. this would almost certainly need to be post analysis. You could do this with a reporting plugin which could rank your SSL TPS gaphs. Pretty rudimentary though.
- wtwagon_99154NimbostratusDoes this still apply to version 10? In version 9, it seemed to be working, but version 10 does not. Is there an updated template that I need to download?
- JRahmAdminThe latest template in the wiki work great for me in v10:
- wtwagon_99154NimbostratusThanks, I imported the new host templates but I still get nothing except for the Interfaces to collect. Is there anything else that needs to be updated from the older document to bring it to the present?
- JRahmAdminI don't believe any of the mibs have changed, I just cleaned up the templates and added a few things introduced in v10. Did you put the scripts in the correct directories with the necessary permissions? Since writing this article, CactiEZ is definitely the way to go to get off the ground running with a clean Cacti environment.
- Logan_Ramirez_5Nimbostratuscitizen_elah - did you find a hero? someone who found a way to index the pool name and loop through the pool members for data? i know it's like 2 years later but I just started writing iControl apps and just came across this article describing 'the use of wget' as a data method in place of SNMP - for basically the same reasons.
- JRahmAdminit might just be you...this is very intriguing. I don't have time to play yet, but I'm adding this to my list. Excellent work!
- Baqar_Husain_81NimbostratusIs anyone successfully able to pull traffic and connection graphs for individual virtual servers? I keep getting the error "WARNING: Result from SNMP not valid. Partial Result: U" in my cacti log.