/** expand_title - takes a string and substitutes all data query variables contained in it or cleans them out if no data query is in use @param int $device_id - (int) the device ID to match @param int $snmp_query_id - (int) the data query ID to match @param int $snmp_index - the data query index to match @param string $title - the original string that contains the data query variables @return string - the original string with all of the variable substitutions made */ function expand_title($device_id, $snmp_query_id, $snmp_index, $title) { if ((strstr($title, "|")) && (!empty($device_id))) { if (($snmp_query_id != "0") && ($snmp_index != "")) { return substitute_snmp_query_data(null_out_substitutions(substitute_device_data($title, "|", "|", $device_id)), $device_id, $snmp_query_id, $snmp_index, read_config_option("max_data_query_field_length"), false); }else{ return null_out_substitutions(substitute_device_data($title, "|", "|", $device_id)); } }else{ return null_out_substitutions($title); } }
/** get_script_query_path - builds the complete script query executable path @param array $args - the variable that contains any arguments to be appended to the argument list (variables will be substituted in this function) @param string $script_path - the path on the disk to the script file @param int $device_id - the id of the device that this script query belongs to @return string - a full path to the script query script containing all arguments */ function get_script_query_path($args, $script_path, $device_id) { global $config; include_once(CACTI_BASE_PATH . "/lib/variables.php"); /* get any extra arguments that need to be passed to the script */ if (!empty($args)) { $extra_arguments = substitute_device_data($args, "|", "|", $device_id, true); }else{ $extra_arguments = ""; } /* get a complete path for out target script */ return substitute_script_query_path($script_path) . " $extra_arguments"; }
function rrd_substitute_device_query_data($txt_graph_item, $graph, $graph_item) { /* replace device variables in graph elements */ $txt_graph_item = substitute_device_data($txt_graph_item, '|','|', $graph["device_id"], true); /* replace query variables in graph elements */ if (preg_match("/\|query_[a-zA-Z0-9_]+\|/", $txt_graph_item)) { /* default to the graph data query information from the graph */ if (empty($graph_item["local_data_id"])) { return substitute_snmp_query_data($txt_graph_item, $graph["device_id"], $graph["snmp_query_id"], $graph["snmp_index"]); /* use the data query information from the data source if possible */ }else{ $data_local = db_fetch_row("select snmp_index,snmp_query_id,device_id from data_local where id='" . $graph_item["local_data_id"] . "'"); return substitute_snmp_query_data($txt_graph_item, $data_local["device_id"], $data_local["snmp_query_id"], $data_local["snmp_index"]); } }else{ return $txt_graph_item; } }