|
|
| Author |
Message |
cricalix
Joined: 22 Jan 2007 Posts: 9
|
Posted: Tue Feb 13, 2007 7:19 am Post subject: [SOLVED] More variable support for graph templates |
|
|
At the moment, the host_* variables can be used in the title of the graphs, which is nice. However, I'd like to be able to fit some of that information in a COMMENT field on the graph, so that the title of the graph doesn't exceed the boundaries of the graph container.
I can do legend values like:
Out 95%: |95:bits:1:max:0|
I'd like to do things like
Host: |host_hostname|
leaving the title with the |host_description| and the graph type. I've tried digging through the source code, but can't determine how to run the substitute_host_data function against the RRD legend stuff. Pointers on where I might find it would be appreciated too
|
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9671 Location: MI, USA
|
Posted: Tue Feb 13, 2007 8:25 am Post subject: |
|
|
I think if you goto the top of include/config_constants.php or include/config_arrays.php, you will start to understand. There is an array that includes the viable "special use" ones. Follow that array around and you may start to understand.
TheWitness
|
|
| Back to top |
|
 |
cricalix
Joined: 22 Jan 2007 Posts: 9
|
Posted: Wed Feb 14, 2007 5:46 am Post subject: Solved :) |
|
|
Well, I don't think this is the cleanest processing method, but maybe it is.
I found that graph titles are stored in SQL as the pipe-variable template string, and the substituted string. However, I didn't see the equivalent storage for the RRD legend stuff. This makes sense, as the legend data is changed on generation.
Tracing the text_format variable from include/config_form.php, I found references in rrd.php, which made sense.
Two changes were made to rrd.php to support the host_* variables:
1) Added to line 29 of lib/rrd.php:
| Code: | | include_once($config["base_path"] . "/lib/rrd.php"); |
2) Added to the -new- line 799 of lib/rrd.php:
| Code: | | $graph_item["text_format"] = substitute_host_data($graph_item["text_format"], '|','|', $graph["host_id"]); |
Really and truly, the second modification should only be run when the legend type is COMMENT, to cut down the processing overhead. A quick test around line 1088 didn't work, and I'm not inclined to poke it any further today.
Oh, the critical part - this was version 0.8.6j. Tried to find that in about.php and it wasn't there :p
Thanks for the hint TheWitness - don't suppose this might make it into .9?
| Description: |
| Using host_hostname in the legend. |
|
| Filesize: |
8.05 KB |
| Viewed: |
2930 Time(s) |

|
|
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9671 Location: MI, USA
|
Posted: Sat Feb 17, 2007 9:57 pm Post subject: |
|
|
Please log this as a feature request at bugs.cacti.net. Include a link to this post in that bug report and then reply here to let me know it's there.
Thanks,
TheWitness
ps. Monday is Cacti day for me this week.
|
|
| Back to top |
|
 |
cricalix
Joined: 22 Jan 2007 Posts: 9
|
Posted: Sun Feb 18, 2007 4:55 am Post subject: |
|
|
Ticket 925 has been created
|
|
| Back to top |
|
 |
disirk
Joined: 11 Sep 2006 Posts: 12 Location: Atlanta, GA
|
Posted: Tue Feb 20, 2007 1:40 pm Post subject: Include more data... |
|
|
If you use the following in your rrd.php you can add not only the host_* variables, but all snmp_queries as well.
At line 1035ish replace:
| Code: | | $txt_graph_items .= $graph_item_types{$graph_item["graph_type_id"]} . ":\"" . str_replace(":", "\:", $graph_variables["text_format"][$graph_item_id]) . $hardreturn[$graph_item_id] . "\" "; |
With the following:
| Code: | | $txt_graph_items .= $graph_item_types{$graph_item["graph_type_id"]} . ":\"" . expand_title($graph["host_id"],$graph["snmp_query_id"],$graph["snmp_index"],str_replace(":", "\:", $graph_variables["text_format"][$graph_item_id])) . $hardreturn[$graph_item_id] . "\" "; |
This calls the same function that allows you to do the variables in your title...just add the variables in your comments...and bam! The only thing I need to work on now is centering the information and maybe have the font's be a different size.
*NOTE: The line | Code: | | include_once($config["base_path"] . "/lib/rrd.php"); | was not needed for me *shrug*
|
|
| Back to top |
|
 |
cricalix
Joined: 22 Jan 2007 Posts: 9
|
Posted: Tue Feb 20, 2007 3:00 pm Post subject: |
|
|
| Yeah, now that I think about it, requiring itself makes no sense. Wonder why I did that, or if I was editing a different file...
|
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9671 Location: MI, USA
|
Posted: Sun Feb 25, 2007 4:44 pm Post subject: |
|
|
If you are not running the Plugin Architecture, please try the attached lib/rrd.php for comparison. This addresses query replacement in CDEF, and COMMENT.
TheWitness
| Description: |
| With Plugin Architecture (v1.1) |
|
 Download |
| Filename: |
rrd.zip |
| Filesize: |
11.54 KB |
| Downloaded: |
193 Time(s) |
| Description: |
|
 Download |
| Filename: |
rrd.zip |
| Filesize: |
11.38 KB |
| Downloaded: |
190 Time(s) |
|
|
| Back to top |
|
 |
gandalf Developer
Joined: 02 Dec 2004 Posts: 12206 Location: Muenster, Germany
|
Posted: Mon Feb 04, 2008 10:38 am Post subject: |
|
|
Now available for upper/lower limit. At least in SVN
Reinhard
|
|
| Back to top |
|
 |
|