本文整理汇总了PHP中update_data_source_title_cache函数的典型用法代码示例。如果您正苦于以下问题:PHP update_data_source_title_cache函数的具体用法?PHP update_data_source_title_cache怎么用?PHP update_data_source_title_cache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update_data_source_title_cache函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_data_source_title_cache_from_host
function update_data_source_title_cache_from_host($host_id)
{
$data = db_fetch_assoc_prepared('SELECT id FROM data_local WHERE host_id = ?', array($host_id));
if (sizeof($data) > 0) {
foreach ($data as $item) {
update_data_source_title_cache($item['id']);
}
}
}
示例2: update_data_source_title_cache_from_host
function update_data_source_title_cache_from_host($host_id) {
$data = db_fetch_assoc("select id from data_local where host_id=$host_id");
if (sizeof($data) > 0) {
foreach ($data as $item) {
update_data_source_title_cache($item["id"]);
}
}
}
示例3: db_fetch_assoc
$snmp_query_array["snmp_query_graph_id"] = $dsGraph["snmpQueryType"];
$snmp_indexes = db_fetch_assoc("SELECT snmp_index\r\n\t\t\tFROM host_snmp_cache\r\n\t\t\tWHERE host_id=" . $hostId . "\r\n\t\t\tAND snmp_query_id=" . $dsGraph["snmpQueryId"] . "\r\n\t\t\tAND field_name='" . $dsGraph["snmpField"] . "'\r\n\t\t\tAND field_value='" . $dsGraph["snmpValue"] . "'");
if (sizeof($snmp_indexes)) {
foreach ($snmp_indexes as $snmp_index) {
$snmp_query_array["snmp_index"] = $snmp_index["snmp_index"];
$existsAlready = db_fetch_cell("SELECT id\r\n\t\t\t\t\tFROM graph_local\r\n\t\t\t\t\tWHERE graph_template_id={$templateId}\r\n\t\t\t\t\tAND host_id={$hostId}\r\n\t\t\t\t\tAND snmp_query_id=" . $dsGraph["snmpQueryId"] . "\r\n\t\t\t\t\tAND snmp_index='" . $snmp_query_array["snmp_index"] . "'");
if (isset($existsAlready) && $existsAlready > 0) {
if ($graphTitle != "") {
db_execute("UPDATE graph_templates_graph\r\n\t\t\t\t\t\t\tSET title = \"{$graphTitle}\"\r\n\t\t\t\t\t\t\tWHERE local_graph_id = {$existsAlready}");
update_graph_title_cache($existsAlready);
}
$dataSourceId = db_fetch_cell("SELECT\r\n\t\t\t\t\t\tdata_template_rrd.local_data_id\r\n\t\t\t\t\t\tFROM graph_templates_item, data_template_rrd\r\n\t\t\t\t\t\tWHERE graph_templates_item.local_graph_id = " . $existsAlready . "\r\n\t\t\t\t\t\tAND graph_templates_item.task_item_id = data_template_rrd.id\r\n\t\t\t\t\t\tLIMIT 1");
/* modify for multi user start */
if ($dataTitle != "") {
db_execute("UPDATE data_template_data\r\n SET name=\"{$dataTitle}\"\r\n WHERE local_data_id=" . $dataSourceId);
update_data_source_title_cache($dataSourceId);
}
/* modify for multi user end */
echo "NOTE: Not Adding Graph - this graph already exists - graph-id: ({$existsAlready}) - data-source-id: ({$dataSourceId})\n";
continue;
}
$empty = array();
/* Suggested Values are not been implemented */
$returnArray = create_complete_graph_from_template($templateId, $hostId, $snmp_query_array, $empty);
if ($graphTitle != "") {
db_execute("UPDATE graph_templates_graph\r\n\t\t\t\t\t\tSET title=\"{$graphTitle}\"\r\n\t\t\t\t\t\tWHERE local_graph_id=" . $returnArray["local_graph_id"]);
update_graph_title_cache($returnArray["local_graph_id"]);
}
$dataSourceId = db_fetch_cell("SELECT\r\n\t\t\t\t\tdata_template_rrd.local_data_id\r\n\t\t\t\t\tFROM graph_templates_item, data_template_rrd\r\n\t\t\t\t\tWHERE graph_templates_item.local_graph_id = " . $returnArray["local_graph_id"] . "\r\n\t\t\t\t\tAND graph_templates_item.task_item_id = data_template_rrd.id\r\n\t\t\t\t\tLIMIT 1");
foreach ($returnArray["local_data_id"] as $item) {
push_out_host($hostId, $item);
示例4: template
//.........这里部分代码省略.........
AND snmp_index='" . $snmp_query_array["snmp_index"] . "'");
/* save the value to index on (ie. ifindex, ifip, etc) */
db_execute("REPLACE INTO data_input_data
(data_input_field_id, data_template_data_id, t_value, value)
VALUES (" . $data_input_field["index_type"] . ", $data_template_data_id, '', '" . $snmp_query_array["snmp_index_on"] . "')");
/* save the actual value (ie. 3, 192.168.1.101, etc) */
db_execute("REPLACE INTO data_input_data
(data_input_field_id,data_template_data_id,t_value,value)
VALUES (" . $data_input_field["index_value"] . ",$data_template_data_id,'','" . addslashes($snmp_cache_value) . "')");
/* set the expected output type (ie. bytes, errors, packets) */
db_execute("REPLACE INTO data_input_data
(data_input_field_id,data_template_data_id,t_value,value)
VALUES (" . $data_input_field["output_type"] . ",$data_template_data_id,'','" . $snmp_query_array["snmp_query_graph_id"] . "')");
/* now that we have put data into the 'data_input_data' table, update the snmp cache for ds's */
update_data_source_data_query_cache($cache_array["local_data_id"]{$data_template["id"]});
}
/* suggested values: data source */
if (isset($suggested_values_array[$graph_template_id]["data_template"]{$data_template["id"]})) {
reset($suggested_values_array[$graph_template_id]["data_template"]{$data_template["id"]});
while (list($field_name, $field_value) = each($suggested_values_array[$graph_template_id]["data_template"]{$data_template["id"]})) {
db_execute("UPDATE data_template_data
SET $field_name='$field_value'
WHERE local_data_id=" . $cache_array["local_data_id"]{$data_template["id"]});
}
}
/* suggested values: data source item */
if (isset($suggested_values_array[$graph_template_id]["data_template_item"])) {
reset($suggested_values_array[$graph_template_id]["data_template_item"]);
while (list($data_template_item_id, $field_array) = each($suggested_values_array[$graph_template_id]["data_template_item"])) {
while (list($field_name, $field_value) = each($field_array)) {
$data_source_item_id = db_fetch_cell("select id from data_template_rrd where local_data_template_rrd_id=$data_template_item_id and local_data_id=" . $cache_array["local_data_id"]{$data_template["id"]});
db_execute("UPDATE data_template_rrd
SET $field_name='$field_value'
WHERE id=$data_source_item_id");
}
}
}
/* suggested values: custom data */
if (isset($suggested_values_array[$graph_template_id]["custom_data"]{$data_template["id"]})) {
reset($suggested_values_array[$graph_template_id]["custom_data"]{$data_template["id"]});
while (list($data_input_field_id, $field_value) = each($suggested_values_array[$graph_template_id]["custom_data"]{$data_template["id"]})) {
db_execute("replace into data_input_data (data_input_field_id,data_template_data_id,t_value,value) values ($data_input_field_id,$data_template_data_id,'','$field_value')");
}
}
update_data_source_title_cache($cache_array["local_data_id"]{$data_template["id"]});
}
}
/* connect the dots: graph -> data source(s) */
$template_item_list = db_fetch_assoc("select
graph_templates_item.id,
data_template_rrd.id as data_template_rrd_id,
data_template_rrd.data_template_id
from (graph_templates_item,data_template_rrd)
where graph_templates_item.task_item_id=data_template_rrd.id
and graph_templates_item.graph_template_id=$graph_template_id
and local_graph_id=0
and task_item_id>0");
/* loop through each item affected and update column data */
if (sizeof($template_item_list) > 0) {
foreach ($template_item_list as $template_item) {
$local_data_id = $cache_array["local_data_id"]{$template_item["data_template_id"]};
$graph_template_item_id = db_fetch_cell("select id from graph_templates_item where local_graph_template_item_id=" . $template_item["id"] . " and local_graph_id=" . $cache_array["local_graph_id"]);
$data_template_rrd_id = db_fetch_cell("select id from data_template_rrd where local_data_template_rrd_id=" . $template_item["data_template_rrd_id"] . " and local_data_id=$local_data_id");
if (!empty($data_template_rrd_id)) {
db_execute("update graph_templates_item set task_item_id='$data_template_rrd_id' where id=$graph_template_item_id");
}
}
}
/* this will not work until the ds->graph dots are connected */
if (is_array($snmp_query_array)) {
update_graph_data_query_cache($cache_array["local_graph_id"]);
}
# now that we have the id of the new host, we may plugin postprocessing code
$save["id"] = $cache_array["local_graph_id"];
$save["graph_template_id"] = $graph_template_id; // attention: unset!
if (is_array($snmp_query_array)) {
$save["snmp_query_id"] = $snmp_query_array["snmp_query_id"];
$save["snmp_index"] = $snmp_query_array["snmp_index"];
} else {
$save["snmp_query_id"] = 0;
$save["snmp_index"] = 0;
}
api_plugin_hook_function('create_complete_graph_from_template', $save);
return $cache_array;
}
示例5: update_data_source_data_query_cache
function update_data_source_data_query_cache($local_data_id) {
$host_id = db_fetch_cell("select host_id from data_local where id=$local_data_id");
$field = data_query_field_list(db_fetch_cell("select
data_template_data.id
from data_template_data
where data_template_data.local_data_id=$local_data_id"));
if (empty($field)) { return; }
$data_query_id = db_fetch_cell("select snmp_query_id from snmp_query_graph where id='" . $field["output_type"] . "'");
$index = data_query_index($field["index_type"], $field["index_value"], $host_id, $data_query_id);
if (($data_query_id != "0") && ($index != "")) {
db_execute("update data_local set snmp_query_id='$data_query_id',snmp_index='$index' where id='$local_data_id'");
/* update data source title cache */
update_data_source_title_cache($local_data_id);
}
}
示例6: form_actions
function form_actions()
{
global $colors, $ds_actions;
/* if we are to save this form, instead of display it */
if (isset($_POST["selected_items"])) {
$selected_items = unserialize(stripslashes($_POST["selected_items"]));
if ($_POST["drp_action"] == "1") {
/* delete */
if (!isset($_POST["delete_type"])) {
$_POST["delete_type"] = 1;
}
switch ($_POST["delete_type"]) {
case '2':
/* delete all graph items tied to this data source */
$data_template_rrds = db_fetch_assoc("select id from data_template_rrd where " . array_to_sql_or($selected_items, "local_data_id"));
/* loop through each data source item */
if (sizeof($data_template_rrds) > 0) {
foreach ($data_template_rrds as $item) {
db_execute("delete from graph_templates_item where task_item_id=" . $item["id"] . " and local_graph_id > 0");
}
}
break;
case '3':
/* delete all graphs tied to this data source */
$graphs = db_fetch_assoc("select\n\t\t\t\t\t\tgraph_templates_graph.local_graph_id\n\t\t\t\t\t\tfrom (data_template_rrd,graph_templates_item,graph_templates_graph)\n\t\t\t\t\t\twhere graph_templates_item.task_item_id=data_template_rrd.id\n\t\t\t\t\t\tand graph_templates_item.local_graph_id=graph_templates_graph.local_graph_id\n\t\t\t\t\t\tand " . array_to_sql_or($selected_items, "data_template_rrd.local_data_id") . "\n\t\t\t\t\t\tand graph_templates_graph.local_graph_id > 0\n\t\t\t\t\t\tgroup by graph_templates_graph.local_graph_id");
if (sizeof($graphs) > 0) {
foreach ($graphs as $graph) {
api_graph_remove($graph["local_graph_id"]);
}
}
break;
}
for ($i = 0; $i < count($selected_items); $i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
/* ==================================================== */
api_data_source_remove($selected_items[$i]);
}
} elseif ($_POST["drp_action"] == "2") {
/* change graph template */
for ($i = 0; $i < count($selected_items); $i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
input_validate_input_number(get_request_var_post("data_template_id"));
/* ==================================================== */
change_data_template($selected_items[$i], $_POST["data_template_id"]);
}
} elseif ($_POST["drp_action"] == "3") {
/* change host */
for ($i = 0; $i < count($selected_items); $i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
input_validate_input_number(get_request_var_post("host_id"));
/* ==================================================== */
db_execute("update data_local set host_id=" . $_POST["host_id"] . " where id=" . $selected_items[$i]);
push_out_host($_POST["host_id"], $selected_items[$i]);
update_data_source_title_cache($selected_items[$i]);
}
} elseif ($_POST["drp_action"] == "4") {
/* duplicate */
for ($i = 0; $i < count($selected_items); $i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
/* ==================================================== */
duplicate_data_source($selected_items[$i], 0, $_POST["title_format"]);
}
} elseif ($_POST["drp_action"] == "5") {
/* data source -> data template */
for ($i = 0; $i < count($selected_items); $i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
/* ==================================================== */
data_source_to_data_template($selected_items[$i], $_POST["title_format"]);
}
} elseif ($_POST["drp_action"] == "6") {
/* data source enable */
for ($i = 0; $i < count($selected_items); $i++) {
api_data_source_enable($selected_items[$i]);
}
} elseif ($_POST["drp_action"] == "7") {
/* data source disable */
for ($i = 0; $i < count($selected_items); $i++) {
api_data_source_disable($selected_items[$i]);
}
}
header("Location: data_sources.php");
exit;
}
/* setup some variables */
$ds_list = "";
$i = 0;
/* loop through each of the graphs selected on the previous page and get more info about them */
while (list($var, $val) = each($_POST)) {
if (ereg("^chk_([0-9]+)\$", $var, $matches)) {
/* ================= input validation ================= */
input_validate_input_number($matches[1]);
/* ==================================================== */
$ds_list .= "<li>" . get_data_source_title($matches[1]) . "<br>";
$ds_array[$i] = $matches[1];
}
//.........这里部分代码省略.........
示例7: duplicate_data_source
//.........这里部分代码省略.........
$data_template_rrds = db_fetch_assoc("select * from data_template_rrd where local_data_id=$_local_data_id");
$data_input_datas = db_fetch_assoc("select * from data_input_data where data_template_data_id=" . $data_template_data["id"]);
$data_template_data_rras = db_fetch_assoc("select * from data_template_data_rra where data_template_data_id=" . $data_template_data["id"]);
/* create new entry: data_local */
$save["id"] = 0;
$save["data_template_id"] = $data_local["data_template_id"];
$save["device_id"] = $data_local["device_id"];
$save["snmp_query_id"] = $data_local["snmp_query_id"];
$save["snmp_index"] = $data_local["snmp_index"];
$local_data_id = sql_save($save, "data_local");
$data_template_data["name"] = str_replace(__("<ds_title>"), $data_template_data["name"], $data_source_title);
}elseif (!empty($_data_template_id)) {
$data_template = db_fetch_row("select * from data_template where id=$_data_template_id");
$data_template_data = db_fetch_row("select * from data_template_data where data_template_id=$_data_template_id and local_data_id=0");
$data_template_rrds = db_fetch_assoc("select * from data_template_rrd where data_template_id=$_data_template_id and local_data_id=0");
$data_input_datas = db_fetch_assoc("select * from data_input_data where data_template_data_id=" . $data_template_data["id"]);
$data_template_data_rras = db_fetch_assoc("select * from data_template_data_rra where data_template_data_id=" . $data_template_data["id"]);
/* create new entry: data_template */
$save["id"] = 0;
$save["hash"] = get_hash_data_template(0);
$save["name"] = str_replace(__("<template_title>"), $data_template["name"], $data_source_title);
$data_template_id = sql_save($save, "data_template");
}
unset($save);
$struct_data_source = data_source_form_list();
unset($struct_data_source["rra_id"]);
unset($struct_data_source["data_source_path"]);
reset($struct_data_source);
/* create new entry: data_template_data */
$save["id"] = 0;
$save["local_data_id"] = (isset($local_data_id) ? $local_data_id : 0);
$save["local_data_template_data_id"] = (isset($data_template_data["local_data_template_data_id"]) ? $data_template_data["local_data_template_data_id"] : 0);
$save["data_template_id"] = (!empty($_local_data_id) ? $data_template_data["data_template_id"] : $data_template_id);
$save["name_cache"] = $data_template_data["name_cache"];
while (list($field, $array) = each($struct_data_source)) {
$save{$field} = $data_template_data{$field};
if ($array["flags"] != "ALWAYSTEMPLATE") {
$save{"t_" . $field} = $data_template_data{"t_" . $field};
}
}
$data_template_data_id = sql_save($save, "data_template_data");
/* create new entry(s): data_template_rrd */
if (sizeof($data_template_rrds) > 0) {
$struct_data_source_item = data_source_item_form_list();
foreach ($data_template_rrds as $data_template_rrd) {
unset($save);
reset($struct_data_source_item);
$save["id"] = 0;
$save["local_data_id"] = (isset($local_data_id) ? $local_data_id : 0);
$save["local_data_template_rrd_id"] = (isset($data_template_rrd["local_data_template_rrd_id"]) ? $data_template_rrd["local_data_template_rrd_id"] : 0);
$save["data_template_id"] = (!empty($_local_data_id) ? $data_template_rrd["data_template_id"] : $data_template_id);
if ($save["local_data_id"] == 0) {
$save["hash"] = get_hash_data_template($data_template_rrd["local_data_template_rrd_id"], "data_template_item");
} else {
$save["hash"] = '';
}
while (list($field, $array) = each($struct_data_source_item)) {
$save{$field} = $data_template_rrd{$field};
}
$data_template_rrd_id = sql_save($save, "data_template_rrd");
}
}
/* create new entry(s): data_input_data */
if (sizeof($data_input_datas) > 0) {
foreach ($data_input_datas as $data_input_data) {
db_execute("insert into data_input_data (data_input_field_id,data_template_data_id,t_value,value) values
(" . $data_input_data["data_input_field_id"] . ",$data_template_data_id,'" . $data_input_data["t_value"] .
"','" . $data_input_data["value"] . "')");
}
}
/* create new entry(s): data_template_data_rra */
if (sizeof($data_template_data_rras) > 0) {
foreach ($data_template_data_rras as $data_template_data_rra) {
db_execute("insert into data_template_data_rra (data_template_data_id,rra_id) values ($data_template_data_id,
" . $data_template_data_rra["rra_id"] . ")");
}
}
if (!empty($_local_data_id)) {
update_data_source_title_cache($local_data_id);
}
}
示例8: duplicate_data_source
function duplicate_data_source($_local_data_id, $_data_template_id, $data_source_title)
{
global $struct_data_source, $struct_data_source_item;
if (!empty($_local_data_id)) {
$data_local = db_fetch_row("select * from data_local where id={$_local_data_id}");
$data_template_data = db_fetch_row("select * from data_template_data where local_data_id={$_local_data_id}");
$data_template_rrds = db_fetch_assoc("select * from data_template_rrd where local_data_id={$_local_data_id}");
$data_input_datas = db_fetch_assoc("select * from data_input_data where data_template_data_id=" . $data_template_data["id"]);
$data_template_data_rras = db_fetch_assoc("select * from data_template_data_rra where data_template_data_id=" . $data_template_data["id"]);
/* create new entry: data_local */
$save["id"] = 0;
$save["data_template_id"] = $data_local["data_template_id"];
$save["host_id"] = $data_local["host_id"];
$save["snmp_query_id"] = $data_local["snmp_query_id"];
$save["snmp_index"] = $data_local["snmp_index"];
$local_data_id = sql_save($save, "data_local");
$data_template_data["name"] = str_replace("<ds_title>", $data_template_data["name"], $data_source_title);
} elseif (!empty($_data_template_id)) {
$data_template = db_fetch_row("select * from data_template where id={$_data_template_id}");
$data_template_data = db_fetch_row("select * from data_template_data where data_template_id={$_data_template_id} and local_data_id=0");
$data_template_rrds = db_fetch_assoc("select * from data_template_rrd where data_template_id={$_data_template_id} and local_data_id=0");
$data_input_datas = db_fetch_assoc("select * from data_input_data where data_template_data_id=" . $data_template_data["id"]);
$data_template_data_rras = db_fetch_assoc("select * from data_template_data_rra where data_template_data_id=" . $data_template_data["id"]);
/* create new entry: data_template */
$save["id"] = 0;
$save["hash"] = get_hash_data_template(0);
$save["name"] = str_replace("<template_title>", $data_template["name"], $data_source_title);
$data_template_id = sql_save($save, "data_template");
}
unset($save);
unset($struct_data_source["rra_id"]);
unset($struct_data_source["data_source_path"]);
reset($struct_data_source);
/* create new entry: data_template_data */
$save["id"] = 0;
$save["local_data_id"] = isset($local_data_id) ? $local_data_id : 0;
$save["local_data_template_data_id"] = isset($data_template_data["local_data_template_data_id"]) ? $data_template_data["local_data_template_data_id"] : 0;
$save["data_template_id"] = !empty($_local_data_id) ? $data_template_data["data_template_id"] : $data_template_id;
$save["name_cache"] = $data_template_data["name_cache"];
while (list($field, $array) = each($struct_data_source)) {
$save[$field] = $data_template_data[$field];
if ($array["flags"] != "ALWAYSTEMPLATE") {
$save["t_" . $field] = $data_template_data["t_" . $field];
}
}
$data_template_data_id = sql_save($save, "data_template_data");
/* create new entry(s): data_template_rrd */
if (sizeof($data_template_rrds) > 0) {
foreach ($data_template_rrds as $data_template_rrd) {
unset($save);
reset($struct_data_source_item);
$save["id"] = 0;
$save["local_data_id"] = isset($local_data_id) ? $local_data_id : 0;
$save["local_data_template_rrd_id"] = isset($data_template_rrd["local_data_template_rrd_id"]) ? $data_template_rrd["local_data_template_rrd_id"] : 0;
$save["data_template_id"] = !empty($_local_data_id) ? $data_template_rrd["data_template_id"] : $data_template_id;
if ($save["local_data_id"] == 0) {
$save["hash"] = get_hash_data_template($data_template_rrd["local_data_template_rrd_id"], "data_template_item");
} else {
$save["hash"] = '';
}
while (list($field, $array) = each($struct_data_source_item)) {
$save[$field] = $data_template_rrd[$field];
}
$data_template_rrd_id = sql_save($save, "data_template_rrd");
}
}
/* create new entry(s): data_input_data */
if (sizeof($data_input_datas) > 0) {
foreach ($data_input_datas as $data_input_data) {
db_execute("insert into data_input_data (data_input_field_id,data_template_data_id,t_value,value) values\n\t\t\t(" . $data_input_data["data_input_field_id"] . ",{$data_template_data_id},'" . $data_input_data["t_value"] . "','" . $data_input_data["value"] . "')");
}
}
/* create new entry(s): data_template_data_rra */
if (sizeof($data_template_data_rras) > 0) {
foreach ($data_template_data_rras as $data_template_data_rra) {
db_execute("insert into data_template_data_rra (data_template_data_id,rra_id) values ({$data_template_data_id},\n\t\t\t" . $data_template_data_rra["rra_id"] . ")");
}
}
if (!empty($_local_data_id)) {
update_data_source_title_cache($local_data_id);
}
}
示例9: form_actions
function form_actions()
{
global $ds_actions;
/* ================= input validation ================= */
input_validate_input_regex(get_request_var_post('drp_action'), "^([a-zA-Z0-9_]+)\$");
/* ==================================================== */
/* if we are to save this form, instead of display it */
if (isset($_POST["selected_items"])) {
$selected_items = sanitize_unserialize_selected_items($_POST['selected_items']);
if ($selected_items != false) {
if ($_POST["drp_action"] == "1") {
/* delete */
if (!isset($_POST["delete_type"])) {
$_POST["delete_type"] = 1;
}
switch ($_POST["delete_type"]) {
case '2':
/* delete all graph items tied to this data source */
$data_template_rrds = array_rekey(db_fetch_assoc("select id from data_template_rrd where " . array_to_sql_or($selected_items, "local_data_id")), "id", "id");
/* loop through each data source item */
if (sizeof($data_template_rrds) > 0) {
db_execute("delete from graph_templates_item where task_item_id IN (" . implode(",", $data_template_rrds) . ") and local_graph_id > 0");
}
api_plugin_hook_function('graph_items_remove', $data_template_rrds);
break;
case '3':
/* delete all graphs tied to this data source */
$graphs = array_rekey(db_fetch_assoc("select\n\t\t\t\t\t\t\tgraph_templates_graph.local_graph_id\n\t\t\t\t\t\t\tfrom (data_template_rrd,graph_templates_item,graph_templates_graph)\n\t\t\t\t\t\t\twhere graph_templates_item.task_item_id=data_template_rrd.id\n\t\t\t\t\t\t\tand graph_templates_item.local_graph_id=graph_templates_graph.local_graph_id\n\t\t\t\t\t\t\tand " . array_to_sql_or($selected_items, "data_template_rrd.local_data_id") . "\n\t\t\t\t\t\t\tand graph_templates_graph.local_graph_id > 0\n\t\t\t\t\t\t\tgroup by graph_templates_graph.local_graph_id"), "local_graph_id", "local_graph_id");
if (sizeof($graphs) > 0) {
api_graph_remove_multi($graphs);
}
api_plugin_hook_function('graphs_remove', $graphs);
break;
}
api_data_source_remove_multi($selected_items);
api_plugin_hook_function('data_source_remove', $selected_items);
} elseif ($_POST["drp_action"] == "2") {
/* change graph template */
input_validate_input_number(get_request_var_post("data_template_id"));
for ($i = 0; $i < count($selected_items); $i++) {
change_data_template($selected_items[$i], $_POST["data_template_id"]);
}
} elseif ($_POST["drp_action"] == "3") {
/* change host */
input_validate_input_number(get_request_var_post("host_id"));
for ($i = 0; $i < count($selected_items); $i++) {
db_execute("update data_local set host_id=" . $_POST["host_id"] . " where id=" . $selected_items[$i]);
push_out_host($_POST["host_id"], $selected_items[$i]);
update_data_source_title_cache($selected_items[$i]);
}
} elseif ($_POST["drp_action"] == "4") {
/* duplicate */
for ($i = 0; $i < count($selected_items); $i++) {
duplicate_data_source($selected_items[$i], 0, $_POST["title_format"]);
}
} elseif ($_POST["drp_action"] == "5") {
/* data source -> data template */
for ($i = 0; $i < count($selected_items); $i++) {
data_source_to_data_template($selected_items[$i], $_POST["title_format"]);
}
} elseif ($_POST["drp_action"] == "6") {
/* data source enable */
for ($i = 0; $i < count($selected_items); $i++) {
api_data_source_enable($selected_items[$i]);
}
} elseif ($_POST["drp_action"] == "7") {
/* data source disable */
for ($i = 0; $i < count($selected_items); $i++) {
api_data_source_disable($selected_items[$i]);
}
} elseif ($_POST["drp_action"] == "8") {
/* reapply suggested data source naming */
for ($i = 0; $i < count($selected_items); $i++) {
api_reapply_suggested_data_source_title($selected_items[$i]);
update_data_source_title_cache($selected_items[$i]);
}
} else {
api_plugin_hook_function('data_source_action_execute', $_POST['drp_action']);
}
api_plugin_hook_function('data_source_action_bottom', array($_POST['drp_action'], $selected_items));
}
header("Location: data_sources.php");
exit;
}
/* setup some variables */
$ds_list = "";
$i = 0;
/* loop through each of the graphs selected on the previous page and get more info about them */
while (list($var, $val) = each($_POST)) {
if (preg_match("/^chk_([0-9]+)\$/", $var, $matches)) {
/* ================= input validation ================= */
input_validate_input_number($matches[1]);
/* ==================================================== */
$ds_list .= "<li>" . htmlspecialchars(get_data_source_title($matches[1])) . "</li>";
$ds_array[$i] = $matches[1];
$i++;
}
}
include_once "./include/top_header.php";
html_start_box("<strong>" . $ds_actions[$_POST["drp_action"]] . "</strong>", "60%", "", "3", "center", "");
//.........这里部分代码省略.........
示例10: debug
LEFT JOIN data_template
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";
}
示例11: data_source_form_actions
function data_source_form_actions() {
global $colors;
require(CACTI_BASE_PATH . "/include/data_source/data_source_arrays.php");
/* if we are to save this form, instead of display it */
if (isset($_POST["selected_items"])) {
$selected_items = unserialize(stripslashes($_POST["selected_items"]));
if (get_request_var_post("drp_action") === DS_ACTION_DELETE) { /* delete */
if (!isset($_POST["delete_type"])) { $_POST["delete_type"] = 1; }
switch (get_request_var_post("delete_type")) {
case '2': /* delete all graph items tied to this data source */
$data_template_rrds = db_fetch_assoc("select id from data_template_rrd where " . array_to_sql_or($selected_items, "local_data_id"));
/* loop through each data source item */
if (sizeof($data_template_rrds) > 0) {
foreach ($data_template_rrds as $item) {
db_execute("delete from graph_templates_item where task_item_id=" . $item["id"] . " and local_graph_id > 0");
}
}
break;
case '3': /* delete all graphs tied to this data source */
$graphs = db_fetch_assoc("select
graph_templates_graph.local_graph_id
from (data_template_rrd,graph_templates_item,graph_templates_graph)
where graph_templates_item.task_item_id=data_template_rrd.id
and graph_templates_item.local_graph_id=graph_templates_graph.local_graph_id
and " . array_to_sql_or($selected_items, "data_template_rrd.local_data_id") . "
and graph_templates_graph.local_graph_id > 0
group by graph_templates_graph.local_graph_id");
if (sizeof($graphs) > 0) {
foreach ($graphs as $graph) {
api_graph_remove($graph["local_graph_id"]);
}
}
break;
}
for ($i=0;($i<count($selected_items));$i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
/* ==================================================== */
api_data_source_remove($selected_items[$i]);
}
}elseif (get_request_var_post("drp_action") === DS_ACTION_CHANGE_TEMPLATE) { /* change graph template */
for ($i=0;($i<count($selected_items));$i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
input_validate_input_number(get_request_var_post("data_template_id"));
/* ==================================================== */
change_data_template($selected_items[$i], get_request_var_post("data_template_id"));
}
}elseif (get_request_var_post("drp_action") === DS_ACTION_CHANGE_HOST) { /* change device */
for ($i=0;($i<count($selected_items));$i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
input_validate_input_number(get_request_var_post("device_id"));
/* ==================================================== */
db_execute("update data_local set device_id=" . $_POST["device_id"] . " where id=" . $selected_items[$i]);
push_out_device(get_request_var_post("device_id"), $selected_items[$i]);
update_data_source_title_cache($selected_items[$i]);
}
}elseif (get_request_var_post("drp_action") === DS_ACTION_DUPLICATE) { /* duplicate */
for ($i=0;($i<count($selected_items));$i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
/* ==================================================== */
duplicate_data_source($selected_items[$i], 0, get_request_var_post("title_format"));
}
}elseif (get_request_var_post("drp_action") === DS_ACTION_CONVERT_TO_TEMPLATE) { /* data source -> data template */
for ($i=0;($i<count($selected_items));$i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
/* ==================================================== */
data_source_to_data_template($selected_items[$i], get_request_var_post("title_format"));
}
}elseif (get_request_var_post("drp_action") === DS_ACTION_ENABLE) { /* data source enable */
for ($i=0;($i<count($selected_items));$i++) {
api_data_source_enable($selected_items[$i]);
}
}elseif (get_request_var_post("drp_action") === DS_ACTION_DISABLE) { /* data source disable */
for ($i=0;($i<count($selected_items));$i++) {
api_data_source_disable($selected_items[$i]);
}
}elseif (get_request_var_post("drp_action") === DS_ACTION_REAPPLY_SUGGESTED_NAMES) { /* reapply suggested data source naming */
for ($i=0;($i<count($selected_items));$i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
/* ==================================================== */
api_reapply_suggested_data_source_title($selected_items[$i]);
update_data_source_title_cache($selected_items[$i]);
//.........这里部分代码省略.........
示例12: create_complete_graph_from_template
//.........这里部分代码省略.........
while (list($graph_template_item_id, $field_array) = each($suggested_values_array[$graph_template_id]["graph_template_item"])) {
while (list($field_name, $field_value) = each($field_array)) {
$graph_item_id = db_fetch_cell("select id from graph_templates_item where local_graph_template_item_id={$graph_template_item_id} and local_graph_id=" . $cache_array["local_graph_id"]);
db_execute("update graph_templates_item set {$field_name}='{$field_value}' where id={$graph_item_id}");
}
}
}
update_graph_title_cache($cache_array["local_graph_id"]);
/* create each data source */
$data_templates = db_fetch_assoc("select\n\t\tdata_template.id,\n\t\tdata_template.name,\n\t\tdata_template_rrd.data_source_name\n\t\tfrom (data_template, data_template_rrd, graph_templates_item)\n\t\twhere graph_templates_item.task_item_id=data_template_rrd.id\n\t\tand data_template_rrd.data_template_id=data_template.id\n\t\tand data_template_rrd.local_data_id=0\n\t\tand graph_templates_item.local_graph_id=0\n\t\tand graph_templates_item.graph_template_id=" . $graph_template_id . "\n\t\tgroup by data_template.id\n\t\torder by data_template.name");
if (sizeof($data_templates) > 0) {
foreach ($data_templates as $data_template) {
unset($save);
$save["id"] = 0;
$save["data_template_id"] = $data_template["id"];
$save["host_id"] = $host_id;
$cache_array["local_data_id"][$data_template["id"]] = sql_save($save, "data_local");
change_data_template($cache_array["local_data_id"][$data_template["id"]], $data_template["id"]);
$data_template_data_id = db_fetch_cell("select id from data_template_data where local_data_id=" . $cache_array["local_data_id"][$data_template["id"]]);
if (is_array($snmp_query_array)) {
/* suggested values for snmp query code */
$suggested_values = db_fetch_assoc("select text,field_name from snmp_query_graph_rrd_sv where snmp_query_graph_id=" . $snmp_query_array["snmp_query_graph_id"] . " and data_template_id=" . $data_template["id"] . " order by sequence");
if (sizeof($suggested_values) > 0) {
foreach ($suggested_values as $suggested_value) {
/* once we find a match; don't try to find more */
if (!isset($suggested_values_ds[$data_template["id"]][$suggested_value["field_name"]])) {
$subs_string = substitute_snmp_query_data($suggested_value["text"], $host_id, $snmp_query_array["snmp_query_id"], $snmp_query_array["snmp_index"], read_config_option("max_data_query_field_length"));
/* if there are no '|' characters, all of the substitutions were successful */
if (!strstr($subs_string, "|query")) {
if (sizeof(db_fetch_row("show columns from data_template_data like '" . $suggested_value["field_name"] . "'"))) {
db_execute("update data_template_data set " . $suggested_value["field_name"] . "='" . addslashes($suggested_value["text"]) . "' where local_data_id=" . $cache_array["local_data_id"][$data_template["id"]]);
}
/* once we find a working value, stop */
$suggested_values_ds[$data_template["id"]][$suggested_value["field_name"]] = true;
if (sizeof(db_fetch_row("show columns from data_template_rrd like '" . $suggested_value["field_name"] . "'")) && !substr_count($subs_string, "|")) {
db_execute("update data_template_rrd set " . $suggested_value["field_name"] . "='" . $subs_string . "' where local_data_id=" . $cache_array["local_data_id"][$data_template["id"]]);
}
}
}
}
}
}
if (is_array($snmp_query_array)) {
$data_input_field = array_rekey(db_fetch_assoc("select\n\t\t\t\tdata_input_fields.id,\n\t\t\t\tdata_input_fields.type_code\n\t\t\t\tfrom (snmp_query,data_input,data_input_fields)\n\t\t\t\twhere snmp_query.data_input_id=data_input.id\n\t\t\t\tand data_input.id=data_input_fields.data_input_id\n\t\t\t\tand (data_input_fields.type_code='index_type' or data_input_fields.type_code='index_value' or data_input_fields.type_code='output_type')\n\t\t\t\tand snmp_query.id=" . $snmp_query_array["snmp_query_id"]), "type_code", "id");
$snmp_cache_value = db_fetch_cell("select field_value from host_snmp_cache where host_id='{$host_id}' and snmp_query_id='" . $snmp_query_array["snmp_query_id"] . "' and field_name='" . $snmp_query_array["snmp_index_on"] . "' and snmp_index='" . $snmp_query_array["snmp_index"] . "'");
/* save the value to index on (ie. ifindex, ifip, etc) */
db_execute("replace into data_input_data (data_input_field_id,data_template_data_id,t_value,value) values (" . $data_input_field["index_type"] . ",{$data_template_data_id},'','" . $snmp_query_array["snmp_index_on"] . "')");
/* save the actual value (ie. 3, 192.168.1.101, etc) */
db_execute("replace into data_input_data (data_input_field_id,data_template_data_id,t_value,value) values (" . $data_input_field["index_value"] . ",{$data_template_data_id},'','" . addslashes($snmp_cache_value) . "')");
/* set the expected output type (ie. bytes, errors, packets) */
db_execute("replace into data_input_data (data_input_field_id,data_template_data_id,t_value,value) values (" . $data_input_field["output_type"] . ",{$data_template_data_id},'','" . $snmp_query_array["snmp_query_graph_id"] . "')");
/* now that we have put data into the 'data_input_data' table, update the snmp cache for ds's */
update_data_source_data_query_cache($cache_array["local_data_id"][$data_template["id"]]);
}
/* suggested values: data source */
if (isset($suggested_values_array[$graph_template_id]["data_template"][$data_template["id"]])) {
reset($suggested_values_array[$graph_template_id]["data_template"][$data_template["id"]]);
while (list($field_name, $field_value) = each($suggested_values_array[$graph_template_id]["data_template"][$data_template["id"]])) {
db_execute("update data_template_data set {$field_name}='{$field_value}' where local_data_id=" . $cache_array["local_data_id"][$data_template["id"]]);
}
}
/* suggested values: data source item */
if (isset($suggested_values_array[$graph_template_id]["data_template_item"])) {
reset($suggested_values_array[$graph_template_id]["data_template_item"]);
while (list($data_template_item_id, $field_array) = each($suggested_values_array[$graph_template_id]["data_template_item"])) {
while (list($field_name, $field_value) = each($field_array)) {
$data_source_item_id = db_fetch_cell("select id from data_template_rrd where local_data_template_rrd_id={$data_template_item_id} and local_data_id=" . $cache_array["local_data_id"][$data_template["id"]]);
db_execute("update data_template_rrd set {$field_name}='{$field_value}' where id={$data_source_item_id}");
}
}
}
/* suggested values: custom data */
if (isset($suggested_values_array[$graph_template_id]["custom_data"][$data_template["id"]])) {
reset($suggested_values_array[$graph_template_id]["custom_data"][$data_template["id"]]);
while (list($data_input_field_id, $field_value) = each($suggested_values_array[$graph_template_id]["custom_data"][$data_template["id"]])) {
db_execute("replace into data_input_data (data_input_field_id,data_template_data_id,t_value,value) values ({$data_input_field_id},{$data_template_data_id},'','{$field_value}')");
}
}
update_data_source_title_cache($cache_array["local_data_id"][$data_template["id"]]);
}
}
/* connect the dots: graph -> data source(s) */
$template_item_list = db_fetch_assoc("select\n\t\tgraph_templates_item.id,\n\t\tdata_template_rrd.id as data_template_rrd_id,\n\t\tdata_template_rrd.data_template_id\n\t\tfrom (graph_templates_item,data_template_rrd)\n\t\twhere graph_templates_item.task_item_id=data_template_rrd.id\n\t\tand graph_templates_item.graph_template_id={$graph_template_id}\n\t\tand local_graph_id=0\n\t\tand task_item_id>0");
/* loop through each item affected and update column data */
if (sizeof($template_item_list) > 0) {
foreach ($template_item_list as $template_item) {
$local_data_id = $cache_array["local_data_id"][$template_item["data_template_id"]];
$graph_template_item_id = db_fetch_cell("select id from graph_templates_item where local_graph_template_item_id=" . $template_item["id"] . " and local_graph_id=" . $cache_array["local_graph_id"]);
$data_template_rrd_id = db_fetch_cell("select id from data_template_rrd where local_data_template_rrd_id=" . $template_item["data_template_rrd_id"] . " and local_data_id={$local_data_id}");
if (!empty($data_template_rrd_id)) {
db_execute("update graph_templates_item set task_item_id='{$data_template_rrd_id}' where id={$graph_template_item_id}");
}
}
}
/* this will not work until the ds->graph dots are connected */
if (is_array($snmp_query_array)) {
update_graph_data_query_cache($cache_array["local_graph_id"]);
}
return $cache_array;
}
示例13: update_data_source_data_query_cache
function update_data_source_data_query_cache($local_data_id)
{
$host_id = db_fetch_cell("SELECT host_id FROM data_local WHERE id={$local_data_id}");
$field = data_query_field_list(db_fetch_cell("select\n\t\tdata_template_data.id\n\t\tfrom data_template_data\n\t\twhere data_template_data.local_data_id={$local_data_id}"));
if (empty($field)) {
return;
}
$data_query_id = db_fetch_cell("SELECT snmp_query_id FROM snmp_query_graph WHERE id='" . $field["output_type"] . "'");
$index = data_query_index($field["index_type"], $field["index_value"], $host_id, $data_query_id);
if ($data_query_id != "0" && $index != "") {
db_execute("UPDATE data_local SET snmp_query_id='{$data_query_id}',snmp_index='{$index}' WHERE id='{$local_data_id}'");
/* update data source title cache */
update_data_source_title_cache($local_data_id);
}
}
示例14: create_complete_graph_from_template
//.........这里部分代码省略.........
if (sql_column_exists("data_template_data", $suggested_value["field_name"]) &&
(!substr_count($subs_string, "|"))) {
db_execute("update data_template_rrd set " . $suggested_value["field_name"] . "='" . $subs_string . "' where local_data_id=" . $cache_array["local_data_id"]{$data_template["id"]});
}
}
}
}
}
}
if (is_array($snmp_query_array)) {
$data_input_field = array_rekey(db_fetch_assoc("select
data_input_fields.id,
data_input_fields.type_code
from (snmp_query
cross join data_input
cross join data_input_fields)
where snmp_query.data_input_id=data_input.id
and data_input.id=data_input_fields.data_input_id
and (data_input_fields.type_code='index_type' or data_input_fields.type_code='index_value' or data_input_fields.type_code='output_type')
and snmp_query.id=" . $snmp_query_array["snmp_query_id"]), "type_code", "id");
$snmp_cache_value = db_fetch_cell("select field_value from host_snmp_cache where host_id='$host_id' and snmp_query_id='" . $snmp_query_array["snmp_query_id"] . "' and field_name='" . $snmp_query_array["snmp_index_on"] . "' and snmp_index='" . $snmp_query_array["snmp_index"] . "'");
/* save the value to index on (ie. ifindex, ifip, etc) */
db_replace("data_input_data",array("data_input_field_id"=>$data_input_field["index_type"],"data_template_data_id"=>$data_template_data_id,"t_value"=>"","value"=>$snmp_query_array["snmp_index_on"]),array("data_input_field_id","data_template_data_id"),true);
/* save the actual value (ie. 3, 192.168.1.101, etc) */
db_replace("data_input_data",array("data_input_field_id"=>$data_input_field["index_value"],"data_template_data_id"=>$data_template_data_id,"t_value"=>"","value"=>addslashes($snmp_cache_value)),array("data_input_field_id","data_template_data_id"),true);
/* set the expected output type (ie. bytes, errors, packets) */
db_replace("data_input_data",array("data_input_field_id"=>$data_input_field["output_type"],"data_template_data_id"=>$data_template_data_id,"t_value"=>"","value"=>$snmp_query_array["snmp_query_graph_id"]),array("data_input_field_id","data_template_data_id"),true);
/* now that we have put data into the 'data_input_data' table, update the snmp cache for ds's */
update_data_source_data_query_cache($cache_array["local_data_id"]{$data_template["id"]});
}
/* suggested values: data source */
if (isset($suggested_values_array[$graph_template_id]["data_template"]{$data_template["id"]})) {
reset($suggested_values_array[$graph_template_id]["data_template"]{$data_template["id"]});
while (list($field_name, $field_value) = each($suggested_values_array[$graph_template_id]["data_template"]{$data_template["id"]})) {
db_execute("update data_template_data set $field_name='$field_value' where local_data_id=" . $cache_array["local_data_id"]{$data_template["id"]});
}
}
/* suggested values: data source item */
if (isset($suggested_values_array[$graph_template_id]["data_template_item"])) {
reset($suggested_values_array[$graph_template_id]["data_template_item"]);
while (list($data_template_item_id, $field_array) = each($suggested_values_array[$graph_template_id]["data_template_item"])) {
while (list($field_name, $field_value) = each($field_array)) {
$data_source_item_id = db_fetch_cell("select id from data_template_rrd where local_data_template_rrd_id=$data_template_item_id and local_data_id=" . $cache_array["local_data_id"]{$data_template["id"]});
db_execute("update data_template_rrd set $field_name='$field_value' where id=$data_source_item_id");
}
}
}
/* suggested values: custom data */
if (isset($suggested_values_array[$graph_template_id]["custom_data"]{$data_template["id"]})) {
reset($suggested_values_array[$graph_template_id]["custom_data"]{$data_template["id"]});
while (list($data_input_field_id, $field_value) = each($suggested_values_array[$graph_template_id]["custom_data"]{$data_template["id"]})) {
db_replace("data_input_data",array("data_input_field_id"=>$data_input_field_id,"data_template_data_id"=>$data_template_data_id,"t_value"=>"","value"=>$field_value),array("data_input_field_id","data_template_data_id"),true);
}
}
update_data_source_title_cache($cache_array["local_data_id"]{$data_template["id"]});
}
}
/* connect the dots: graph -> data source(s) */
$template_item_list = db_fetch_assoc("select
graph_templates_item.id,
data_template_rrd.id as data_template_rrd_id,
data_template_rrd.data_template_id
from (graph_templates_item cross join data_template_rrd)
where graph_templates_item.task_item_id=data_template_rrd.id
and graph_templates_item.graph_template_id=$graph_template_id
and local_graph_id=0
and task_item_id>0");
/* loop through each item affected and update column data */
if (sizeof($template_item_list) > 0) {
foreach ($template_item_list as $template_item) {
$local_data_id = $cache_array["local_data_id"]{$template_item["data_template_id"]};
$graph_template_item_id = db_fetch_cell("select id from graph_templates_item where local_graph_template_item_id=" . $template_item["id"] . " and local_graph_id=" . $cache_array["local_graph_id"]);
$data_template_rrd_id = db_fetch_cell("select id from data_template_rrd where local_data_template_rrd_id=" . $template_item["data_template_rrd_id"] . " and local_data_id=$local_data_id");
if (!empty($data_template_rrd_id)) {
db_execute("update graph_templates_item set task_item_id='$data_template_rrd_id' where id=$graph_template_item_id");
}
}
}
/* this will not work until the ds->graph dots are connected */
if (is_array($snmp_query_array)) {
update_graph_data_query_cache($cache_array["local_graph_id"]);
}
return $cache_array;
}
示例15: form_actions
function form_actions()
{
global $ds_actions;
/* ================= input validation ================= */
input_validate_input_regex(get_request_var_post('drp_action'), '^([a-zA-Z0-9_]+)$');
/* ==================================================== */
/* if we are to save this form, instead of display it */
if (isset($_POST['selected_items'])) {
$selected_items = unserialize(stripslashes($_POST['selected_items']));
if ($_POST['drp_action'] == '1') {
/* delete */
if (!isset($_POST['delete_type'])) {
$_POST['delete_type'] = 1;
}
switch ($_POST['delete_type']) {
case '2':
/* delete all graph items tied to this data source */
$data_template_rrds = array_rekey(db_fetch_assoc('SELECT id FROM data_template_rrd WHERE ' . array_to_sql_or($selected_items, 'local_data_id')), 'id', 'id');
/* loop through each data source item */
if (sizeof($data_template_rrds) > 0) {
db_execute('DELETE FROM graph_templates_item WHERE task_item_id IN (' . implode(',', $data_template_rrds) . ') and local_graph_id > 0');
}
api_plugin_hook_function('graph_items_remove', $data_template_rrds);
break;
case '3':
/* delete all graphs tied to this data source */
$graphs = array_rekey(db_fetch_assoc('SELECT
graph_templates_graph.local_graph_id
FROM (data_template_rrd,graph_templates_item,graph_templates_graph)
WHERE graph_templates_item.task_item_id=data_template_rrd.id
AND graph_templates_item.local_graph_id=graph_templates_graph.local_graph_id
AND ' . array_to_sql_or($selected_items, 'data_template_rrd.local_data_id') . '
AND graph_templates_graph.local_graph_id > 0
GROUP BY graph_templates_graph.local_graph_id'), 'local_graph_id', 'local_graph_id');
if (sizeof($graphs) > 0) {
api_graph_remove_multi($graphs);
}
api_plugin_hook_function('graphs_remove', $graphs);
break;
}
for ($i = 0; $i < count($selected_items); $i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
/* ==================================================== */
}
api_data_source_remove_multi($selected_items);
api_plugin_hook_function('data_source_remove', $selected_items);
} elseif ($_POST['drp_action'] == '2') {
/* change graph template */
for ($i = 0; $i < count($selected_items); $i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
input_validate_input_number(get_request_var_post('data_template_id'));
/* ==================================================== */
change_data_template($selected_items[$i], $_POST['data_template_id']);
}
} elseif ($_POST['drp_action'] == '3') {
/* change host */
for ($i = 0; $i < count($selected_items); $i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
input_validate_input_number(get_request_var_post('host_id'));
/* ==================================================== */
db_execute_prepared('UPDATE data_local SET host_id = ? WHERE id = ?', array($_POST['host_id'], $selected_items[$i]));
push_out_host($_POST['host_id'], $selected_items[$i]);
update_data_source_title_cache($selected_items[$i]);
}
} elseif ($_POST['drp_action'] == '4') {
/* duplicate */
for ($i = 0; $i < count($selected_items); $i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
/* ==================================================== */
duplicate_data_source($selected_items[$i], 0, $_POST['title_format']);
}
} elseif ($_POST['drp_action'] == '5') {
/* data source -> data template */
for ($i = 0; $i < count($selected_items); $i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
/* ==================================================== */
data_source_to_data_template($selected_items[$i], $_POST['title_format']);
}
} elseif ($_POST['drp_action'] == '6') {
/* data source enable */
for ($i = 0; $i < count($selected_items); $i++) {
api_data_source_enable($selected_items[$i]);
}
} elseif ($_POST['drp_action'] == '7') {
/* data source disable */
for ($i = 0; $i < count($selected_items); $i++) {
api_data_source_disable($selected_items[$i]);
}
} elseif ($_POST['drp_action'] == '8') {
/* reapply suggested data source naming */
for ($i = 0; $i < count($selected_items); $i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
/* ==================================================== */
api_reapply_suggested_data_source_title($selected_items[$i]);
//.........这里部分代码省略.........