Some users (and me) wanted to use "|query_xxxx|" from datasource in graph title,
but this feature is limited to datasources that used Data Queries, not for Data Input Method.
See also:
get param passed to an scriptSo I've tried implementing that.
How to use1) Place 'addon_data_input_field.php' at 'cacti/lib/' directory
Attachment:
addon_data_input_field.zip [1.35 KiB]
Downloaded 195 times
2) Modify get_graph_title() in 'cacti/lib/functions.php' as follows:
Code:
function get_graph_title($local_graph_id) {
+ global $config;
+ include_once($config["library_path"] . "/addon_data_input_field.php");
$graph = db_fetch_row("select
graph_local.host_id,
graph_local.snmp_query_id,
graph_local.snmp_index,
graph_templates_graph.title
from (graph_templates_graph,graph_local)
where graph_templates_graph.local_graph_id=graph_local.id
and graph_local.id=$local_graph_id");
if ((strstr($graph["title"], "|")) && (!empty($graph["host_id"]))) {
+ $graph["title"] = substitute_data_input_field($graph["title"], $graph["host_id"], $local_graph_id);
return expand_title($graph["host_id"], $graph["snmp_query_id"], $graph["snmp_index"], $graph["title"]);
}else{
return $graph["title"];
}
}
Sample case - Advanced Ping TemplateInput fields of this Data Input Method is as follows:

And here is my datasource.

Then I set title like this in graph template.
before:Quote:
|host_description| - Advanced Ping
after:Quote:
Advanced Ping - from |host_hostname| to |input_hostname| (attempts=|input_attempts|, protocol=|input_protocol|)
Result is...

(Please ignore about packet loss :P)
If the changes won't be applied immediately (like this),

perform "
Reapply Suggested Names" to the graph.
NOTICE:- I'm using on Cacti 0.8.7g + official patch + PA2.9
- I made this mainly for Advanced Ping, not enough tested with other templates
(e.g. a graph that is related with multiple rrd file which is made by Data Input Method)
- The changes won't be applied when the device is down
- I'm not sure whether if this will work properly (or not) when the multiple input fields with the same name existed in same datasource
(e.g. aggregated graph?)
LogicIt needed to determine "what datasources are used in this graph"..
(Does anyone know easier method for that?)
I tried this way:
1) determine what graph template is used in its graph
2) determine what data (output) field is used in its graph template
(collect field which has "Data Source" type in "Graph Item Inputs")
3) determine what datasource has its field (= what datasource is used for its graph)
4) if data input id and data template id which used in its datasource are known, then retrieve data input fields from its datasource
// Sorry my English