[HOWTO] Color coded percent utilization

If you figure out how to do something interesting/cool in Cacti and want to share it with the community, please post your experience here.

Moderators: Developers, Moderators

Post Reply
User avatar
timi
Cacti User
Posts: 240
Joined: Wed Nov 09, 2005 8:35 am
Location: Timisoara, Romania
Contact:

Post by timi »

I am trying to use this template but I get an error:

Code: Select all

RRDTool Command:
/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Circuit Utilization Summary - Dixie to Atlanta \"B\" GigabitEthernet " \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="Percent" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:10: \
--font UNIT:8: \
DEF:a="/var/www/htdocs/cacti/rra/fttb-aries-4_traffic_in_6088.rrd":traffic_in:LAST \
DEF:b="/var/www/htdocs/cacti/rra/fttb-aries-4_traffic_in_6088.rrd":traffic_out:LAST \
DEF:c="/var/www/htdocs/cacti/rra/fttb-aries-4_traffic_in_6088.rrd":traffic_in:AVERAGE \
DEF:d="/var/www/htdocs/cacti/rra/fttb-aries-4_traffic_in_6088.rrd":traffic_out:AVERAGE \
CDEF:cdefa=a,1000000000,/,100,*,8,* \
CDEF:cdefb=b,1000000000,/,100,*,8,* \
CDEF:cdefc=a,b,+,1000000000,/,100,*,8,*,10,LE,a,b,+,1000000000,/,100,*,8,*,0,GT,NEGINF,UNKN,IF,UNKN,IF \
CDEF:cdefd=a,b,+,1000000000,/,100,*,8,*,30,LE,a,b,+,1000000000,/,100,*,8,*,20,GT,NEGINF,UNKN,IF,UNKN,IF \
CDEF:cdefe=a,b,+,1000000000,/,100,*,8,*,50,LE,a,b,+,1000000000,/,100,*,8,*,40,GT,NEGINF,UNKN,IF,UNKN,IF \
CDEF:cdeff=a,b,+,1000000000,/,100,*,8,*,70,LE,a,b,+,1000000000,/,100,*,8,*,60,GT,NEGINF,UNKN,IF,UNKN,IF \
CDEF:cdefg=a,b,+,1000000000,/,100,*,8,*,90,LE,a,b,+,1000000000,/,100,*,8,*,80,GT,NEGINF,UNKN,IF,UNKN,IF \
CDEF:cdefh=a,b,+,1000000000,/,100,*,8,*,20,LE,a,b,+,1000000000,/,100,*,8,*,10,GT,NEGINF,UNKN,IF,UNKN,IF \
CDEF:cdefi=a,b,+,1000000000,/,100,*,8,*,40,LE,a,b,+,1000000000,/,100,*,8,*,30,GT,NEGINF,UNKN,IF,UNKN,IF \
CDEF:cdefj=a,b,+,1000000000,/,100,*,8,*,60,LE,a,b,+,1000000000,/,100,*,8,*,50,GT,NEGINF,UNKN,IF,UNKN,IF \
CDEF:cdefba=a,b,+,1000000000,/,100,*,8,*,80,LE,a,b,+,1000000000,/,100,*,8,*,70,GT,NEGINF,UNKN,IF,UNKN,IF \
CDEF:cdefbb=a,b,+,1000000000,/,100,*,8,*,5000,LE,a,b,+,1000000000,/,100,*,8,*,90,GT,NEGINF,UNKN,IF,UNKN,IF \
CDEF:cdefbe=c,8,* \
CDEF:cdefbh=a,8,* \
CDEF:cdefbj=c,1000000000,/,100,*,8,* \
CDEF:cdefce=d,8,* \
CDEF:cdefch=b,8,* \
CDEF:cdefcj=d,1000000000,/,100,*,8,* \
AREA:cdefa:""  \
AREA:cdefb:"":STACK \
AREA:cdefc#3ACE0CFF:" 0 - 10%":STACK \
AREA:cdefd#99FF99FF:"20 - 30%":STACK \
AREA:cdefe#FFFF00FF:"40 - 50%":STACK \
AREA:cdeff#FF8C1AFF:"60 - 70%":STACK \
AREA:cdefg#FF3333FF:"80 - 90%\n":STACK \
AREA:cdefh#00FF00FF:"10 - 20%":STACK \
AREA:cdefi#FFFF80FF:"30 - 40%":STACK \
AREA:cdefj#FFA54CFF:"50 - 60%":STACK \
AREA:cdefba#FF5F00FF:"70 - 80%":STACK \
AREA:cdefbb#FF0000FF:"90 - 100%\n":STACK \
COMMENT:"CIRCUIT SPEED\:         1000000000 bits per second\n"  \
COMMENT:"INBOUND TRAFFIC RATE"  \
GPRINT:cdefbe:AVERAGE:" Avg\:%8.2lf%s"  \
GPRINT:cdefbe:MIN:"Min\:%8.2lf%s"  \
GPRINT:cdefbe:MAX:"Max\:%8.2lf%s"  \
GPRINT:cdefbh:LAST:"Current\:%8.2lf%s\n"  \
COMMENT:"INBOUND TRAFFIC %"  \
GPRINT:cdefbj:AVERAGE:"    Avg\:(%5.2lf %%)"  \
GPRINT:cdefbj:MIN:"Min\:(%5.2lf %%)"  \
GPRINT:cdefbj:MAX:"Max\:(%5.2lf %%)"  \
GPRINT:cdefa:LAST:"Current\:(%5.2lf %%)\n"  \
COMMENT:"OUTBOUND TRAFFIC RATE"  \
GPRINT:cdefce:AVERAGE:"Avg\:%8.2lf%s"  \
GPRINT:cdefce:MIN:"Min\:%8.2lf%s"  \
GPRINT:cdefce:MAX:"Max\:%8.2lf%s"  \
GPRINT:cdefch:LAST:"Current\:%8.2lf%s\n"  \
COMMENT:"OUTBOUND TRAFFIC %"  \
GPRINT:cdefcj:AVERAGE:"   Avg\:(%5.2lf %%)"  \
GPRINT:cdefcj:MIN:"Min\:(%5.2lf %%)"  \
GPRINT:cdefcj:MAX:"Max\:(%5.2lf %%)"  \
GPRINT:cdefb:LAST:"Current\:(%5.2lf %%)\n"  \
COMMENT:"TOTAL DATA MOVED"  \
COMMENT:"     Inbound\: 2.2 GB"  \
COMMENT:"Outbound\: 1.24 GB" 
RRDTool Says:

ERROR: the RRD does not contain an RRA matching the chosen CF

anybody can help me with this ?
jay
Cacti User
Posts: 390
Joined: Wed Aug 31, 2005 8:55 am
Location: Bristol, England

Post by jay »

This post may help you

http://forums.cacti.net/post-122652.html

Jay
Cacti Version 0.8.7e, Spine 0.8.7e, Apache 2.2.15, Mysql 5.0.88, PHP 5.2.13, RRDTool 1.2.30, NET-SNMP 5.5
Quad Core AMD Opteron Processor 2384, 2.70Ghz, 2GB RAM , 1 CPU used
Windows Server 2003 (X64), VMWARE ESX
Plugins: Aggregate 0.75

SYSTEM STATS: Time:12.5140 Method:spine Processes:2 Threads:15 Hosts:400 HostsPerProcess:200 DataSources:2909 RRDsProcessed:1384
User avatar
timi
Cacti User
Posts: 240
Joined: Wed Nov 09, 2005 8:35 am
Location: Timisoara, Romania
Contact:

Post by timi »

jay wrote:This post may help you

http://forums.cacti.net/post-122652.html

Jay
same error even with the new lib/functions.php :(
maybe I'm not doing something right ?
windexh8er
Posts: 11
Joined: Wed Feb 27, 2008 1:18 pm

So.........

Post by windexh8er »

I get this:

Code: Select all

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-14400 \
--end=-60 \
--title="Circuit Utilization - Summary - Serial1/0" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="Percent" \
--slope-mode \
--font TITLE:10: \
--font AXIS:8: \
--font LEGEND:8: \
--font UNIT:8: \
DEF:a="/var/www/html/rra/burr_ridge_ce_01_62_6_83_197_traffic_in_66.rrd":traffic_in:LAST \
DEF:b="/var/www/html/rra/burr_ridge_ce_01_62_6_83_197_traffic_in_66.rrd":traffic_out:LAST \
DEF:c="/var/www/html/rra/burr_ridge_ce_01_62_6_83_197_traffic_in_66.rrd":traffic_in:AVERAGE \
DEF:d="/var/www/html/rra/burr_ridge_ce_01_62_6_83_197_traffic_in_66.rrd":traffic_out:AVERAGE \
CDEF:cdefa=a,15037000,/,100,*,8,* \
CDEF:cdefb=b,15037000,/,100,*,8,* \
CDEF:cdefc=a,b,+,15037000,/,100,*,8,*,10,LE,a,b,+,15037000,/,100,*,8,*,0,GT,NEGINF,UNKN,IF,UNKN,IF \
CDEF:cdefd=a,b,+,15037000,/,100,*,8,*,20,LE,a,b,+,15037000,/,100,*,8,*,10,GT,NEGINF,UNKN,IF,UNKN,IF \
CDEF:cdefe=a,b,+,15037000,/,100,*,8,*,30,LE,a,b,+,15037000,/,100,*,8,*,20,GT,NEGINF,UNKN,IF,UNKN,IF \
CDEF:cdeff=a,b,+,15037000,/,100,*,8,*,40,LE,a,b,+,15037000,/,100,*,8,*,30,GT,NEGINF,UNKN,IF,UNKN,IF \
CDEF:cdefg=a,b,+,15037000,/,100,*,8,*,50,LE,a,b,+,15037000,/,100,*,8,*,40,GT,NEGINF,UNKN,IF,UNKN,IF \
CDEF:cdefh=a,b,+,15037000,/,100,*,8,*,70,LE,a,b,+,15037000,/,100,*,8,*,60,GT,NEGINF,UNKN,IF,UNKN,IF \
CDEF:cdefi=a,b,+,15037000,/,100,*,8,*,60,LE,a,b,+,15037000,/,100,*,8,*,50,GT,NEGINF,UNKN,IF,UNKN,IF \
CDEF:cdefj=a,b,+,15037000,/,100,*,8,*,80,LE,a,b,+,15037000,/,100,*,8,*,70,GT,NEGINF,UNKN,IF,UNKN,IF \
CDEF:cdefba=a,b,+,15037000,/,100,*,8,*,90,LE,a,b,+,15037000,/,100,*,8,*,80,GT,NEGINF,UNKN,IF,UNKN,IF \
CDEF:cdefbb=a,b,+,15037000,/,100,*,8,*,5000,LE,a,b,+,15037000,/,100,*,8,*,90,GT,NEGINF,UNKN,IF,UNKN,IF \
CDEF:cdefbe=c,8,* \
CDEF:cdefbh=a,8,* \
CDEF:cdefbj=c,15037000,/,100,*,8,* \
CDEF:cdefce=d,8,* \
CDEF:cdefch=b,8,* \
CDEF:cdefcj=d,15037000,/,100,*,8,* \
AREA:cdefa:""  \
AREA:cdefb:"":STACK \
AREA:cdefc#3ACE0C:" 0 - 10%":STACK \
AREA:cdefd#00FF00:"10 - 20%":STACK \
AREA:cdefe#99FF99:"20 - 30%":STACK \
AREA:cdeff#FFFF80:"30 - 40%":STACK \
AREA:cdefg#FFFF00:"40 - 50%":STACK \
AREA:cdefh#FF8C1A:"60 - 70%":STACK \
AREA:cdefi#FFA54C:"50 - 60%":STACK \
AREA:cdefj#FF5F00:"70 - 80%":STACK \
AREA:cdefba#FF3333:"80 - 90%\n":STACK \
AREA:cdefbb#FF0000:"90 - 100%\n":STACK \
COMMENT:"CIRCUIT SPEED\:         15037000 bits per second\n"  \
COMMENT:"INBOUND TRAFFIC RATE"  \
GPRINT:cdefbe:AVERAGE:" Avg\:%8.2lf%s"  \
GPRINT:cdefbe:MIN:"Min\:%8.2lf%s"  \
GPRINT:cdefbe:MAX:"Max\:%8.2lf%s"  \
GPRINT:cdefbh:LAST:"Current\:%8.2lf%s\n"  \
COMMENT:"INBOUND TRAFFIC %"  \
GPRINT:cdefbj:AVERAGE:"    Avg\:(%5.2lf %%)"  \
GPRINT:cdefbj:MIN:"Min\:(%5.2lf %%)"  \
GPRINT:cdefbj:MAX:"Max\:(%5.2lf %%)"  \
GPRINT:cdefa:LAST:"Current\:(%5.2lf %%)\n"  \
COMMENT:"OUTBOUND TRAFFIC RATE"  \
GPRINT:cdefce:AVERAGE:"Avg\:%8.2lf%s"  \
GPRINT:cdefce:MIN:"Min\:%8.2lf%s"  \
GPRINT:cdefce:MAX:"Max\:%8.2lf%s"  \
GPRINT:cdefch:LAST:"Current\:%8.2lf%s\n"  \
COMMENT:"OUTBOUND TRAFFIC %"  \
GPRINT:cdefcj:AVERAGE:"   Avg\:(%5.2lf %%)"  \
GPRINT:cdefcj:MIN:"Min\:(%5.2lf %%)"  \
GPRINT:cdefcj:MAX:"Max\:(%5.2lf %%)"  \
GPRINT:cdefb:LAST:"Current\:(%5.2lf %%)\n"  \
COMMENT:"TOTAL DATA MOVED"  \
COMMENT:"     Inbound\: 0 bytes"  \
COMMENT:"Outbound\: 0 bytes" 
...which (to me) looks OK. But no graphs ever get generated?!?!??
User avatar
nebj00la
Cacti User
Posts: 112
Joined: Fri Feb 17, 2006 9:02 pm
Location: Massachusetts, USA
Contact:

Post by nebj00la »

Since I couldn't find anything in this thread, I've attached the template for in/out with positive/negative representation. Please let me know if there are any errors!
Attachments
cacti_graph_template_interface_-_circuit_utilization_summary.xml
(51.6 KiB) Downloaded 744 times
Thanks,
nebj00la
davesmith87
Posts: 2
Joined: Thu Aug 30, 2012 10:19 am

Re: [HOWTO] Color coded percent utilization

Post by davesmith87 »

Hello,

Can someone explain to me how I can get this to work on 1GB? I'm using the original graph templates from the original post. I've changed the data queries to use ifHCinOctets and ifHCOutOctets already (saw that earlier in the post).

However, I can't seem how to figure out where to edit this in the graph template. I know this thread is old but any help would be appreciated.
jimcjulsonjr
Posts: 48
Joined: Fri Dec 07, 2012 11:11 am

Re:

Post by jimcjulsonjr »

SRY wrote:To reply to cjennings_cr post there are a number of explanations on CDEFs on the net but it still took me a awhile to understand how they work. CDEFs use reverse polish notation to calculate there answers and uses a stack to process variables, numbers and operations. I will try and explain the basic CDEF and one of the ones used in my graph posted before.

Note that by putting together this info document I have discovered a problem with my previously posted CDEFs which I will repost.

I hasten to add that I am no CDEF expert and what I am posting is mainly found by research and a lot of trial and error.

Simple form:

In Cacti there are a number of ways to identify variables that are used in the graph the following two examples would produce the same result if there was only one data source, Where “CURRENT_DATA_SOURCE” and “a” are the same variable. Take the graph that I posted earlier in this thread this uses two data sources and I have elected to call the “a” and “b” as per jas0420 original post. These relate to Data Source [traffic_in] and Data Source [traffic_out] in this example, if you have four Data Sources then you could have variables a,b,c,d for instance. The variable letter is relative to the order of the data sources are ordered in the graph template.

CURRENT_DATA_SOURCE,8,*

or

a,8,*

The above calculation converts bytes into bits. Variable “a” is the value obtained by the poll of the device from Cacti for our example here we will give “a” a value of 32 KBytes, therefore:

a,8,* will equate to 32000,8,* this can be turned into 32000 * 8 which equals 256000 bits.


so 32000 is placed on the stack and then 8 is placed on the stack then an multiple is places on the stack, all three entireties are replaced by 256000, CDEFs must only return one value if not you will get a lot of warnings about invalid CDEFs and your graphs will not display.

Now lets try something a bit more challenging, this is for the positive side of the graph where the value is between 0 and 10% of the interfaces throughput.

a,8,*,|query_ifSpeed|,/,100,*,10,LE,a,8,*,|query_ifSpeed|,/,100,*,0,GT,a,8,*,UNKN,IF,UNKN,IF

Here we have a number of variables:

“a” which is the number of bytes at the time of the sample.
“|query_ifSpeed|” which is the value defined by the Bandwidth statement on a Cisco in this example, this value could be replaced with the maximum bandwidth of the interface. This value is defined in bits.

The stack is empty and then we put the following in:

a,8,* this will convert the bytes into bits 32000,8,* and is equal to 256000

the stack now contains 256000 and the next part of the CDEF is placed on the stack

256000,|query_ifSpeed|,/, this would be 256000,6900000,/ and equal 0.037101449275362318840579710144928

Our internet link is 6900 Kbits as defined on the router and is listed as 6900000 in Cacti interface speed on the devices page.

The stack now contains the number 0.037101449275362318840579710144928

To this we add 100 and then a multiply operation

0.037101449275362318840579710144928,100,/ and is equal to 3.7101449275362318840579710144928.

The stack now contains 3.7101449275362318840579710144928

We then push 10 to the stack and the LE operation (Less than or equal to).

3.7101449275362318840579710144928,10,LE

“LE” compares the first value to the second and if it is true returns 1, false returns 0, in this case 3.7101449275362318840579710144928 is less than 10 so 1 is placed on the stack.

1

Now we check to see if the a,8,*,|query_ifSpeed|,/,100,* is grater than zero.

The calculation needs to be done again as the only value on the stack is 1 at the moment so after the above calculation we have the following in the stack:

1, 3.7101449275362318840579710144928

We now add 0 and do the comparison so the stack looks like this:

1, 3.7101449275362318840579710144928,0,GT

GT will pop 3.7101449275362318840579710144928 and 0 from the stack and as 3.7101449275362318840579710144928 is greater than zero it will place 1 on the stack.

The stack is now contains

1,1

now we will add the following calculation to the stack


a,8,*

This will add 32000,8 and the multiply variable to the stack:

1,1,32000,8,*

the multiple operator will take 32000 and 8 from the stack and return 256000 so the following this the stack contains

1,1,256000

Now we are moving into the IF function of the CDEF the next two items added to the stack are:

UNKN,IF

UNKN is a function to represent an unknown number.

So the stack looks like this

1,1,256000, UNKN,IF

The IF function pops three values from the stack in this case:

1,256000,UNKN

the IF function looks at the left hand most function and if it is 0 it will return the middle value or if it is 1 then it will return the right most value. So in our case it returns 256000 as the left hand variable is 1.

The stack now looks like this

1,256000

The second “IF” statement is now executed so the stack looks like this

1,256000, UNKN,IF

Here again the 1 indicates that the IF statement is true, therefore the result of the CDEF is

256000 and this is what is plotted as an area on the graph.

If the answer had been 0 then UNKN would be returned, UNKN can not be graphed.

NEGINF and INF define infinity in the graph and is used to plot a area from a point to the upper, INF, or lower, NEGINF, border of the graph and hence why you can not use it in a graph that uses both positive and negative values as the would overwrite each other.


I hope this help with your understanding of CDEFs and lets you explore there potential a bit more.

:lol:

So, I know this post is older than Moses, but you did an AMAZING job of walking folks through the operation of the CDEFs in excellent detail, and I just wanted to say thank you. that helped me TREMENDOUSLY!
-------------------------------------

VERSION: Cacti 0.8.8b
POLLER: Spine
DATA SOURCES: 100,000K and Growing (Multiple Servers)
PLUGINS: AUTOM8, THOLD, DISCOVER, WEATHERMAP, BOOST, CLOG, NECTAR, MACTRACK, FLOWVIEW, SPIKEKILL, INTROPAGE, MONITOR
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests