********************
UPDATE: I failed to mention below that I also had to modify the file rrd.php as documented by "KC" about midway down on this link: http://forums.cacti.net/viewtopic.php?t=3030
********************
I wanted a quick way to skim through a group of similar graphs and have things needing attention jump out at me. I like using auto-scale graphs to see as much detail as possible. With it though, spikes are meaningless unless you take time to look at the scale on the left. OK for a couple of graphs, but if you want to look at the circuit utilization on 40 circuits, it gets to be more time consuming.
After 3 days of pulling my hair out fighting with data sources and CDEF's, I finally got this going. I'm using it for circuit utilization, but it could be massaged into pretty much anything. The example below isn't the most exciting... It's the weekend, so there's not much action on any of the circuits at the moment, but you can get an idea of what I mean.
Ok, so here's what I ultimately did... I've tried to make this as simple as possible so that anyone can follow it regardless of experience. (I've been a noob too!) That said, this is long.............
You need a lot of CDEF's, so let's do those first. It may be common knowledge, but I finally figured out the hard way that instead of hand building big long CDEF statements, you can just copy a string you've put together in Notepad (or wherever) into a single Custom String and shave a LOT of time off of the process. We'll do it that way.
1) Navigate to the CDEF section of Cacti
2) Click "Add"
1) Give the new CDEF a name. We'll call the first one "Bandwidth Percentage - 0 to 10%"
2) Click "Create"
1) We now have a new CDEF, but no formula defined. Click "Add" to enter a new statement.
1) Here's where the shortcut comes in. Change the CDEF Item Type to "Custom String".
2) Copy the string below and paste it into the "CDEF Item Value" field.
Code: Select all
a,b,+,|query_ifSpeed|,/,100,*,8,*,10,LE,a,b,+,|query_ifSpeed|,/,100,*,8,*,0,GT,NEGINF,UNKN,IF,UNKN,IF
1) Notice that the CDEF formula has now updated.
2) Click "Save".
One down, 12 to go! Repeat the procedure above to create each of the CDEF statements below.
Name: Bandwidth Percentage - 10 to 20%
Code: Select all
a,b,+,|query_ifSpeed|,/,100,*,8,*,20,LE,a,b,+,|query_ifSpeed|,/,100,*,8,*,10,GT,NEGINF,UNKN,IF,UNKN,IF
Code: Select all
a,b,+,|query_ifSpeed|,/,100,*,8,*,30,LE,a,b,+,|query_ifSpeed|,/,100,*,8,*,20,GT,NEGINF,UNKN,IF,UNKN,IF
Code: Select all
a,b,+,|query_ifSpeed|,/,100,*,8,*,40,LE,a,b,+,|query_ifSpeed|,/,100,*,8,*,30,GT,NEGINF,UNKN,IF,UNKN,IF
Code: Select all
a,b,+,|query_ifSpeed|,/,100,*,8,*,50,LE,a,b,+,|query_ifSpeed|,/,100,*,8,*,40,GT,NEGINF,UNKN,IF,UNKN,IF
Code: Select all
a,b,+,|query_ifSpeed|,/,100,*,8,*,60,LE,a,b,+,|query_ifSpeed|,/,100,*,8,*,50,GT,NEGINF,UNKN,IF,UNKN,IF
Code: Select all
a,b,+,|query_ifSpeed|,/,100,*,8,*,70,LE,a,b,+,|query_ifSpeed|,/,100,*,8,*,60,GT,NEGINF,UNKN,IF,UNKN,IF
Code: Select all
a,b,+,|query_ifSpeed|,/,100,*,8,*,80,LE,a,b,+,|query_ifSpeed|,/,100,*,8,*,70,GT,NEGINF,UNKN,IF,UNKN,IF
Code: Select all
a,b,+,|query_ifSpeed|,/,100,*,8,*,90,LE,a,b,+,|query_ifSpeed|,/,100,*,8,*,80,GT,NEGINF,UNKN,IF,UNKN,IF
Code: Select all
a,b,+,|query_ifSpeed|,/,100,*,8,*,5000,LE,a,b,+,|query_ifSpeed|,/,100,*,8,*,90,GT,NEGINF,UNKN,IF,UNKN,IF
Code: Select all
CURRENT_DATA_SOURCE,|query_ifSpeed|,/,100,*,8,*
Code: Select all
ALL_DATA_SOURCES_NODUPS,|query_ifSpeed|,/,100,*,8,*
Name: Turn Bytes into Bits
Code: Select all
CURRENT_DATA_SOURCE,8,*
All right. That takes care of entering the CDEF's. Before we leave them completely though, I want to explain a couple of things... I tried hopelessly for many many hours trying to get various combinations of the special "All Data Sources, No Dup's" and "Similar Data Sources, No Dup's" to work. I could get close sometimes, but it never quite worked. I ultimately placed variables in the CDEF (Notice the two sets of "a" and "b" in the code below... That's them).
Code: Select all
a,b,+,|query_ifSpeed|,/,100,*,8,*,40,LE,a,b,+,|query_ifSpeed|,/,100,*,8,*,30,GT,NEGINF,UNKN,IF,UNKN,IF
Enough CDEF's. Onward!
Next you need to download the circ_util.xml attachment in this message and save it to a location of your choosing. We need to use it to import the graph template and save you a little work. I'm going to spare the details, but just go to the "Import/Export" section of Cacti's menu bar, select "Import Templates", browse to the folder you saved the file to, select "circ_util.xml", then click the "Save" button. You should see a screen showing the successful import.
Of note here... I have sorted my color pallet as per "byrons" guidelines here: http://forums.cacti.net/about6308.html&highlight=colors
Because of that, you'll probably get some wacky colors if you haven't done the same. It is not necessary to resort your colors, but you probably will want to go back into your new graph template and change the colors of each line into something that makes more sense. Mine looks like this:
If you know what you're doing, you should be able to manually make graphs at this point. I went ahead and made this part of the SNMP Interface Statistics Data Query though so that it is easily reachable when I'm adding new devices. Let's add that...
1) Select "Data Queries" from the menu.
2) Select "SNMP - Interface Statistics" from the options.
1) Select "Add" to add a new Associated Graph Template.
1) Give it a meaningful name. I chose "Circuit Utilization - Summary". This is what will show up in the drop-down menu when making new graphs.
2) Select the graph template. If you've imported mine, it should be called "Interface - Circuit Utilization Summary"
3) Select the "ifInOctets (Bytes In)" option from the drop-down to match this up with the "traffic_in" Data Source.
4) Select the "ifOutOctets (Bytes Out)" option from the drop-down to match this up with the "traffic_out" Data Source.
5) To help keep your Data Sources organized, give it a name here to make it recognizable and unique. I chose:
Code: Select all
|host_description| - Ckt Util - |query_ifName|
7) Click the "Add" button.
8) Along similar lines as above, you will want for your graphs to have a meaningful and unique name. Enter as many titles as you'd like, but take note that Cacti always uses the one at the top of the list when making new graphs, so you may have to come back and re-sort these depending on your needs at the time. I added a ton, but chopped the list down to a couple for the screenshot below. In this case, I would go in and make new graphs from my "Atlanta B" router... Adding 10 - 15 VPN tunnels to this graph template. Each graph would be created called "Circuit Utilization Summary - Dixie to Atlanta "B" SomeTunnelName". I then go back in under Graph Management and change my generic "Dixie" to the appropriate city for each graph. So an example of what I entered here is:
Code: Select all
Circuit Utilization Summary - Dixie to Atlanta "B" |query_ifDescr|
10) Click "Add".
11) Once you have added all of the template names and graph titles that you need, click the "Save" button.
Now when you go to add a new device (or modify an existing one) and choose to "Create Graphs for this Host" you will see "Circuit Utilization - Summary" in your option of graphs to create assuming that you have chosen a Host Template ("Cisco Router", "Windows 2000/XP Host", etc.) that uses the "SNMP - Interface Statistics" Data Query to scan the host for interfaces that it has.
I'm pretty sure that encompasses everything that I did. I do have one last note though... In Cisco-world (and others, I'm sure) if you are doing this graph for tunnel interfaces (or other non-physical ones), you will need to modify the tunnel interface by adding the "bandwidth x" (where "x" is the speed of the circuit in kilobits... 1000 = 1Mb) line to each tunnel. I've used Cacti's |query_ifDescr| command extensively to obtain the bandwidth necessary for the math to calcualte the percentage used. Most physical interfaces should return a value to this request just fine w/o any extra work, but keep it in mind on tunnels and serial sub-interfaces.
I hope that you have found this useful! I need to throw in the disclaimer that this tutorial was written with the assistance of a few beers... I think I covered everything I did, but I will edit it accordingly if need-be.
Best of luck,
Jason