当前位置: 首页>>代码示例>>PHP>>正文


PHP get_data_source_title函数代码示例

本文整理汇总了PHP中get_data_source_title函数的典型用法代码示例。如果您正苦于以下问题:PHP get_data_source_title函数的具体用法?PHP get_data_source_title怎么用?PHP get_data_source_title使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_data_source_title函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: rrdtool_function_graph


//.........这里部分代码省略.........
			/* note the current item_id for easy access */
			$graph_item_id = $graph_item["graph_templates_item_id"];

			/* the following fields will be searched for graph variables */
			$variable_fields = array(
				"text_format" => array(
					"process_no_legend" => false
					),
				"value" => array(
					"process_no_legend" => true
					),
				"cdef_cache" => array(
					"process_no_legend" => true
					)
				);

			/* loop through each field that we want to substitute values for:
			currently: text format and value */
			while (list($field_name, $field_array) = each($variable_fields)) {
				/* certain fields do not require values when the legend is not to be shown */
				if (($field_array["process_no_legend"] == false) && (isset($graph_data_array["graph_nolegend"]))) {
					continue;
				}

				$graph_variables[$field_name][$graph_item_id] = $graph_item[$field_name];

				/* date/time substitution */
				if (strstr($graph_variables[$field_name][$graph_item_id], "|date_time|")) {
					$graph_variables[$field_name][$graph_item_id] = str_replace("|date_time|", date('D d M H:i:s T Y', strtotime(db_fetch_cell("select value from settings where name='date'"))), $graph_variables[$field_name][$graph_item_id]);
				}

				/* data source title substitution */
				if (strstr($graph_variables[$field_name][$graph_item_id], "|data_source_title|")) {
					$graph_variables[$field_name][$graph_item_id] = str_replace("|data_source_title|", get_data_source_title($graph_item["local_data_id"]), $graph_variables[$field_name][$graph_item_id]);
				}

				/* data query variables */
				$graph_variables[$field_name][$graph_item_id] = rrd_substitute_host_query_data($graph_variables[$field_name][$graph_item_id], $graph, $graph_item);

				/* Nth percentile */
				if (preg_match_all("/\|([0-9]{1,2}):(bits|bytes):(\d):(current|total|max|total_peak|all_max_current|all_max_peak|aggregate_max|aggregate_sum|aggregate_current|aggregate):(\d)?\|/", $graph_variables[$field_name][$graph_item_id], $matches, PREG_SET_ORDER)) {
					foreach ($matches as $match) {
						$graph_variables[$field_name][$graph_item_id] = str_replace($match[0], variable_nth_percentile($match, $graph_item, $graph_items, $graph_start, $graph_end), $graph_variables[$field_name][$graph_item_id]);
					}
				}

				/* bandwidth summation */
				if (preg_match_all("/\|sum:(\d|auto):(current|total|atomic):(\d):(\d+|auto)\|/", $graph_variables[$field_name][$graph_item_id], $matches, PREG_SET_ORDER)) {
					foreach ($matches as $match) {
						$graph_variables[$field_name][$graph_item_id] = str_replace($match[0], variable_bandwidth_summation($match, $graph_item, $graph_items, $graph_start, $graph_end, $rra["steps"], $ds_step), $graph_variables[$field_name][$graph_item_id]);
					}
				}
			}

			/* if we are not displaying a legend there is no point in us even processing the auto padding,
			text format stuff. */
			if (!isset($graph_data_array["graph_nolegend"])) {
				/* set hard return variable if selected (\n) */
				if ($graph_item["hard_return"] == "on") {
					$hardreturn[$graph_item_id] = "\\n";
				}else{
					$hardreturn[$graph_item_id] = "";
				}

				/* +++++++++++++++++++++++ LEGEND: AUTO PADDING (<>'s) +++++++++++++++++++++++ */
开发者ID:songchin,项目名称:Cacti,代码行数:66,代码来源:rrd.php

示例2: thold_data_source_action_prepare

function thold_data_source_action_prepare($save)
{
    global $colors, $config;
    if ($save["drp_action"] == "plugin_thold_create") {
        /* get the valid thold templates
         * remove those hosts that do not have any valid templates
         */
        $templates = "";
        $found_list = "";
        $not_found = "";
        if (sizeof($save["ds_array"])) {
            foreach ($save["ds_array"] as $item) {
                $data_template_id = db_fetch_cell("SELECT data_template_id FROM data_local WHERE id={$item}");
                if ($data_template_id != "") {
                    if (sizeof(db_fetch_assoc("SELECT id FROM thold_template WHERE data_template_id={$data_template_id}"))) {
                        $found_list .= "<li>" . get_data_source_title($item) . "</li>";
                        if (strlen($templates)) {
                            $templates .= ", {$data_template_id}";
                        } else {
                            $templates = "{$data_template_id}";
                        }
                    } else {
                        $not_found .= "<li>" . get_data_source_title($item) . "</li>";
                    }
                } else {
                    $not_found .= "<li>" . get_data_source_title($item) . "</li>";
                }
            }
        }
        if (strlen($templates)) {
            $sql = "SELECT id, name FROM thold_template WHERE data_template_id IN (" . $templates . ") ORDER BY name";
        } else {
            $sql = "SELECT id, name FROM thold_template ORDER BY name";
        }
        print "\t<tr>\r\n\t\t\t\t<td colspan='2' class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>";
        if (strlen($found_list)) {
            if (strlen($not_found)) {
                print "<p>The following Data Sources have no Threshold Templates associated with them</p>";
                print "<ul>" . $not_found . "</ul>";
            }
            print "<p>Are you sure you wish to create Thresholds for these Data Sources?</p>\r\n\t\t\t\t\t<ul>" . $found_list . "</ul>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\n\r\n\t\t\t\t";
            $form_array = array('general_header' => array('friendly_name' => 'Available Threshold Templates', 'method' => 'spacer'), 'thold_template_id' => array('method' => 'drop_sql', 'friendly_name' => 'Select a Threshold Template', 'description' => '', 'none_value' => 'None', 'value' => 'None', 'sql' => $sql));
            draw_edit_form(array("config" => array("no_form_tag" => true), "fields" => $form_array));
        } else {
            if (strlen($not_found)) {
                print "<p>There are no Threshold Templates associated with the following Data Sources</p>";
                print "<ul>" . $not_found . "</ul>";
            }
        }
    } else {
        return $save;
    }
}
开发者ID:caiorasec,项目名称:thold,代码行数:53,代码来源:setup.php

示例3: update_data_source_title_cache

function update_data_source_title_cache($local_data_id) {
	db_execute("update data_template_data set name_cache='" . addslashes(get_data_source_title($local_data_id)) . "' where local_data_id=$local_data_id");
}
开发者ID:songchin,项目名称:Cacti,代码行数:3,代码来源:variables.php

示例4: update_data_source_title_cache

function update_data_source_title_cache($local_data_id)
{
    db_execute_prepared('UPDATE data_template_data SET name_cache = ? WHERE local_data_id = ?', array(get_data_source_title($local_data_id), $local_data_id));
    api_plugin_hook_function('update_data_source_title_cache', $local_data_id);
}
开发者ID:MrWnn,项目名称:cacti,代码行数:5,代码来源:variables.php

示例5: ds_edit

function ds_edit()
{
    global $colors, $struct_data_source, $struct_data_source_item, $data_source_types;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var("id"));
    /* ==================================================== */
    $use_data_template = true;
    $host_id = 0;
    if (!empty($_GET["id"])) {
        $data_local = db_fetch_row("select host_id,data_template_id from data_local where id='" . $_GET["id"] . "'");
        $data = db_fetch_row("select * from data_template_data where local_data_id='" . $_GET["id"] . "'");
        if (isset($data_local["data_template_id"]) && $data_local["data_template_id"] >= 0) {
            $data_template = db_fetch_row("select id,name from data_template where id='" . $data_local["data_template_id"] . "'");
            $data_template_data = db_fetch_row("select * from data_template_data where data_template_id='" . $data_local["data_template_id"] . "' and local_data_id=0");
        } else {
            $_SESSION["sess_messages"] = 'Data Source "' . $_GET["id"] . '" does not exist.';
            header("Location: data_sources.php");
            exit;
        }
        $header_label = "[edit: " . get_data_source_title($_GET["id"]) . "]";
        if (empty($data_local["data_template_id"])) {
            $use_data_template = false;
        }
    } else {
        $header_label = "[new]";
        $use_data_template = false;
    }
    /* handle debug mode */
    if (isset($_GET["debug"])) {
        if ($_GET["debug"] == "0") {
            kill_session_var("ds_debug_mode");
        } elseif ($_GET["debug"] == "1") {
            $_SESSION["ds_debug_mode"] = true;
        }
    }
    include_once "./include/top_header.php";
    if (!empty($_GET["id"])) {
        ?>
		<table width="100%" align="center">
			<tr>
				<td class="textInfo" colspan="2" valign="top">
					<?php 
        print get_data_source_title($_GET["id"]);
        ?>
				</td>
				<td class="textInfo" align="right" valign="top">
					<span style="color: #c16921;">*<a href='data_sources.php?action=ds_edit&id=<?php 
        print isset($_GET["id"]) ? $_GET["id"] : 0;
        ?>
&debug=<?php 
        print isset($_SESSION["ds_debug_mode"]) ? "0" : "1";
        ?>
'>Turn <strong><?php 
        print isset($_SESSION["ds_debug_mode"]) ? "Off" : "On";
        ?>
</strong> Data Source Debug Mode.</a>
				</td>
			</tr>
		</table>
		<br>
		<?php 
    }
    html_start_box("<strong>Data Template Selection</strong> {$header_label}", "100%", $colors["header"], "3", "center", "");
    $form_array = array("data_template_id" => array("method" => "drop_sql", "friendly_name" => "Selected Data Template", "description" => "The name given to this data template.", "value" => isset($data_template) ? $data_template["id"] : "0", "none_value" => "None", "sql" => "select id,name from data_template order by name"), "host_id" => array("method" => "drop_sql", "friendly_name" => "Host", "description" => "Choose the host that this graph belongs to.", "value" => isset($_GET["host_id"]) ? $_GET["host_id"] : $data_local["host_id"], "none_value" => "None", "sql" => "select id,CONCAT_WS('',description,' (',hostname,')') as name from host order by description,hostname"), "_data_template_id" => array("method" => "hidden", "value" => isset($data_template) ? $data_template["id"] : "0"), "_host_id" => array("method" => "hidden", "value" => empty($data_local["host_id"]) ? isset($_GET["host_id"]) ? $_GET["host_id"] : "0" : $data_local["host_id"]), "_data_input_id" => array("method" => "hidden", "value" => isset($data["data_input_id"]) ? $data["data_input_id"] : "0"), "data_template_data_id" => array("method" => "hidden", "value" => isset($data) ? $data["id"] : "0"), "local_data_template_data_id" => array("method" => "hidden", "value" => isset($data) ? $data["local_data_template_data_id"] : "0"), "local_data_id" => array("method" => "hidden", "value" => isset($data) ? $data["local_data_id"] : "0"));
    draw_edit_form(array("config" => array(), "fields" => $form_array));
    html_end_box();
    /* only display the "inputs" area if we are using a data template for this data source */
    if (!empty($data["data_template_id"])) {
        $template_data_rrds = db_fetch_assoc("select * from data_template_rrd where local_data_id=" . $_GET["id"] . " order by data_source_name");
        html_start_box("<strong>Supplemental Data Template Data</strong>", "100%", $colors["header"], "3", "center", "");
        draw_nontemplated_fields_data_source($data["data_template_id"], $data["local_data_id"], $data, "|field|", "<strong>Data Source Fields</strong>", true, true, 0);
        draw_nontemplated_fields_data_source_item($data["data_template_id"], $template_data_rrds, "|field|_|id|", "<strong>Data Source Item Fields</strong>", true, true, true, 0);
        draw_nontemplated_fields_custom_data($data["id"], "value_|id|", "<strong>Custom Data</strong>", true, true, 0);
        form_hidden_box("save_component_data", "1", "");
        html_end_box();
    }
    if ((isset($_GET["id"]) || isset($_GET["new"])) && empty($data["data_template_id"])) {
        html_start_box("<strong>Data Source</strong>", "100%", $colors["header"], "3", "center", "");
        $form_array = array();
        while (list($field_name, $field_array) = each($struct_data_source)) {
            $form_array += array($field_name => $struct_data_source[$field_name]);
            if (!($use_data_template == false || !empty($data_template_data["t_" . $field_name]) || $field_array["flags"] == "NOTEMPLATE")) {
                $form_array[$field_name]["description"] = "";
            }
            $form_array[$field_name]["value"] = isset($data[$field_name]) ? $data[$field_name] : "";
            $form_array[$field_name]["form_id"] = empty($data["id"]) ? "0" : $data["id"];
            if (!($use_data_template == false || !empty($data_template_data["t_" . $field_name]) || $field_array["flags"] == "NOTEMPLATE")) {
                $form_array[$field_name]["method"] = "template_" . $form_array[$field_name]["method"];
            }
        }
        draw_edit_form(array("config" => array("no_form_tag" => true), "fields" => inject_form_variables($form_array, isset($data) ? $data : array())));
        html_end_box();
        /* fetch ALL rrd's for this data source */
        if (!empty($_GET["id"])) {
            $template_data_rrds = db_fetch_assoc("select id,data_source_name from data_template_rrd where local_data_id=" . $_GET["id"] . " order by data_source_name");
        }
        /* select the first "rrd" of this data source by default */
        if (empty($_GET["view_rrd"])) {
            $_GET["view_rrd"] = isset($template_data_rrds[0]["id"]) ? $template_data_rrds[0]["id"] : "0";
        }
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:odp-svn,代码行数:101,代码来源:data_sources.php

示例6: data_source_edit

function data_source_edit() {
	global $colors;
	require_once(CACTI_BASE_PATH . "/lib/data_source/data_source_info.php");

	/* ================= input validation ================= */
	input_validate_input_number(get_request_var("id"));
	/* ==================================================== */

	$use_data_template = true;
	$device_id = 0;

	if (!empty($_GET["id"])) {
		$data_local 		= db_fetch_row("select device_id,data_template_id from data_local where id='" . $_GET["id"] . "'");
		$data       		= db_fetch_row("select * from data_template_data where local_data_id='" . $_GET["id"] . "'");
		$data_source_items 	= db_fetch_assoc("select * from data_template_rrd where local_data_id=" . $_GET["id"] . " order by data_source_name");

		if (isset($data_local["data_template_id"]) && $data_local["data_template_id"] >= 0) {
			$data_template      = db_fetch_row("select id,name from data_template where id='" . $data_local["data_template_id"] . "'");
			$data_template_data = db_fetch_row("select * from data_template_data where data_template_id='" . $data_local["data_template_id"] . "' and local_data_id=0");
		} else {
			$_SESSION["sess_messages"] = 'Data Source "' . $_GET["id"] . '" does not exist.';
			header ("Location: data_sources.php");
			exit;
		}

		$header_label = __("[edit: ") . get_data_source_title($_GET["id"]) . "]";

		if (empty($data_local["data_template_id"])) {
			$use_data_template = false;
		}
	}else{
		$header_label = __("[new]");

		$use_data_template = false;
	}

	/* handle debug mode */
	if (isset($_GET["debug"])) {
		if (get_request_var("debug") == "0") {
			kill_session_var("ds_debug_mode");
		}elseif (get_request_var("debug") == "1") {
			$_SESSION["ds_debug_mode"] = true;
		}
	}

	/* handle info mode */
	if (isset($_GET["info"])) {
		if (get_request_var("info") == "0") {
			kill_session_var("ds_info_mode");
		}elseif (get_request_var("info") == "1") {
			$_SESSION["ds_info_mode"] = true;
		}
	}

	include_once(CACTI_BASE_PATH . "/include/top_header.php");

	$tip_text = "";
	if (isset($data)) {
		$tip_text .= "<tr><td align=\\'right\\'><a class=\\'popup_item\\' id=\\'changeDSState\\' onClick=\\'changeDSState()\\' href=\\'#\\'>Unlock/Lock</a></td></tr>";
		$tip_text .= "<tr><td align=\\'right\\'><a class=\\'popup_item\\' href=\\'" . htmlspecialchars('data_sources.php?action=data_source_toggle_status&id=' . (isset($_GET["id"]) ? $_GET["id"] : 0) . '&newstate=' . (($data["active"] == CHECKED) ? "0" : "1")) . "\\'>" . (($data["active"] == CHECKED) ? __("Disable") : __("Enable")) . "</a></td></tr>";
		$tip_text .= "<tr><td align=\\'right\\'><a class=\\'popup_item\\' href=\\'" . htmlspecialchars('data_sources.php?action=data_source_edit&id=' . (isset($_GET["id"]) ? $_GET["id"] : 0) . '&debug=' . (isset($_SESSION["ds_debug_mode"]) ? "0" : "1")) . "\\'>" . __("Turn") . " <strong>" . (isset($_SESSION["ds_debug_mode"]) ? __("Off") : __(CHECKED)) . "</strong> " . __("Debug Mode") . "</a></td></tr>";
		$tip_text .= "<tr><td align=\\'right\\'><a class=\\'popup_item\\' href=\\'" . htmlspecialchars('data_sources.php?action=data_source_edit&id=' . (isset($_GET["id"]) ? $_GET["id"] : 0) . '&info=' . (isset($_SESSION["ds_info_mode"]) ? "0" : "1")) . "\\'>" . __("Turn") . " <strong>" . (isset($_SESSION["ds_info_mode"]) ? __("Off") : __(CHECKED)) . "</strong> " . __("RRD Info Mode") . "</a><td></tr>";
	}
	if (!empty($data_template["id"])) {
		$tip_text .= "<tr><td align=\\'right\\'><a class=\\'popup_item\\' href=\\'" . htmlspecialchars('data_templates.php?action=template_edit&id=' . (isset($data_template["id"]) ? $data_template["id"] : "0")) . "\\'>" . __("Edit Data Source Template") . "<br></a></td></td>";
	}
	if (!empty($_GET["device_id"]) || !empty($data_local["device_id"])) {
		$tip_text .= "<tr><td align=\\'right\\'><a class=\\'popup_item\\' href=\\'" . htmlspecialchars('devices.php?action=edit&id=' . (isset($_GET["device_id"]) ? $_GET["device_id"] : $data_local["device_id"])) . "\\'>" . __("Edit Host") . "</a></td></tr>";
	}

	if (!empty($_GET["id"])) {
		?>
		<script type="text/javascript">
		<!--
		var disabled = true;

		$().ready(function() {
			$("input").attr("disabled","disabled")
			$("select").attr("disabled","disabled")
			$("#cancel").removeAttr("disabled");
		});

		function changeDSState() {
			if (disabled) {
				$("input").removeAttr("disabled");
				$("select").removeAttr("disabled");
				$("#cancel").removeAttr("disabled");
				disabled = false;
			}else{
				$("input").attr("disabled","disabled")
				$("select").attr("disabled","disabled")
				disabled = true;
			}
		}
		-->
		</script>
		<table width="100%" align="center">
			<tr>
				<td class="textInfo" colspan="2" valign="top">
					<?php print get_data_source_title(get_request_var("id"));?>
//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:data_source_form.php

示例7: rrdtool_function_graph


//.........这里部分代码省略.........
                    			the same way, except a 'cdef' is put on the beginning of the hash */
                    $graph_defs .= "DEF:" . generate_graph_def_name(strval($i)) . "=" . cacti_escapeshellarg($data_source_path) . ":" . cacti_escapeshellarg($graph_item["data_source_name"], true) . ":" . $consolidation_functions[$graph_cf] . RRD_NL;
                    $cf_ds_cache[$graph_item["data_template_rrd_id"]][$graph_cf] = "{$i}";
                    $i++;
                }
            }
            /* cache cdef value here to support data query variables in the cdef string */
            if (empty($graph_item["cdef_id"])) {
                $graph_item["cdef_cache"] = "";
                $graph_items[$j]["cdef_cache"] = "";
            } else {
                $graph_item["cdef_cache"] = get_cdef($graph_item["cdef_id"]);
                $graph_items[$j]["cdef_cache"] = get_cdef($graph_item["cdef_id"]);
            }
            /* +++++++++++++++++++++++ LEGEND: TEXT SUBSTITUTION (<>'s) +++++++++++++++++++++++ */
            /* note the current item_id for easy access */
            $graph_item_id = $graph_item["graph_templates_item_id"];
            /* the following fields will be searched for graph variables */
            $variable_fields = array("text_format" => array("process_no_legend" => false), "value" => array("process_no_legend" => true), "cdef_cache" => array("process_no_legend" => true));
            /* loop through each field that we want to substitute values for:
            			currently: text format and value */
            while (list($field_name, $field_array) = each($variable_fields)) {
                /* certain fields do not require values when the legend is not to be shown */
                if ($field_array["process_no_legend"] == false && isset($graph_data_array["graph_nolegend"])) {
                    continue;
                }
                $graph_variables[$field_name][$graph_item_id] = $graph_item[$field_name];
                /* date/time substitution */
                if (strstr($graph_variables[$field_name][$graph_item_id], "|date_time|")) {
                    $graph_variables[$field_name][$graph_item_id] = str_replace("|date_time|", date('D d M H:i:s T Y', strtotime(db_fetch_cell("SELECT value FROM settings WHERE name='date'"))), $graph_variables[$field_name][$graph_item_id]);
                }
                /* data source title substitution */
                if (strstr($graph_variables[$field_name][$graph_item_id], "|data_source_title|")) {
                    $graph_variables[$field_name][$graph_item_id] = str_replace("|data_source_title|", get_data_source_title($graph_item["local_data_id"]), $graph_variables[$field_name][$graph_item_id]);
                }
                /* data query variables */
                $graph_variables[$field_name][$graph_item_id] = rrd_substitute_host_query_data($graph_variables[$field_name][$graph_item_id], $graph, $graph_item);
                /* Nth percentile */
                if (preg_match_all("/\\|([0-9]{1,2}):(bits|bytes):(\\d):(current|total|max|total_peak|all_max_current|all_max_peak|aggregate_max|aggregate_sum|aggregate_current|aggregate):(\\d)?\\|/", $graph_variables[$field_name][$graph_item_id], $matches, PREG_SET_ORDER)) {
                    foreach ($matches as $match) {
                        $graph_variables[$field_name][$graph_item_id] = str_replace($match[0], variable_nth_percentile($match, $graph_item, $graph_items, $graph_start, $graph_end), $graph_variables[$field_name][$graph_item_id]);
                    }
                }
                /* bandwidth summation */
                if (preg_match_all("/\\|sum:(\\d|auto):(current|total|atomic):(\\d):(\\d+|auto)\\|/", $graph_variables[$field_name][$graph_item_id], $matches, PREG_SET_ORDER)) {
                    foreach ($matches as $match) {
                        $graph_variables[$field_name][$graph_item_id] = str_replace($match[0], variable_bandwidth_summation($match, $graph_item, $graph_items, $graph_start, $graph_end, $rra["steps"], $ds_step), $graph_variables[$field_name][$graph_item_id]);
                    }
                }
            }
            /* if we are not displaying a legend there is no point in us even processing the auto padding,
            			text format stuff. */
            if (!isset($graph_data_array["graph_nolegend"])) {
                /* set hard return variable if selected (\n) */
                if ($graph_item["hard_return"] == "on") {
                    $hardreturn[$graph_item_id] = "\\n";
                } else {
                    $hardreturn[$graph_item_id] = "";
                }
                /* +++++++++++++++++++++++ LEGEND: AUTO PADDING (<>'s) +++++++++++++++++++++++ */
                /* PADDING: remember this is not perfect! its main use is for the basic graph setup of:
                			AREA - GPRINT-CURRENT - GPRINT-AVERAGE - GPRINT-MAXIMUM \n
                			of course it can be used in other situations, however may not work as intended.
                			If you have any additions to this small peice of code, feel free to send them to me. */
                if ($graph["auto_padding"] == "on") {
                    /* only applies to AREA, STACK and LINEs */
开发者ID:MrWnn,项目名称:cacti,代码行数:67,代码来源:rrd.php

示例8: debug

		ON (data_local.data_template_id=data_template.id)
		WHERE data_local.id=data_template_data.local_data_id
		$sql_where");

/* issue warnings and start message if applicable */
print "WARNING: Do not interrupt this script.  Interrupting during rename can cause issues\n";
debug("There are '" . sizeof($data_source_list) . "' Data Sources to rename");

$i = 1;
foreach ($data_source_list as $data_source) {
	if (!$debug)
		print ".";
	debug("Data Source Name '" . $data_source["name_cache"] . "' starting");
	api_reapply_suggested_data_source_title($data_source["local_data_id"]);
	update_data_source_title_cache($data_source["local_data_id"]);
	debug("Data Source Rename Done for Data Source '" . addslashes(get_data_source_title($data_source["local_data_id"])) . "'");
	$i++;
}

/*	display_help - displays the usage of the function */
function display_help() {
	print "Cacti Reapply Data Sources Names Script 1.0, Copyright 2008 - The Cacti Group\n\n";
	print "usage: poller_data_sources_reapply_names.php --id=[host_id|All][host_id1|host_id2|...] [--filter=[search_string] [--debug] [-h] [--help] [-v] [--version]\n\n";
	print "--id=host_id        - The host_id or 'All' or a pipe delimited list of host_id's\n";
	print "--filter=search_str - A data template name or data source title to search for\n";
	print "--debug             - Display verbose output during execution\n";
	print "-v --version        - Display this help message\n";
	print "-h --help           - Display this help message\n";
}

function debug($message) {
开发者ID:songchin,项目名称:Cacti,代码行数:31,代码来源:poller_data_sources_reapply_names.php

示例9: update_data_source_title_cache

function update_data_source_title_cache($local_data_id)
{
    db_execute("update data_template_data set name_cache='" . addslashes(get_data_source_title($local_data_id)) . "' where local_data_id={$local_data_id}");
    api_plugin_hook_function('update_data_source_title_cache', $local_data_id);
}
开发者ID:resmon,项目名称:resmon-cacti,代码行数:5,代码来源:variables.php

示例10: ds_edit

function ds_edit()
{
    global $struct_data_source, $struct_data_source_item, $data_source_types;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request('id'));
    input_validate_input_number(get_request_var_request('host_id'));
    /* ==================================================== */
    api_plugin_hook('data_source_edit_top');
    $use_data_template = true;
    $host_id = 0;
    if (!empty($_REQUEST['id'])) {
        $data_local = db_fetch_row_prepared('SELECT host_id, data_template_id FROM data_local WHERE id = ?', array($_REQUEST['id']));
        $data = db_fetch_row_prepared('SELECT * FROM data_template_data WHERE local_data_id = ?', array($_REQUEST['id']));
        if (isset($data_local['data_template_id']) && $data_local['data_template_id'] >= 0) {
            $data_template = db_fetch_row_prepared('SELECT id, name FROM data_template WHERE id = ?', array($data_local['data_template_id']));
            $data_template_data = db_fetch_row_prepared('SELECT * FROM data_template_data WHERE data_template_id = ? AND local_data_id = 0', array($data_local['data_template_id']));
        } else {
            $_SESSION['sess_messages'] = 'Data Source "' . $_REQUEST['id'] . '" does not exist.';
            header('Location: data_sources.php');
            exit;
        }
        $header_label = '[edit: ' . htmlspecialchars(get_data_source_title($_REQUEST['id'])) . ']';
        if (empty($data_local['data_template_id'])) {
            $use_data_template = false;
        }
    } else {
        $header_label = '[new]';
        $use_data_template = false;
    }
    /* handle debug mode */
    if (isset($_REQUEST['debug'])) {
        if ($_REQUEST['debug'] == '0') {
            kill_session_var('ds_debug_mode');
        } elseif ($_REQUEST['debug'] == '1') {
            $_SESSION['ds_debug_mode'] = true;
        }
    }
    top_header();
    if (!empty($_REQUEST['id'])) {
        ?>
		<table width='100%' align='center'>
			<tr>
				<td class='textInfo' colspan='2' valign='top'>
					<?php 
        print htmlspecialchars(get_data_source_title($_REQUEST['id']));
        ?>
				</td>
				<td class='textInfo' align='right' valign='top'>
					<span class='linkMarker'>*<a href='<?php 
        print htmlspecialchars('data_sources.php?action=ds_edit&id=' . (isset($_REQUEST['id']) ? $_REQUEST['id'] : '0'));
        ?>
&debug=<?php 
        print isset($_SESSION['ds_debug_mode']) ? '0' : '1';
        ?>
'>Turn <strong><?php 
        print isset($_SESSION['ds_debug_mode']) ? 'Off' : 'On';
        ?>
</strong> Data Source Debug Mode.</a><br>
					<?php 
        if (!empty($data_template['id'])) {
            ?>
<span class='linkMarker'>*<a href='<?php 
            print htmlspecialchars('data_templates.php?action=template_edit&id=' . (isset($data_template['id']) ? $data_template['id'] : '0'));
            ?>
'>Edit Data Template.</a><br><?php 
        }
        if (!empty($_REQUEST['host_id']) || !empty($data_local['host_id'])) {
            ?>
<span class='linkMarker'>*<a href='<?php 
            print htmlspecialchars('host.php?action=edit&id=' . (isset($_REQUEST['host_id']) ? $_REQUEST['host_id'] : $data_local['host_id']));
            ?>
'>Edit Device.</a><br><?php 
        }
        ?>
				</td>
			</tr>
		</table>
		<br>
		<?php 
    }
    html_start_box("<strong>Data Template Selection</strong> {$header_label}", '100%', '', '3', 'center', '');
    $form_array = array('data_template_id' => array('method' => 'drop_sql', 'friendly_name' => 'Selected Data Template', 'description' => 'The name given to this data template.', 'value' => isset($data_template) ? $data_template['id'] : '0', 'none_value' => 'None', 'sql' => 'SELECT id,name FROM data_template order by name'), 'host_id' => array('method' => 'drop_sql', 'friendly_name' => 'Device', 'description' => 'Choose the host that this graph belongs to.', 'value' => isset($_REQUEST['host_id']) ? $_REQUEST['host_id'] : $data_local['host_id'], 'none_value' => 'None', 'sql' => "SELECT id,CONCAT_WS('',description,' (',hostname,')') as name FROM host order by description,hostname"), '_data_template_id' => array('method' => 'hidden', 'value' => isset($data_template) ? $data_template['id'] : '0'), '_host_id' => array('method' => 'hidden', 'value' => empty($data_local['host_id']) ? isset($_REQUEST['host_id']) ? $_REQUEST['host_id'] : '0' : $data_local['host_id']), '_data_input_id' => array('method' => 'hidden', 'value' => isset($data['data_input_id']) ? $data['data_input_id'] : '0'), 'data_template_data_id' => array('method' => 'hidden', 'value' => isset($data) ? $data['id'] : '0'), 'local_data_template_data_id' => array('method' => 'hidden', 'value' => isset($data) ? $data['local_data_template_data_id'] : '0'), 'local_data_id' => array('method' => 'hidden', 'value' => isset($data) ? $data['local_data_id'] : '0'));
    draw_edit_form(array('config' => array(), 'fields' => $form_array));
    html_end_box();
    /* only display the "inputs" area if we are using a data template for this data source */
    if (!empty($data['data_template_id'])) {
        $template_data_rrds = db_fetch_assoc_prepared('SELECT * FROM data_template_rrd WHERE local_data_id = ? ORDER BY data_source_name', array($_REQUEST['id']));
        html_start_box('<strong>Supplemental Data Template Data</strong>', '100%', '', '3', 'center', '');
        draw_nontemplated_fields_data_source($data['data_template_id'], $data['local_data_id'], $data, '|field|', '<strong>Data Source Fields</strong>', true, true, 0);
        draw_nontemplated_fields_data_source_item($data['data_template_id'], $template_data_rrds, '|field|_|id|', '<strong>Data Source Item Fields</strong>', true, true, true, 0);
        draw_nontemplated_fields_custom_data($data['id'], 'value_|id|', '<strong>Custom Data</strong>', true, true, 0);
        form_hidden_box('save_component_data', '1', '');
        html_end_box();
    }
    if ((isset($_REQUEST['id']) || isset($_REQUEST['new'])) && empty($data['data_template_id'])) {
        html_start_box('<strong>Data Source</strong>', '100%', '', '3', 'center', '');
        $form_array = array();
        while (list($field_name, $field_array) = each($struct_data_source)) {
            $form_array += array($field_name => $struct_data_source[$field_name]);
            if (!($use_data_template == false || !empty($data_template_data['t_' . $field_name]) || $field_array['flags'] == 'NOTEMPLATE')) {
//.........这里部分代码省略.........
开发者ID:MrWnn,项目名称:cacti,代码行数:101,代码来源:data_sources.php

示例11: rrdtool_function_graph


//.........这里部分代码省略.........
			/* the following fields will be searched for graph variables */
			$variable_fields = array(
				"text_format" => array(
					"process_no_legend" => false
					),
				"value" => array(
					"process_no_legend" => true
					),
				"cdef_cache" => array(
					"process_no_legend" => true
					),
				"vdef_cache" => array(
					"process_no_legend" => true
					)
				);

			/* loop through each field that we want to substitute values for:
			currently: text format and value */
			while (list($field_name, $field_array) = each($variable_fields)) {
				/* certain fields do not require values when the legend is not to be shown */
				if (($field_array["process_no_legend"] == false) && (isset($graph_data_array["graph_nolegend"]))) {
					continue;
				}

				$graph_variables[$field_name][$graph_item_id] = $graph_item[$field_name];

				/* date/time substitution */
				if (strstr($graph_variables[$field_name][$graph_item_id], "|date_time|")) {
					$graph_variables[$field_name][$graph_item_id] = str_replace("|date_time|", date(date_time_format(), strtotime(db_fetch_cell("select value from settings where name='date'"))), $graph_variables[$field_name][$graph_item_id]);
				}

				/* data source title substitution */
				if (strstr($graph_variables[$field_name][$graph_item_id], "|data_source_title|")) {
					$graph_variables[$field_name][$graph_item_id] = str_replace("|data_source_title|", get_data_source_title($graph_item["local_data_id"]), $graph_variables[$field_name][$graph_item_id]);
				}

				/* data query variables */
				$graph_variables[$field_name][$graph_item_id] = rrd_substitute_device_query_data($graph_variables[$field_name][$graph_item_id], $graph, $graph_item);

				/* Nth percentile */
				if (preg_match_all("/\|([0-9]{1,2}):(bits|bytes):(\d):(current|total|max|total_peak|all_max_current|all_max_peak|aggregate_max|aggregate_sum|aggregate_current|aggregate):(\d)?\|/", $graph_variables[$field_name][$graph_item_id], $matches, PREG_SET_ORDER)) {
					foreach ($matches as $match) {
						$graph_variables[$field_name][$graph_item_id] = str_replace($match[0], variable_nth_percentile($match, $graph_item, $graph_items, $graph_start, $graph_end), $graph_variables[$field_name][$graph_item_id]);
					}
				}

				/* bandwidth summation */
				if (preg_match_all("/\|sum:(\d|auto):(current|total|atomic):(\d):(\d+|auto)\|/", $graph_variables[$field_name][$graph_item_id], $matches, PREG_SET_ORDER)) {
					foreach ($matches as $match) {
						$graph_variables[$field_name][$graph_item_id] = str_replace($match[0], variable_bandwidth_summation($match, $graph_item, $graph_items, $graph_start, $graph_end, $rra["steps"], $ds_step), $graph_variables[$field_name][$graph_item_id]);
					}
				}
			}

			/* if we are not displaying a legend there is no point in us even processing the auto padding,
			text format stuff. */
			if (!isset($graph_data_array["graph_nolegend"])) {
				/* set hard return variable if selected (\n) */
				if ($graph_item["hard_return"] == CHECKED) {
					$hardreturn[$graph_item_id] = "\\n";
				}else{
					$hardreturn[$graph_item_id] = "";
				}

				/* +++++++++++++++++++++++ LEGEND: AUTO PADDING (<>'s) +++++++++++++++++++++++ */
开发者ID:songchin,项目名称:Cacti,代码行数:66,代码来源:rrd.php

示例12: thold_data_source_action_prepare

function thold_data_source_action_prepare($save)
{
    global $config;
    if ($save['drp_action'] == 'plugin_thold_create') {
        /* get the valid thold templates
         * remove those hosts that do not have any valid templates
         */
        $templates = '';
        $found_list = '';
        $not_found = '';
        if (sizeof($save['ds_array'])) {
            foreach ($save['ds_array'] as $item) {
                $data_template_id = db_fetch_cell("SELECT data_template_id FROM data_local WHERE id={$item}");
                if ($data_template_id != '') {
                    if (sizeof(db_fetch_assoc("SELECT id FROM thold_template WHERE data_template_id={$data_template_id}"))) {
                        $found_list .= '<li>' . get_data_source_title($item) . '</li>';
                        if (strlen($templates)) {
                            $templates .= ", {$data_template_id}";
                        } else {
                            $templates = "{$data_template_id}";
                        }
                    } else {
                        $not_found .= '<li>' . get_data_source_title($item) . '</li>';
                    }
                } else {
                    $not_found .= '<li>' . get_data_source_title($item) . '</li>';
                }
            }
        }
        if (strlen($templates)) {
            $sql = 'SELECT id, name FROM thold_template WHERE data_template_id IN (' . $templates . ') ORDER BY name';
        } else {
            $sql = 'SELECT id, name FROM thold_template ORDER BY name';
        }
        print "<tr><td colspan='2' class='textArea'>\n";
        if (strlen($found_list)) {
            if (strlen($not_found)) {
                print '<p>' . __('The following Data Sources have no Threshold Templates associated with them') . '</p>';
                print '<ul>' . $not_found . '</ul>';
            }
            print '<p>' . __('Are you sure you wish to create Thresholds for these Data Sources?') . '</p>
					<ul>' . $found_list . "</ul>\n\t\t\t\t</td>\n\t\t\t</tr></table><table class='cactiTable'>\n";
            $form_array = array('general_header' => array('friendly_name' => __('Available Threshold Templates'), 'method' => 'spacer'), 'thold_template_id' => array('method' => 'drop_sql', 'friendly_name' => __('Select a Threshold Template'), 'description' => '', 'none_value' => __('None'), 'value' => __('None'), 'sql' => $sql));
            draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => $form_array));
            print "</tr></table>\n";
        } else {
            if (strlen($not_found)) {
                print '<p>' . __('There are no Threshold Templates associated with the following Data Sources') . '</p>';
                print '<ul>' . $not_found . '</ul>';
            }
        }
    } else {
        return $save;
    }
}
开发者ID:Cacti,项目名称:plugin_thold,代码行数:55,代码来源:setup.php


注:本文中的get_data_source_title函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。