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.
- clowe_16759NimbostratusI already have Cacti graphing the performance for my LTMs, i would like to have some more granular graphs of my Virtual Servers, does anyone have a Cacti template to poll the Virtual servers more closely?
- JRahmAdminWhat did you have in mind?
- Simon_Wright_85NimbostratusHi there
- JRahmAdminIs this true of the root account as well, or just a user account?
- Simon_Wright_85NimbostratusI was just using the public snmp group so there is no security involved. The problem does seem limited to the 9.4.1 units as the others are fine. I will post in the forum to see if anyone else has come across the same thing.
- JRahmAdminDuh, sorry, it's early on Monday!
- Simon_Wright_85NimbostratusThanks for the quick reply. I need to upgrade the unit as we are running a different os version on each of our clusters and this was the only one that was giving us problems. I will give that a go first and then see what happens.
- Cesar_L__75595NimbostratusHi
- Julian_GrunnellNimbostratusDo you need to install the Architecture & Weathermap plugins to graph the switchports? Followed the steps above and everything I want is graphing apart from these. They just appear as broken images.
- Chris__Bloss_10NimbostratusAnyone build this in a VM yet? I'd love to get an export of the VM to avoid building my own? PLEASE!!!