Cacti Interface Traffic Graph

Dress Up Your Cacti Graphs

Cacti has been around for over a decade and is a terrific tool for graphing everything on your network from interface traffic to temperature and voltage. Unfortunately the default templates give you bland-looking graphs. Since you’re going to be eying your graphs on a daily basis why not give them a little more pizzazz? The information presented in this post can be also be found by scouring the Cacti forums. I’ve taken the best ideas, added my own enhancements, and consolidated them down to a single step-by-step process.

What Will My Graphs Look Like?

There are a lot of examples of custom graph templates on the Cacti forums (links at the end of this post) with folks doing everything from graphing on the negative axis to using non-conventional colors. It’s all a matter of personal preference, so experiment and find something that works for you.

My graphs stick with the classical Cacti graph colors of green for inbound traffic and blue for outbound.

Here are a few examples of how graphs using my template settings look:

Cacti-Thumbnail-Previews

Cacti Interface Traffic Graph

Cacti Interface Graph

Instructions

There are five steps for dressing up your graphs…

1. Make full use of your Interface “description” field

Put as much relevant information as you can in the description field for every physical and virtual interface on your devices. You want to know exactly what each interface is connected to when looking at the graphs.

Personally I like to use the following standards for each connection type:

  • Port-Channel Interface
    hostname: interface1,interface2…interface x
    (config-if)# description SW-R03-01A: G0/26,28
  • Port-Channel Member
    hostname: interface [Port-Channel ID]
    (config-if)# description SW-R03-01A: G0/26 [Po12] 
  • Virtual Port-Channel Member
    hostname: interface [vPC ID]
    (config-if)# description SW-R08-02A: Te1/1 [vpc10]
  • Hosts
    hostname: interface
    (config-if)# description DNS01: eth0
  • VLAN Interface
    IP Subnet <VLAN-description>
    (config-if)# description 10.3.0.0/22 Ads

2. Add leading numerals to the name of each graph template

When you apply multiple graph templates to a host they will be ordered alphabetically. If you have a preference for which types of graphs are displayed first (I want Traffic before Errors), you’ll have to change the graph template name to reflect it.

Easiest way to do this is by adding numerals:

cacti-graph-template-number

3. Modify the Title field in the “Interface – Traffic (bits/sec)” Graph Template

Add some variables to the Title field and tell Cacti to name all of the graphs it creates accordingly. Please note that you need to un-check the box for “Use Per-Graph Value (Ignore this Value)”, otherwise it won’t be displayed. Here’s the string to paste in:

|host_description| – |query_ifName| – |query_ifAlias| – Traffic

cacti-template-title

4. Add Graph Template Items

The default look of the “Interface – Traffic (bits/sec)” graphs are to have Inbound traffic represented by green shaded areas and Outbound traffic represented by blue lines. We want to change this so the Outbound and Inbound traffic are both represented by lines and shaded area. In order for this to work, we need to change the opacity of the shaded areas so that they don’t cancel one another out.

So let’s add blue shading to our graph by creating a new AREA Graph Item Type.

From within the “Interface – Traffic (bits/sec)” template click “Add” in the Graph Template Items and configure a new AREA item as shown below and save it.

cacti-blue-area

Let’s repeat the process to add a green line to our Inbound traffic graphs using the settings below and save it.

Note: “Line 1” is a thin line, “Line 2” is medium, and “Line 3” is very thick.

cacti-green-line

Now let’s reduce the opacity of the AREA Graph Item Type for Inbound traffic from 100% to 20%. We are going to use 20% rather than 10% so the blue shading doesn’t drown out too much of the green when the graphs overlap.

cacti-green-area

Now that you have everything added in, it’s time to order them properly. Use the up/down arrows and position your new Graph Template Items as shown:

cacti-order-graph-items

Once you are done save the template.

5. Update Visualization Settings

Now we need to make sure our graphs can display all the useful description information we added to our interface descriptions in Step#1 by changing fonts and increasing the Maximum Title Length.

Go to the Cacti Configuration Settings page and select the “Visual” tab. Adjust the Maximum Title Length, Maximum Field Length, and Font settings similar to the screen shot below. If you want to experiment with different fonts, be sure to use the pango convention for font names.

cacti-visual

Note: The secret to getting the legend data in your graphs to line up nicely is by using a mono-space font, such as Courier New and including a Hard Return on the last item in the Graph Template Items. This can be seen in the last screenshot of Step #4 and is denoted as <HR>.

That’s it! You’re graphs should now be looking 10x better than before you started the process! Aren’t you glad you did it?

Troubleshooting

Problem: The traffic data in my graph is incorrect

  1. Be sure your graphs are created with the “In/Out Bits (64-bit Counters)” Graph Template

Problem: New graph template names are not appearing on new graphs

  1. Go back to the Graph Template and open it for editing, but do nothing other than save it. This should re-apply the new names.
  2. Run the poller_graphs_reapply_names.php script from your cacti installation directory. Be sure to do this from the account cacti is running under so you don’t mess up file permissions.
  3. Make the Title string listed in Step #3 the default for the “In/Out Bits (64-bit Counters)” Data Query Graph Template. Go to Console ->Data Queries -> SNMP Interface Statistics -> In/Out Bits (64-bit Counters) and set like this:

cacti-64bits

Summary

Although the focus of this post will be Interface Traffic graphs, the principles outlined can be applied to any and all types of Cacti graphs. Enjoy!

References

http://forums.cacti.net/about22275.html
http://forums.cacti.net/viewtopic.php?f=21&t=46680
http://forums.cacti.net/viewtopic.php?p=214839
http://forums.cacti.net/viewtopic.php?t=25415
http://www.cacti.net/downloads/docs/html/variables.html
http://forums.cacti.net/about34680.html

//

9 comments

  1. nice tips …. i have one question … is it possible to ignore ifAlias when this field is blank? When the value is empty i am getting |query_ifAlias|

    1. Unfortunately there is no way for it to ignore the variable declaration if it comes back blank. You can either create an identical template without the “|query_ifName|” declaration and use it for devices which don’t have interface descriptions, or just set a generic description of “-“.

  2. There is a gotcha when trying to prettify the interface graphs which utilize the Sum function. Adding a second graph item breaks the Sum calculations. If I had to venture a guess, that is why all the distributed traffic graphs are identical (and bland). 😉

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s