Add graph to host template, update Associated Graph Template

Addons for Cacti and discussion about those addons

Moderators: Developers, Moderators

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

Add graph to host template, update Associated Graph Template

Post by gandalf »

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 4188 times
applesx
Posts: 8
Joined: Tue Jun 21, 2005 10:29 am

Further Instructions

Post by applesx »

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: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

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......

Post by applesx »

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: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

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

Post by gandalf »

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

Post by applesx »

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: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

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: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

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

Post by kslt »

Hello all,

is there any way to create the associated graphs automaticly ?
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

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

Post by kslt »

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

Post by ymartin59 »

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

Post by felimwhiteley »

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: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

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

Post by felimwhiteley »

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

Who is online

Users browsing this forum: No registered users and 0 guests