Add graph to host template, update Associated Graph Template

Addons for Cacti and discussion about those addons

Moderators: Moderators, Developers

Author
Message
User avatar
gandalf
Developer
Posts: 22375
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Add graph to host template, update Associated Graph Template

#1 Post by gandalf » Fri May 06, 2005 1:17 pm

I recently added some graph templates to several host templates.
Afterwards, I had to add all those templates to the list of 'Associated Graph Templates' for each host, and we have about 200 of them.
To automate this task, I developed a patch to graph_templates.php, based on cacti 0.8.6d.

Usage Note:
  • You will add a graph template to all those host templates as usual.
    Now you may select "Graph Templates" on the left.
    Check all graph templates you added to a host template
    Select 'Insert Associated Graph Templates' from the action dropdown an GO
You will notice a text like this
You are using host templates for several hosts and you just updated one or more host templates to include another graph template. But if you display one of those hosts, you will not have the 'Associated Graph Templates' list updated.
Now you may add each graph manually and error prone.
To ease this burdon, you may even select all those graph templates, that you have added to one or more host templates, and I will do the update for you.
Remember:
  • No graphs are generated automatically!
    Only the list of 'Associated Graph Templates' is updated!
Now ALL host templates are searched for a reference to the selected graph template(s). And all hosts that belong to those host templates will have there list of graph templates updated.
People, who are updating there host templates frequently or poll a lot of hosts may find this patch useful. :o
Reinhard
Attachments
graph_templates.patch
graph_templates.patch
(2.81 KiB) Downloaded 3155 times

applesx
Posts: 8
Joined: Tue Jun 21, 2005 10:29 am

Further Instructions

#2 Post by applesx » Tue Jun 21, 2005 10:30 am

Can you pass on some more details on how to install this? Do I just paste this code into the existing graph_templates.php? If so, where do I paste it?


Thanks!

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

#3 Post by gandalf » Tue Jun 21, 2005 10:49 am

You may download the patch to <path_cacti>. Apply this patch using

Code: Select all

patch -p1 < <path_cacti>/graph_templates.patch
Of course you have to

Code: Select all

replace <path_cacti> with your path, e.g. /var/www/html/cacti or so
Tried on Linux, don't know how to do that on windows. Please have a look at http://forums.cacti.net/viewtopic.php?t=5587 for more information.

HTH
Reinhard

applesx
Posts: 8
Joined: Tue Jun 21, 2005 10:29 am

I am getting this error......

#4 Post by applesx » Tue Jun 21, 2005 4:11 pm

patch: **** strip count l is not a number



I assume this is because I am running 0.8.6c, when your patch was written for 0.8.6d?

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

Re: I am getting this error......

#5 Post by gandalf » Wed Jun 22, 2005 2:51 am

applesx wrote:I assume this is because I am running 0.8.6c, when your patch was written for 0.8.6d?
Yes, you are right.
You may have a look at the *.patch file itself. It contains changes to the $graph_actions array and two code fragments that have to be added; nothing to be deleted.
I don't have a 0.8.6c version, so I can't deliver an appropriate patch for that version.

Reinhard

applesx
Posts: 8
Joined: Tue Jun 21, 2005 10:29 am

#6 Post by applesx » Wed Jun 22, 2005 10:12 am

Thanks for your responses. Since I have to upgrade, and 0.8.6e is the latest, will the patch work with it?

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

#7 Post by gandalf » Wed Jun 22, 2005 10:21 am

applesx wrote:Thanks for your responses. Since I have to upgrade, and 0.8.6e is the latest, will the patch work with it?
Sorry,
but up to the moment, I don't have any experience with 0.8.6e. Just have a try. If the patch does not match, the command will fail and nothing will be modified. To be sure, just save the file graph_template.php; it's the only file that will be changed.
The solution I posted before should work even if "patch ..." fails. If it does not, please post.

Reinhard

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

