Script Input Variables in Data Source Name

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

Moderators: Developers, Moderators

Post Reply
rickg421
Posts: 6
Joined: Fri Sep 16, 2011 2:12 pm

Script Input Variables in Data Source Name

Post by rickg421 »

I upgraded to 0.8.7i and was able to use the input variables in my graph titles. However, they don't seem to work when I try to apply the same to a data template name. I copy & pasted the same string from the graph template's title to the data template's name. New data sources don't get the substitution, and there is also no change when I try to "Reapply Suggested Names" from the data source view. I don't know if this is intended behavior or if I have a local problem.

I looked at the SQL queries being made and there's one to the data_local table that has a condition with snmp_query_id > 0. Entries in that table for my data query in question have an id value = 0, so that one SQL query returns no rows. I'm only guessing at it's relevance.

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

Re: Script Input Variables in Data Source Name

Post by gandalf »

Not sure, but I suppose that there has been a custom patch (== not yet published officially) to the related code to apply input variables to DS as well. It's a singel function call, if I remember correctly.
This patch has been published to the forums by a educated user; please search
R.
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: Script Input Variables in Data Source Name

Post by noname »

For 0.8.7i, try adding this line to 'lib/functions.php':

Code: Select all

function get_data_source_title($local_data_id) {
	...
	if ((strstr($data["name"], "|")) && (!empty($data["host_id"]))) {
		$data["name"] = substitute_data_input_data($data["name"], "", $local_data_id);	// <--THIS LINE
		return expand_title($data["host_id"], $data["snmp_query_id"], $data["snmp_index"], $data["name"]);
	}else{
		return $data["name"];
	}
}
(After you modified data template, perform "Reapply Suggested Names" if needed)

Thanks developers, that function (substitute_data_input_data) is very useful and generic! :D
rickg421
Posts: 6
Joined: Fri Sep 16, 2011 2:12 pm

Re: Script Input Variables in Data Source Name

Post by rickg421 »

Indeed, that modification to functions.php seems to have done the trick. Thank you for that.
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: Script Input Variables in Data Source Name

Post by noname »

Thanks reply. I posted this as a feature request.
- http://bugs.cacti.net/view.php?id=2165
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest