[HOWTO] Graph displaying average of several other hosts

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

widowss
Posts: 2
Joined: Sun Aug 24, 2008 6:00 pm

help me to combine the datas

Post by widowss »

thanks jas0420 very much , i still have some problems , :cry:
firstly ,i will describe what i want to be. i want to add all the onlines users .
there are 3 data soruces. for example , 52g1,52g2,52g3

first key point
the cdef i wrote is a,b,+,c,+
is this right?the copy is below

CDEF's [edit: total 5200g online users]
Name
A useful name for this CDEF.

cdef=a,b,+,c,+


CDEF Items Add
Item Item Value
Item #1 Custom String: a,b,+,c,+ Move Down Move Up Delete

second point is step 35 in your post
since i have 3 data sources ,so i created "Graph Item Inputs",pls see the attachment. the problem is when i click into the first "Graph Item Inputs",i can not find all the graph items,pls see the attach. only the first item " Item #1: AREA (LAST) " there ,why?


third problem is step 44 in your post
there are 3 pull-down, i selected 3 different sources. but ,but, the infomation below this page is "error" , pls see the attach.

i did make mistakes , but i don't know how to correct it, thank you very muck.
Attachments
i can not find all the graph items
i can not find all the graph items
c1.PNG (81.07 KiB) Viewed 31373 times
i can not find all the graph items
i can not find all the graph items
c2.PNG (76.41 KiB) Viewed 31373 times
error info
error info
c3.PNG (75.27 KiB) Viewed 31373 times
dbuchner
Posts: 16
Joined: Thu Mar 13, 2008 7:01 pm
Location: Sydney
Contact:

Post by dbuchner »

HI,

I am trying to figure out where I am going wrong with the CDEF's/calc which I am trying to graph and would appreciate some feedback/comments to solve this.

