Script Input Variables in Data Source Name

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

Moderators: Moderators, Developers

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

Script Input Variables in Data Source Name

#1 Post by rickg421 » Tue Jan 31, 2012 3:45 pm

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

Re: Script Input Variables in Data Source Name

#2 Post by gandalf » Tue Jan 31, 2012 4:35 pm

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

#3 Post by noname » Thu Feb 02, 2012 3:36 am

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

#4 Post by rickg421 » Fri Feb 03, 2012 2:06 pm

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

#5 Post by noname » Mon Feb 06, 2012 8:36 pm

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

Post Reply