#8 Post by gandalf » Sat Nov 05, 2005 4:17 pm

applesx wrote:Thanks for your responses. Since I have to upgrade, and 0.8.6e is the latest, will the patch work with it?
Just tried it on cacti 0.8.6g. Results in

Code: Select all

patch -p1 < graph_templates.patch
missing header for unified diff at line 3 of patch
can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- graph_templates.php.orig   2005-04-27 02:47:39.000000000 +0200
|+++ graph_templates.php        2005-05-06 19:57:14.104051763 +0200
--------------------------
File to patch: graph_templates.php
patching file graph_templates.php
Hunk #1 succeeded at 34 (offset 2 lines).
Hunk #2 succeeded at 197 with fuzz 1 (offset 4 lines).
Hunk #3 succeeded at 270 (offset 6 lines).
Seems to work for me (and I have patched graph_templates.php to include a filter option ...)
Reinhard

kslt
Cacti User
Posts: 85
Joined: Tue Aug 02, 2005 4:12 am

#9 Post by kslt » Mon Nov 07, 2005 3:07 am

Hello all,

is there any way to create the associated graphs automaticly ?

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

#10 Post by gandalf » Tue Nov 08, 2005 5:10 pm

kslt wrote:Hello all,

is there any way to create the associated graphs automaticly ?
Yes, I'm following your struggle for automation. But there has been no solution up to now, AFAIK. Please remember, that Data Templates may virtually define "anything" that will be needed to verify/modify when creating a new Data Source (that are those "checked" fields in the Data Template). They may even include input parameters to scripts etc. I cannot think of a generalized way to generate those parms. You will have to provide them as part of some "batch input file"? You may restrict the usage of a "graph generator" to data sources/graph templates which do not need any other input? What about selecting indices when generating graphs for data queries? Which indices should be used, which not?
Seems not to be that kind of simple task.
Reinhard

kslt
Cacti User
Posts: 85
Joined: Tue Aug 02, 2005 4:12 am

#11 Post by kslt » Mon Nov 14, 2005 9:53 am

a simple, that after adding a device you can go to "create graphs" and select the assosiated graph to create .. and it will do that automaticly (includes data sources and graphs).
so how i can emulate this button-press on "create graphs" by the script/command line .. ?

ymartin59
Posts: 40
Joined: Fri Feb 17, 2006 7:42 am

#12 Post by ymartin59 » Tue Feb 21, 2006 5:59 am

kslt wrote: so how i can emulate this button-press on "create graphs" by the script/command line .. ?
Look at the following thread http://forums.cacti.net/viewtopic.php?t=7683 and use "add_graph.php" script.

felimwhiteley
Posts: 26
Joined: Mon Dec 10, 2007 10:14 am

Re: Add graph to host template, update Associated Graph Temp

#13 Post by felimwhiteley » Tue May 12, 2009 5:02 am

gandalf wrote:I recently added some graph templates to several host templates.
Afterwards, I had to add all those templates to the list of 'Associated Graph Templates' for each host, and we have about 200 of them.
To automate this task, I developed a patch to graph_templates.php, based on cacti 0.8.6d.
Unless I'm missing it, this hasn't made it into Cacti ? I've got the same issue where I want to update both the Associated Graphs and Data templates for a particular host template, not necessarily to add all the graphs. Is there any plans to implement this ? I realise this post was from a long while back but I'd have thought it would be a fairly requested feature.

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

#14 Post by gandalf » Thu May 14, 2009 2:15 pm

This should now be part of cacti main SVN branch. But I still have to resolve an issue. This code now accepts even Data Queries.
I can provide you with a patch against 087d, but this works for "simple" Graph Templates only, no Data Queries
Reinhard

felimwhiteley
Posts: 26
Joined: Mon Dec 10, 2007 10:14 am

#15 Post by felimwhiteley » Thu May 14, 2009 3:16 pm

That would be enough for now, I'd appreciate it if you could ! :-)

Post Reply