I am trying to create an aggregate graph of two CPU graphs. Each CPU graph has System, User and Nice DS' available.
To calculate the total CPU utilization I combine System (Kernel+Wait) with User to get the total CPU utilization of the host. (6 DEF's total per host)
Each graph has an additional Total line showing.

When aggregating the two graphs the calculations no longer correct since rrd tries to total all DEF's and then devide by two. To make this very simple on my feeble brain I removed the Max DEF's as well since I am not really interested in these anyway. Leaving 3 DEF's per host which require totaling on a per host type basis.

Code: Select all

DEF:a="/usr/local/apache2/htdocs/rra/ngpmr1dr01_cpu_system_911.rrd":cpu_system:AVERAGE \
DEF:c="/usr/local/apache2/htdocs/rra/ngpmr1dr01_cpu_user_912.rrd":cpu_user:AVERAGE \
DEF:e="/usr/local/apache2/htdocs/rra/ngpmr1dr01_cpu_nice_910.rrd":cpu_nice:AVERAGE \

DEF:g="/usr/local/apache2/htdocs/rra/ngpmr1dr02_cpu_system_914.rrd":cpu_system:AVERAGE \
DEF:i="/usr/local/apache2/htdocs/rra/ngpmr1dr02_cpu_user_915.rrd":cpu_user:AVERAGE \
DEF:ba="/usr/local/apache2/htdocs/rra/ngpmr1dr02_cpu_nice_913.rrd":cpu_nice:AVERAGE \
I figured I would be able to do this with a CDEF such as a,c,+e and g,i,+ba but this simply returns an error - Invalid rpn expression.

I tried a few other combinations as well such as: cdefa,cdefc,cdefe,+,cdefg,cdefi,cdefba,+

I've even gone and tried this with less DEF's such as (a+b) - (b+d) - no luck.

Any info would be much appreciated.

Dan
niobe
Cacti User
Posts: 228
Joined: Mon Mar 10, 2008 6:52 pm
Location: Australia

Post by niobe »

Responding to Jason's original reply on page 1.

This is a cool solution, however after much playing I discovered there is a critical limitation - it won't work for an arbitrary number of hosts, it has to be the 8 or 'n' that you set in the graph template.

This is a problem for me as I want a generic method for totalling a variable number of hosts.
Specifically I want to aggregate the number of users on subsets of my 180 wireless access points. The APs are actually grouped by subnet. First group may have 8 APs, then next 54, the next 31 and so on, i.e. a variable number of hosts on each aggregate graph.

In this solultion I need a new template to cater for each number in my group. But what happens when I add a new AP to one group? Then I have to redo my templates.

I am trying to work out alternatives, and I think the only way may be a script that accesses the existing data sources and outputs a new aggregate data source. The script will take an argument such as 'hostname_regexp' or 'host_template_id' to determine groupings, and therefore which DS to access.

I believe this is different to the way the aggregate plugin works since it does not create a new data source, just graphs the existing DS on the same graph.

Any thoughts?
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Your statements are correct, IMHO. In a discussion in my company, we were already talking about some kind of "generic, dynamical, self-generating aggregate" which builds the graph based on a regexp filter of any kind (not limited to a host filter).
But this concepts does not fit in any known way (at least not known to me) into current cacti, because the graph would be generated from scratch at graph display time ...
Reinhard
niobe
Cacti User
Posts: 228
Joined: Mon Mar 10, 2008 6:52 pm
Location: Australia

Post by niobe »

gandalf wrote:Your statements are correct, IMHO. In a discussion in my company, we were already talking about some kind of "generic, dynamical, self-generating aggregate" which builds the graph based on a regexp filter of any kind (not limited to a host filter).
But this concepts does not fit in any known way (at least not known to me) into current cacti, because the graph would be generated from scratch at graph display time ...
Reinhard
That's interesting, but I am not sure I follow you.. I always assumed that cacti generates graphs on the fly. Isn't that how rrdtool is designed and a major difference from mrtg?
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Yes, it generates graphs on the fly. But the graph's structure is defined by the graph template. E.g. the number of graph items is fixed.

Now, we want to make a more powerful graph template. It shall be able to accumulate several items based on some generic filter expression. For each those items, it should graph e.g. a LINEx along with 3 lines of LEGEND.
This will lead to graphs that sometimes only habe one item, the next one will have e.g. 42 items ...

Am I clear enough now?
Reinhard
niobe
Cacti User
Posts: 228
Joined: Mon Mar 10, 2008 6:52 pm
Location: Australia

Post by niobe »

gandalf wrote:Yes, it generates graphs on the fly. But the graph's structure is defined by the graph template. E.g. the number of graph items is fixed.

Now, we want to make a more powerful graph template. It shall be able to accumulate several items based on some generic filter expression. For each those items, it should graph e.g. a LINEx along with 3 lines of LEGEND.
This will lead to graphs that sometimes only habe one item, the next one will have e.g. 42 items ...

Am I clear enough now?
Reinhard
Yes, fully understand. How about creating a handful of templates with fixed number of items (e.g. 10,25,50,100), then the script will return a unique data source with value '0' for any difference. Must be unique data source else duplicates will be filtered I think. The scripts will assume you have assigned the right template. So if the template has 10 items and the result 11, just truncate the result to 10. Bit hackish but still easier than doing a template manually for each graph. The trick will be to filter the zero data sources from the legend, but they won't affect the shape of the graph.

Another idea would be for the script to create the template of the correct length the first time it is run, but that is definitely hackish!
lester
Posts: 9
Joined: Sat Dec 06, 2008 9:27 am

Post by lester »

Hi all,

Very nice for this "how to" it's work great for me at the first time.
but i need your help
i'm try to make exactly the same graph and i want to add secondary data.
in your exemple , your graph have one average information, i need to make it with, by exemple for IO disk in the same graph :
-average of several host of IO read in green
-average of several host of IO disk write in red

i have try with:
repeat step for read and write for "graph template items" and for "graph item input"
but the result i have just one line, not two in my graph with cumul of average read and write.

Please can you explane me how to make in one graph write average and read average in two line " i prefere use line to area "

In advance, very thank

I'm added two screenshoot.

Image
Image
lester
Posts: 9
Joined: Sat Dec 06, 2008 9:27 am

Post by lester »

up
vahabzadeh
Posts: 1
Joined: Wed Jul 01, 2009 1:40 am

Problem in aggregating graphs

Post by vahabzadeh »

Hi,
I have 5 Cisco Dialup router, which i am going to graph their online users,
now I want to have their aggregate and have their sum.
but as I follow this post I could not success to do this,
can any body help me? ( i have attached all of steps )

1) Creating CDEF in Graph Management
2) Creating Graph Template
3) Adding Graph Template Items
4) Adding Graph Template Inputs
5) Add New Graph in Graph Management
Attachments
Creating CDEF in Graph Management
Creating CDEF in Graph Management
Step1.jpg (77.77 KiB) Viewed 29593 times
Creating Graph Template
Creating Graph Template
Step2.jpg (231 KiB) Viewed 29593 times
Adding Graph Template Items
Adding Graph Template Items
Step3.jpg (146.26 KiB) Viewed 29593 times
Adding Graph Template Inputs
Adding Graph Template Inputs
Step4.jpg (103.21 KiB) Viewed 29593 times
Add New Graph in Graph Management
Add New Graph in Graph Management
Step5.jpg (179.35 KiB) Viewed 29593 times
Virtuose
Posts: 2
Joined: Wed Apr 17, 2013 4:02 am

