Multiple graphs from one data source

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
User avatar
MrBr
Posts: 44
Joined: Thu Sep 24, 2009 10:13 am

Multiple graphs from one data source

Post by MrBr »

Hello

Is it possible , in any way, to create one data source, that updates regularly, and then create multiple graphs based on this data.

Current situation:
I have a script that fetches multiple values , let say a-f
This script is defined in data input method "get my data"
I want to create 2 graphs, fist with values a,b and the second with c,d,f
Now, when i define 2 graphs, cacti polls the data twice and creates 2 data sources.

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

Post by gandalf »

That's a known drawback, not considered to be a bug.
You may create the first graph "the ussual way" from "Create Graphs for this Host". The second one has to be created from Graph Management. You will be able to refer the required data sources to those already created by the first graph.
R.
User avatar
MrBr
Posts: 44
Joined: Thu Sep 24, 2009 10:13 am

Post by MrBr »

Thanks for the reply.

Is there a way to template this task? ( or any other king of automatisation )
I need to create tens of similar hosts with 4 graphs per single data source.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

If it were I would have mentioned it :-?
Any code contribution is appreciated; but that's unfortunately the best I can say for now
R.
pierretim
Posts: 1
Joined: Thu May 23, 2013 9:51 am

Re:

Post by pierretim »

Same problem, I was thinking it was a mistake from me somewhere...
gandalf wrote:That's a known drawback, not considered to be a bug.
You may create the first graph "the ussual way" from "Create Graphs for this Host". The second one has to be created from Graph Management. You will be able to refer the required data sources to those already created by the first graph.
R.
I could not get this to work but I ended it doing a workaround in my shell script to cache the result if it was executed less than 2 minutes ago. Here is how my script looks now. Note: first create a directory called cache in the script directory.

Code: Select all

TARGETSERVER=$1
THISDIR=/opt/cacti-0.8.8a/scripts
USR=<...>

#we need to cache the response because cacti will execute the script once per graph based on the data source
#this is a limitation of cacti
FNAME=query_accesslog_${TARGETSERVER}
find ${THISDIR}/cache -name "$FNAME" -mmin -2  | grep -q $FNAME
if [ $? -eq 1 ] ; then
 #cached result is too old, we need to run again the query
 ssh ${USR}@$TARGETSERVER '/usr/local/bin/query_accesslog.sh' > ${THISDIR}/cache/${FNAME}
fi
cat ${THISDIR}/cache/${FNAME}
So if the file was modified less than 2 minutes ago, the remote shell is not executed and instead the cached result is used.

I think this is quite OK because the hit on the poller is minimal (local shell script invocation).
jweinraub
Cacti User
Posts: 61
Joined: Fri Apr 13, 2007 9:21 am

Re: Multiple graphs from one data source

Post by jweinraub »

since it is now over a year on this thread, is there any updates? i got one datasource with multiuple stuff, but because the data is not all in the same unit, so i want to make separate graphs for each unit type (weather in my case, so degrees C, km/h, mm, kPa, etc)
justruss
Posts: 8
Joined: Thu Jul 17, 2014 2:33 pm

Re: Multiple graphs from one data source

Post by justruss »

Not in an automated way through a template. You have to create your data template / data source to store the data (the graph values). Then create graphs manually (via a graph template if you'd like) and point the various graph item fields at the same data source (different data source items). It's a pain, but I'm pretty sure there still isn't any other way. The caching of results like someone mentioned above is a good way to overcome any overhead associated with effectively polling the same data over and over again.
demcorp
Posts: 2
Joined: Fri Mar 20, 2015 4:04 am

Re: Multiple graphs from one data source

Post by demcorp »

Hi,

I had the same problem and haven't found any solution so I've decided to create my own CLI command. I share it with you and would be glad if you want to include it with Cacti.

Hope it can help.
Attachments
add_extragraph.zip
(1.88 KiB) Downloaded 187 times
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests