In the last Cacti article, we walked through creating a graph template off individual static oids.  This time out, we're going to look at how to build a template with a data query based on indexed SNMP mibs.

Gathering Data...

The existing Cacti template, available here, already has the wideIP stats covered.  We know, however, that each wideIP can have multiple pools, and we may want to trend the requests handled in one pool versus another.  The SNMP values we'll need to build the template are in the F5-BIGIP-GLOBAL-MIB.txt file located on the BIG-IP in /usr/share/snmp/mibs.  After searching through the mib for pools, I found the index we'll need to build the template:

[root@ltm01:Active] mibs # snmpwalk -v 2c -c public localhost gtmPoolName
F5-BIGIP-GLOBAL-MIB::gtmPoolName."gpool1" = STRING: gpool1
F5-BIGIP-GLOBAL-MIB::gtmPoolName."gpool2" = STRING: gpool2
F5-BIGIP-GLOBAL-MIB::gtmPoolName."gpool3" = STRING: gpool3

So we see we're getting our pool names, which is great, but the data is not in a helpful format for building the template, so we need to translate gtmPoolName:

[root@ltm01:Active] mibs # snmptranslate -On F5-BIGIP-GLOBAL-MIB::gtmPoolName

OK, so that oid string is the index we'll need to build the other values.  Translations for the data points in the pool:

[root@ltm01:Active] config # snmptranslate -On F5-BIGIP-GLOBAL-MIB::gtmPoolStatPreferred

[root@ltm01:Active] config # snmptranslate -On F5-BIGIP-GLOBAL-MIB::gtmPoolStatAlternate

[root@ltm01:Active] config # snmptranslate -On F5-BIGIP-GLOBAL-MIB::gtmPoolStatFallback

[root@ltm01:Active] config # snmptranslate -On F5-BIGIP-GLOBAL-MIB::gtmPoolStatDropped

[root@ltm01:Active] config # snmptranslate -On F5-BIGIP-GLOBAL-MIB::gtmPoolStatReturnToDns

If you do an snmpwalk on one of the data points above, you'll see that the pool name is appended to the strings above to make the oid string necessary to poll the statistic for that pool (text & numeric shown, in the numeric representation, I've highlighted the root in blue and the indexed value in red):

[root@ltm01:Active] config # snmpwalk -v 2c -c public localhost .
F5-BIGIP-GLOBAL-MIB::gtmPoolStatPreferred."gpool1" = Counter64: 33
F5-BIGIP-GLOBAL-MIB::gtmPoolStatPreferred."gpool2" = Counter64: 68
F5-BIGIP-GLOBAL-MIB::gtmPoolStatPreferred."gpool3" = Counter64: 101

[root@ltm01:Active] config # snmpwalk -v 2c -c public -On localhost .
. = Counter64: 33
. = Counter64: 68
. = Counter64: 101

Create the XML Query File

Now that we have our data, we need to build the XML file that Cacti will reference for building the oid strings for the graphs.  The oid index is the string we discovered that returns the pool names.  The input values are the index and the pool name, the output values are the data points we want to graph.  Following Cacti's SNMP Query XML Syntax, we can generate our file:

  <name>Get F5 GTM Pool Statistics</name>










This file needs to be saved to the <cacti_path>/resource/snmp_queries/ directory.  I called it f5_gtm_poolStat.xml. Make sure the permissions are such that Cacti can read the file. 

Into the Cacti GUI

The work under the hood is complete, now we can move into the Cacti GUI.  For this step, I've recorded a video of the process.



The scripts I used in perl and powershell to generate the DNS requests are below.  Note that the perl script I saved as a file for reuse, whereas the powershell script is a one-liner at the command line.



use strict;
use warnings;

my $host = ARGV[0];
my $wip = ARGV[1];
my $count_max = ARGV[2];

for( my $count = 0; $count <= $count_max; $count++ ) {
  system("dig \@$host @wip +nocomments +noquestion +nocmd +nocl +noauthority | grep $wip.*A | cut -f 5");


for($i=0; $i -le 50000; $i++) { nslookup }