Re: [HOWTO] Graph displaying average of several other hosts

Post by Virtuose »

Hi all,

I'm trying to sum values from a an other graph into a new graph as a unique value.

I have two values: mem_cache, mem_free on a graph.

I'm trying to make a new graph with a unique value mem_sum = mem_cache + mem_free.

Here is my Graph Template:
Screenshot.png
Screenshot.png (22.08 KiB) Viewed 22776 times
When using the graph template, I'll get the following issue in Graph Debug Mode:
Screenshot-2.png
Screenshot-2.png (45.21 KiB) Viewed 22776 times
Thank you in advance for your help :-)
Attachments
Screenshot-1.png
Screenshot-1.png (40.73 KiB) Viewed 22776 times
desscartes
Cacti User
Posts: 96
Joined: Fri Mar 14, 2014 1:16 am

Re: [HOWTO] Graph displaying average of several other hosts

Post by desscartes »

Hi Virtuose;

I have sama problem with you.I'm trying to make a new graph with a unique value mem_sum = mem_cache + mem_free. And I want to create new graph mem_free, percent mem_sum .

How can I do this?

Thanks,
Computer Science Eng.

Cenk Durak
Chrysalis
Cacti User
Posts: 70
Joined: Fri Sep 19, 2008 10:14 am
Location: UK

Re: [HOWTO] Graph displaying average of several other hosts

Post by Chrysalis »

very old thread but going to chime in as to help others who google and find this and get mega confused.

I always think its important to understand what you doing, one can follow a guide to the word, but if they dont learn anything in terms of how it works, it makes it harder.

The guide itself also combines the adding of data source and creating a graph template which makes it a lot bigger than it needs to be.

Ultimately I read the guide and concluded it can be greatly simplified.

So lets say e.g. you have a graph with items such as this.

CPU User %
CPU System %
CPU Interrupt %
CPU Nice %
CPU Idle %.

The last item is important in the purpose.

You want to add a Total CPU usage.to graph.

You cannot use the existing CDEF total all existing items as you need CPU Idle excluded.

So in this case there is 4 items to be tallied.

In the guide we seen the guide stated to add lots of no task items, but that isnt required, instead I simply viewed the graph in debug mode.

I then seen something like this.

DEF:a='/var/db/cacti/rra/hope_cpu_user_snmp_3353.rrd':'cpu_user_snmp':MAX \
DEF:b='/var/db/cacti/rra/hope_cpu_system_snmp_3352.rrd':'cpu_system_snmp':MAX \
DEF:c='/var/db/cacti/rra/hope_cpu_nice_snmp_3351.rrd':'cpu_nice_snmp':MAX \
DEF:d='/var/db/cacti/rra/hope_cpu_interrupts_snmp_3350.rrd':'cpu_interrupts_snmp':MAX \
DEF:e='/var/db/cacti/rra/hope_cpu_idle_snmp_3349.rrd':'cpu_idle_snmp':MAX \

So the definitions are there, I see in this case I want 'a b c d'. but not 'e'

In the OP's post we seen this for the custom cdef value

a,b,+,c,+,d,+,e,+,f,+,g,+,h,+,8,/

So its the original variable, then the variable to apply as a modifier, then followed by the type of modifier.

So in my case I adjusted to 'a,b,+,c,+,d,+,1,/' I expect 'a,b,+,c,+,d,+' would have been fine but I havent tested. The 8 / was there to divide by 8 the total, as the example was to change 8 separate cpu usage to a one combined cpu usage.

I hope this helps others in vastly shortening the guide and helping to understand how the actual cdef works. I appreciate of course the guide that was posted.
fparedes
Posts: 1
Joined: Mon Dec 21, 2020 4:50 pm

Re: [HOWTO] Graph displaying average of several other hosts

Post by fparedes »

Excuse me for my English, I have version 1.2.10 of Cacti and I cannot graph the traffic totals of several different hosts, in this version when creating a graph you always have to choose a host and it cannot be left empty
Any suggestion. Thank you

FParedes
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: [HOWTO] Graph displaying average of several other hosts

Post by TheWitness »

You can either use and Aggregate Graph, or go through the process manually. I would prefer to create a Script Server script and enable the Data Source statistics and just pull the averages from the Data Source statistics table, but I've been doing this for almost 20 years and wrote most of it. I don't generally write templates for others though. It's something of a right of passage for you to be able to write your own.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests