• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP update_poller_cache函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: update_poller_cache_from_query

function update_poller_cache_from_query($host_id, $data_query_id) {
	require_once(CACTI_BASE_PATH . "/include/data_source/data_source_constants.php");

	$data_sources = db_fetch_assoc("select
		data_source.id
		from data_source,data_source_field
		where data_source.id=data_source_field.data_source_id
		and data_source.data_input_type = " . DATA_INPUT_TYPE_DATA_QUERY . "
		and data_source_field.name = 'data_query_id'");

	if (sizeof($data_sources) > 0) {
		foreach ($data_sources as $data_source) {
			update_poller_cache($data_source["id"]);
		}
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:16,代码来源:poller.php


示例2: push_out_device

function push_out_device($device_id, $local_data_id = 0, $data_template_id = 0) {
	/* ok here's the deal: first we need to find every data source that uses this device.
	then we go through each of those data sources, finding each one using a data input method
	with "special fields". if we find one, fill it will the data here from this device */
	/* setup the poller items array */
	$poller_items   = array();
	$local_data_ids = array();
	$devices          = array();
	$sql_where      = "";

	/* setup the sql where, and if using a device, get it's device information */
	if ($device_id != 0) {
		/* get all information about this device so we can write it to the data source */
		$devices[$device_id] = db_fetch_row("select * from device where id=$device_id");

		$sql_where .= " AND data_local.device_id=$device_id";
	}

	/* sql where fom local_data_id */
	if ($local_data_id != 0) {
		$sql_where .= " AND data_local.id=$local_data_id";
	}

	/* sql where fom data_template_id */
	if ($data_template_id != 0) {
		$sql_where .= " AND data_template_data.data_template_id=$data_template_id";
	}

	$data_sources = db_fetch_assoc("SELECT
		data_template_data.id,
		data_template_data.data_input_id,
		data_template_data.local_data_id,
		data_template_data.local_data_template_data_id,
		data_local.device_id
		FROM (data_local, data_template_data)
		WHERE data_local.id=data_template_data.local_data_id
		AND data_template_data.data_input_id>0
		$sql_where");

	/* loop through each matching data source */
	if (sizeof($data_sources) > 0) {
	foreach ($data_sources as $data_source) {
		/* set the device information */
		if (!isset($devices[$data_source["device_id"]])) {
			$devices[$data_source["device_id"]] = db_fetch_row("select * from device where id=" . $data_source["device_id"]);
		}
		$device = $devices[$data_source["device_id"]];

		/* get field information from the data template */
		if (!isset($template_fields{$data_source["local_data_template_data_id"]})) {
			$template_fields{$data_source["local_data_template_data_id"]} = db_fetch_assoc("select
				data_input_data.value,
				data_input_data.t_value,
				data_input_fields.id,
				data_input_fields.type_code
				from data_input_fields left join data_input_data
				on (data_input_fields.id=data_input_data.data_input_field_id and data_input_data.data_template_data_id=" . $data_source["local_data_template_data_id"] . ")
				where data_input_fields.data_input_id=" . $data_source["data_input_id"] . "
				and (data_input_data.t_value='' or data_input_data.t_value is null)
				and data_input_fields.input_output='in'");
		}

		reset($template_fields{$data_source["local_data_template_data_id"]});

		/* loop through each field contained in the data template and push out a device value if:
		 - the field is a valid "device field"
		 - the value of the field is empty
		 - the field is set to 'templated' */
		if (sizeof($template_fields{$data_source["local_data_template_data_id"]})) {
		foreach ($template_fields{$data_source["local_data_template_data_id"]} as $template_field) {
			if ((preg_match('/^' . VALID_HOST_FIELDS . '$/i', $template_field["type_code"])) && ($template_field["value"] == "") && ($template_field["t_value"] == "")) {
				db_execute("replace into data_input_data (data_input_field_id,data_template_data_id,value) values (" . $template_field["id"] . "," . $data_source["id"] . ",'" . $device{$template_field["type_code"]} . "')");
			}
		}
		}

		/* flag an update to the poller cache as well */
		$local_data_ids[] = $data_source["local_data_id"];
		$poller_items     = array_merge($poller_items, update_poller_cache($data_source["local_data_id"]));
	}
	}

	if (sizeof($local_data_ids)) {
		poller_update_poller_cache_from_buffer($local_data_ids, $poller_items);
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:86,代码来源:utility.php


示例3: push_out_host

function push_out_host($host_id, $local_data_id = 0, $data_template_id = 0) {
	/* ok here's the deal: first we need to find every data source that uses this host.
	then we go through each of those data sources, finding each one using a data input method
	with "special fields". if we find one, fill it will the data here from this host */

	if (!empty($data_template_id)) {
		$hosts = db_fetch_assoc("select host_id from data_local where data_template_id=$data_template_id group by host_id");

		if (sizeof($hosts) > 0) {
		foreach ($hosts as $host) {
			push_out_host($host["host_id"]);
		}
		}
	}

	if (empty($host_id)) { return 0; }

	/* get all information about this host so we can write it to the data source */
	$host = db_fetch_row("select * from host where id=$host_id");

	$data_sources = db_fetch_assoc("select
		data_template_data.id,
		data_template_data.data_input_id,
		data_template_data.local_data_id,
		data_template_data.local_data_template_data_id
		from data_local,data_template_data
		where " . (empty($local_data_id) ? "data_local.host_id=$host_id" : "data_local.id=$local_data_id") . "
		and data_local.id=data_template_data.local_data_id
		and data_template_data.data_input_id>0");

	/* loop through each matching data source */
	if (sizeof($data_sources) > 0) {
	foreach ($data_sources as $data_source) {
		/* get field information from the data template */
		if (!isset($template_fields{$data_source["local_data_template_data_id"]})) {
			$template_fields{$data_source["local_data_template_data_id"]} = db_fetch_assoc("select
				data_input_data.value,
				data_input_data.t_value,
				data_input_fields.id,
				data_input_fields.type_code
				from data_input_fields left join data_input_data
				on (data_input_fields.id=data_input_data.data_input_field_id and data_input_data.data_template_data_id=" . $data_source["local_data_template_data_id"] . ")
				where data_input_fields.data_input_id=" . $data_source["data_input_id"] . "
				and (data_input_data.t_value='' or data_input_data.t_value is null)
				and data_input_fields.input_output='in'");
		}

		reset($template_fields{$data_source["local_data_template_data_id"]});

		/* loop through each field contained in the data template and push out a host value if:
		 - the field is a valid "host field"
		 - the value of the field is empty
		 - the field is set to 'templated' */
		if (sizeof($template_fields{$data_source["local_data_template_data_id"]})) {
			foreach ($template_fields{$data_source["local_data_template_data_id"]} as $template_field) {
				if ((eregi('^' . VALID_HOST_FIELDS . '$', $template_field["type_code"])) && ($template_field["value"] == "") && ($template_field["t_value"] == "")) {
					db_execute("replace into data_input_data (data_input_field_id,data_template_data_id,value) values (" . $template_field["id"] . "," . $data_source["id"] . ",'" . $host{$template_field["type_code"]} . "')");
				}
			}
		}

		/* make sure to update the poller cache as well */
		update_poller_cache($data_source["local_data_id"], false);
	}
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:66,代码来源:utility.php


示例4: api_data_source_enable

function api_data_source_enable($local_data_id)
{
    db_execute("UPDATE data_template_data SET active='on' WHERE local_data_id={$local_data_id}");
    update_poller_cache($local_data_id, false);
}
开发者ID:songchin,项目名称:Cacti,代码行数:5,代码来源:api_data_source.php


示例5: sizeof

$current_ds = 1;
$total_ds = sizeof($poller_data);
/* setting local_data_ids to an empty array saves time during updates */
$local_data_ids = array();
$poller_items = array();
/* issue warnings and start message if applicable */
print "WARNING: Do not interrupt this script.  Rebuilding the Poller Cache can take quite some time\n";
debug("There are '" . sizeof($poller_data) . "' data source elements to update.");
/* start rebuilding the poller cache */
if (sizeof($poller_data) > 0) {
    foreach ($poller_data as $data) {
        if (!$debug) {
            print ".";
        }
        $local_data_ids[] = $data["id"];
        $poller_items = array_merge($poller_items, update_poller_cache($data["id"]));
        debug("Data Source Item '{$current_ds}' of '{$total_ds}' updated");
        $current_ds++;
    }
    if (sizeof($local_data_ids)) {
        poller_update_poller_cache_from_buffer($local_data_ids, $poller_items);
    }
}
if (!$debug) {
    print "\n";
}
/* poller cache rebuilt, restore runtime parameters */
ini_set("max_execution_time", $max_execution);
/*	display_help - displays the usage of the function */
function display_help()
{
开发者ID:MrWnn,项目名称:cacti,代码行数:31,代码来源:rebuild_poller_cache.php


示例6: update_host_disabled

function update_host_disabled($host_id, $disabled)
{
    db_execute("UPDATE host SET disabled = '{$disabled}' WHERE id = '{$host_id}'");
    /* update poller cache */
    if ($disabled === "") {
        $data_sources = db_fetch_assoc("SELECT id FROM data_local WHERE host_id = '{$host_id}'");
        $poller_items = array();
        include dirname(__FILE__) . "/include/global.php";
        include_once $config["base_path"] . "/lib/utility.php";
        if (sizeof($data_sources) > 0) {
            foreach ($data_sources as $data_source) {
                $local_data_ids[] = $data_source["id"];
                $poller_items = array_merge($poller_items, update_poller_cache($data_source["id"]));
            }
        }
        poller_update_poller_cache_from_buffer($local_data_ids, $poller_items);
    } else {
        db_execute("DELETE FROM poller_item WHERE host_id = '{$host_id}'");
        db_execute("DELETE FROM poller_reindex WHERE host_id = '{$host_id}'");
    }
}
开发者ID:resmon,项目名称:resmon-cacti,代码行数:21,代码来源:poller.php


示例7: db_fetch_assoc

/* get the data_local Id's for the poller cache */
$poller_data = db_fetch_assoc("select id from data_local");

/* initialize some variables */
$current_ds = 1;
$total_ds = sizeof($poller_data);

/* issue warnings and start message if applicable */
print "WARNING: Do not interrupt this script.  Rebuilding the Poller Cache can take quite some time\n";
debug("There are '" . sizeof($poller_data) . "' data source elements to update.");

/* start rebuilding the poller cache */
if (sizeof($poller_data) > 0) {
	foreach ($poller_data as $data) {
		if (!$debug) print ".";
		update_poller_cache($data["id"], true);
		debug("Data Source Item '$current_ds' of '$total_ds' updated");
		$current_ds++;
	}
}

/* poller cache rebuilt, restore runtime parameters */
ini_set("max_execution_time", $max_execution);
ini_set("memory_limit", $max_memory);

/*	display_help - displays the usage of the function */
function display_help () {
	print "Cacti Rebuild Poller Cache Script 1.0, Copyright 2005 - The Cacti Group\n\n";
	print "usage: rebuild_poller_cache.php [-d] [-h] [--help] [-v] [--version]\n\n";
	print "-d            - Display verbose output during execution\n";
	print "-v --version  - Display this help message\n";
开发者ID:songchin,项目名称:Cacti,代码行数:31,代码来源:rebuild_poller_cache.php


示例8: form_save


//.........这里部分代码省略.........
        $save1["host_id"] = $_POST["host_id"];
        $save2["id"] = $_POST["data_template_data_id"];
        $save2["local_data_template_data_id"] = $_POST["local_data_template_data_id"];
        $save2["data_template_id"] = $_POST["data_template_id"];
        $save2["data_input_id"] = form_input_validate($_POST["data_input_id"], "data_input_id", "", true, 3);
        $save2["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
        $save2["data_source_path"] = form_input_validate($_POST["data_source_path"], "data_source_path", "", true, 3);
        $save2["active"] = form_input_validate(isset($_POST["active"]) ? $_POST["active"] : "", "active", "", true, 3);
        $save2["rrd_step"] = form_input_validate($_POST["rrd_step"], "rrd_step", "^[0-9]+\$", false, 3);
        if (!is_error_message()) {
            $local_data_id = sql_save($save1, "data_local");
            $save2["local_data_id"] = $local_data_id;
            $data_template_data_id = sql_save($save2, "data_template_data");
            if ($data_template_data_id) {
                raise_message(1);
            } else {
                raise_message(2);
            }
        }
        if (!is_error_message()) {
            /* if this is a new data source and a template has been selected, skip item creation this time
            			otherwise it throws off the templatate creation because of the NULL data */
            if (!empty($_POST["local_data_id"]) || empty($_POST["data_template_id"])) {
                /* if no template was set before the save, there will be only one data source item to save;
                			otherwise there might be >1 */
                if (empty($_POST["_data_template_id"])) {
                    $rrds[0]["id"] = $_POST["current_rrd"];
                } else {
                    $rrds = db_fetch_assoc("select id from data_template_rrd where local_data_id=" . $_POST["local_data_id"]);
                }
                if (sizeof($rrds) > 0) {
                    foreach ($rrds as $rrd) {
                        if (empty($_POST["_data_template_id"])) {
                            $name_modifier = "";
                        } else {
                            $name_modifier = "_" . $rrd["id"];
                        }
                        $save3["id"] = $rrd["id"];
                        $save3["local_data_id"] = $local_data_id;
                        $save3["local_data_template_rrd_id"] = db_fetch_cell("select local_data_template_rrd_id from data_template_rrd where id=" . $rrd["id"]);
                        $save3["data_template_id"] = $_POST["data_template_id"];
                        $save3["rrd_maximum"] = form_input_validate($_POST["rrd_maximum{$name_modifier}"], "rrd_maximum{$name_modifier}", "^-?[0-9]+\$", false, 3);
                        $save3["rrd_minimum"] = form_input_validate($_POST["rrd_minimum{$name_modifier}"], "rrd_minimum{$name_modifier}", "^-?[0-9]+\$", false, 3);
                        $save3["rrd_heartbeat"] = form_input_validate($_POST["rrd_heartbeat{$name_modifier}"], "rrd_heartbeat{$name_modifier}", "^[0-9]+\$", false, 3);
                        $save3["data_source_type_id"] = $_POST["data_source_type_id{$name_modifier}"];
                        $save3["data_source_name"] = form_input_validate($_POST["data_source_name{$name_modifier}"], "data_source_name{$name_modifier}", "^[a-zA-Z0-9_-]{1,19}\$", false, 3);
                        $save3["data_input_field_id"] = form_input_validate(isset($_POST["data_input_field_id{$name_modifier}"]) ? $_POST["data_input_field_id{$name_modifier}"] : "0", "data_input_field_id{$name_modifier}", "", true, 3);
                        $data_template_rrd_id = sql_save($save3, "data_template_rrd");
                        if ($data_template_rrd_id) {
                            raise_message(1);
                        } else {
                            raise_message(2);
                        }
                    }
                }
            }
        }
        if (!is_error_message()) {
            if (!empty($_POST["rra_id"])) {
                /* save entries in 'selected rras' field */
                db_execute("delete from data_template_data_rra where data_template_data_id={$data_template_data_id}");
                for ($i = 0; $i < count($_POST["rra_id"]); $i++) {
                    /* ================= input validation ================= */
                    input_validate_input_number($_POST["rra_id"][$i]);
                    /* ==================================================== */
                    db_execute("insert into data_template_data_rra (rra_id,data_template_data_id)\n\t\t\t\t\t\tvalues (" . $_POST["rra_id"][$i] . ",{$data_template_data_id})");
                }
            }
            if ($_POST["data_template_id"] != $_POST["_data_template_id"]) {
                /* update all necessary template information */
                change_data_template($local_data_id, $_POST["data_template_id"]);
            } elseif (!empty($_POST["data_template_id"])) {
                update_data_source_data_query_cache($local_data_id);
            }
            if ($_POST["host_id"] != $_POST["_host_id"]) {
                /* push out all necessary host information */
                push_out_host($_POST["host_id"], $local_data_id);
                /* reset current host for display purposes */
                $_SESSION["sess_data_source_current_host_id"] = $_POST["host_id"];
            }
            /* if no data source path has been entered, generate one */
            if (empty($_POST["data_source_path"])) {
                generate_data_source_path($local_data_id);
            }
            /* update the title cache */
            update_data_source_title_cache($local_data_id);
        }
    }
    /* update the poller cache last to make sure everything is fresh */
    if (!is_error_message() && !empty($local_data_id)) {
        update_poller_cache($local_data_id, false);
    }
    if (isset($_POST["save_component_data_source_new"]) && empty($_POST["data_template_id"])) {
        header("Location: data_sources.php?action=ds_edit&host_id=" . $_POST["host_id"] . "&new=1");
    } elseif (is_error_message() || $_POST["data_template_id"] != $_POST["_data_template_id"] || $_POST["data_input_id"] != $_POST["_data_input_id"] || $_POST["host_id"] != $_POST["_host_id"]) {
        header("Location: data_sources.php?action=ds_edit&id=" . (empty($local_data_id) ? $_POST["local_data_id"] : $local_data_id) . "&host_id=" . $_POST["host_id"] . "&view_rrd=" . (isset($_POST["current_rrd"]) ? $_POST["current_rrd"] : "0"));
    } else {
        header("Location: data_sources.php");
    }
}
开发者ID:BackupTheBerlios,项目名称:odp-svn,代码行数:101,代码来源:data_sources.php


示例9: form_actions

function form_actions()
{
    global $colors, $device_actions, $fields_host_edit;
    /* 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"] == "2") {
            /* Enable Selected Devices */
            for ($i = 0; $i < count($selected_items); $i++) {
                db_execute("update host set disabled='' where id='" . $selected_items[$i] . "'");
                /* update poller cache */
                $data_sources = db_fetch_assoc("select id from data_local where host_id='" . $selected_items[$i] . "'");
                if (sizeof($data_sources) > 0) {
                    foreach ($data_sources as $data_source) {
                        update_poller_cache($data_source["id"], false);
                    }
                }
            }
        } elseif ($_POST["drp_action"] == "3") {
            /* Disable Selected Devices */
            for ($i = 0; $i < count($selected_items); $i++) {
                db_execute("update host set disabled='on' where id='" . $selected_items[$i] . "'");
                /* update poller cache */
                db_execute("delete from poller_item where host_id='" . $selected_items[$i] . "'");
                db_execute("delete from poller_reindex where host_id='" . $selected_items[$i] . "'");
            }
        } elseif ($_POST["drp_action"] == "4") {
            /* change snmp options */
            for ($i = 0; $i < count($selected_items); $i++) {
                reset($fields_host_edit);
                while (list($field_name, $field_array) = each($fields_host_edit)) {
                    if (isset($_POST["t_{$field_name}"])) {
                        db_execute("update host set {$field_name} = '" . $_POST[$field_name] . "' where id='" . $selected_items[$i] . "'");
                    }
                }
                push_out_host($selected_items[$i]);
            }
        } elseif ($_POST["drp_action"] == "6") {
            /* change poller */
            for ($i = 0; $i < count($selected_items); $i++) {
                reset($fields_host_edit);
                while (list($field_name, $field_array) = each($fields_host_edit)) {
                    if (isset($_POST["t_{$field_name}"])) {
                        db_execute("update host set {$field_name} = '" . $_POST[$field_name] . "' where id='" . $selected_items[$i] . "'");
                    }
                }
                push_out_host($selected_items[$i]);
            }
        } elseif ($_POST["drp_action"] == "7") {
            /* change availability options */
            for ($i = 0; $i < count($selected_items); $i++) {
                reset($fields_host_edit);
                while (list($field_name, $field_array) = each($fields_host_edit)) {
                    if (isset($_POST["t_{$field_name}"])) {
                        db_execute("update host set {$field_name} = '" . $_POST[$field_name] . "' where id='" . $selected_items[$i] . "'");
                    }
                }
                push_out_host($selected_items[$i]);
            }
        } elseif ($_POST["drp_action"] == "5") {
            /* Clear Statisitics for Selected Devices */
            for ($i = 0; $i < count($selected_items); $i++) {
                db_execute("update host set min_time = '9.99999', max_time = '0', cur_time = '0',\tavg_time = '0',\n\t\t\t\t\t\ttotal_polls = '0', failed_polls = '0',\tavailability = '100.00'\n\t\t\t\t\t\twhere id = '" . $selected_items[$i] . "'");
            }
        } elseif ($_POST["drp_action"] == "1") {
            /* delete */
            for ($i = 0; $i < count($selected_items); $i++) {
                if (!isset($_POST["delete_type"])) {
                    $_POST["delete_type"] = 2;
                }
                switch ($_POST["delete_type"]) {
                    case '1':
                        /* leave graphs and data_sources in place, but disable the data sources */
                        $data_sources = db_fetch_assoc("select id from data_source where " . array_to_sql_or($selected_items, "host_id"));
                        if (sizeof($data_sources) > 0) {
                            foreach ($data_sources as $data_source) {
                                api_data_source_disable($data_source["id"]);
                            }
                        }
                        break;
                    case '2':
                        /* delete graphs/data sources tied to this device */
                        $data_sources = db_fetch_assoc("select id from data_source where " . array_to_sql_or($selected_items, "host_id"));
                        if (sizeof($data_sources) > 0) {
                            foreach ($data_sources as $data_source) {
                                api_data_source_remove($data_source["id"]);
                            }
                        }
                        $graphs = db_fetch_assoc("select id from graph where " . array_to_sql_or($selected_items, "host_id"));
                        if (sizeof($graphs) > 0) {
                            foreach ($graphs as $graph) {
                                api_graph_remove($graph["id"]);
                            }
                        }
                        break;
                }
                api_device_remove($selected_items[$i]);
            }
        }
        header("Location: devices.php");
//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:devices.php


示例10: form_save


//.........这里部分代码省略.........
        $save2['id'] = $_POST['data_template_data_id'];
        $save2['local_data_template_data_id'] = $_POST['local_data_template_data_id'];
        $save2['data_template_id'] = $_POST['data_template_id'];
        $save2['data_input_id'] = form_input_validate($_POST['data_input_id'], 'data_input_id', '', true, 3);
        $save2['name'] = form_input_validate($_POST['name'], 'name', '', false, 3);
        $save2['data_source_path'] = form_input_validate($_POST['data_source_path'], 'data_source_path', '', true, 3);
        $save2['active'] = form_input_validate(isset($_POST['active']) ? $_POST['active'] : '', 'active', '', true, 3);
        $save2['rrd_step'] = form_input_validate($_POST['rrd_step'], 'rrd_step', '^[0-9]+$', false, 3);
        if (!is_error_message()) {
            $local_data_id = sql_save($save1, 'data_local');
            $save2['local_data_id'] = $local_data_id;
            $data_template_data_id = sql_save($save2, 'data_template_data');
            if ($data_template_data_id) {
                raise_message(1);
            } else {
                raise_message(2);
            }
        }
        if (!is_error_message()) {
            /* if this is a new data source and a template has been selected, skip item creation this time
            			otherwise it throws off the templatate creation because of the NULL data */
            if (!empty($_POST['local_data_id']) || empty($_POST['data_template_id'])) {
                /* if no template was set before the save, there will be only one data source item to save;
                			otherwise there might be >1 */
                if (empty($_POST['_data_template_id'])) {
                    $rrds[0]['id'] = $_POST['current_rrd'];
                } else {
                    $rrds = db_fetch_assoc_prepared('SELECT id FROM data_template_rrd WHERE local_data_id = ?', array($_POST['local_data_id']));
                }
                if (sizeof($rrds) > 0) {
                    foreach ($rrds as $rrd) {
                        if (empty($_POST['_data_template_id'])) {
                            $name_modifier = '';
                        } else {
                            $name_modifier = '_' . $rrd['id'];
                        }
                        $save3['id'] = $rrd['id'];
                        $save3['local_data_id'] = $local_data_id;
                        $save3['local_data_template_rrd_id'] = db_fetch_cell_prepared('SELECT local_data_template_rrd_id FROM data_template_rrd WHERE id = ?', array($rrd['id']));
                        $save3['data_template_id'] = $_POST['data_template_id'];
                        $save3['rrd_maximum'] = form_input_validate($_POST["rrd_maximum{$name_modifier}"], "rrd_maximum{$name_modifier}", "^(-?([0-9]+(\\.[0-9]*)?|[0-9]*\\.[0-9]+)([eE][+\\-]?[0-9]+)?)|U\$", false, 3);
                        $save3['rrd_minimum'] = form_input_validate($_POST["rrd_minimum{$name_modifier}"], "rrd_minimum{$name_modifier}", "^(-?([0-9]+(\\.[0-9]*)?|[0-9]*\\.[0-9]+)([eE][+\\-]?[0-9]+)?)|U\$", false, 3);
                        $save3['rrd_heartbeat'] = form_input_validate($_POST["rrd_heartbeat{$name_modifier}"], "rrd_heartbeat{$name_modifier}", '^[0-9]+$', false, 3);
                        $save3['data_source_type_id'] = $_POST["data_source_type_id{$name_modifier}"];
                        $save3['data_source_name'] = form_input_validate($_POST["data_source_name{$name_modifier}"], "data_source_name{$name_modifier}", '^[a-zA-Z0-9_-]{1,19}$', false, 3);
                        $save3['data_input_field_id'] = form_input_validate(isset($_POST["data_input_field_id{$name_modifier}"]) ? $_POST["data_input_field_id{$name_modifier}"] : '0', "data_input_field_id{$name_modifier}", '', true, 3);
                        $data_template_rrd_id = sql_save($save3, 'data_template_rrd');
                        if ($data_template_rrd_id) {
                            raise_message(1);
                        } else {
                            raise_message(2);
                        }
                    }
                }
            }
        }
        if (!is_error_message()) {
            if (!empty($_POST['rra_id'])) {
                /* save entries in 'selected rras' field */
                db_execute_prepared('DELETE FROM data_template_data_rra WHERE data_template_data_id = ?', array($data_template_data_id));
                for ($i = 0; $i < count($_POST['rra_id']); $i++) {
                    /* ================= input validation ================= */
                    input_validate_input_number($_POST['rra_id'][$i]);
                    /* ==================================================== */
                    db_execute_prepared('INSERT INTO data_template_data_rra (rra_id, data_template_data_id)
						VALUES (?, ?)', array($_POST['rra_id'][$i], $data_template_data_id));
                }
            }
            if ($_POST['data_template_id'] != $_POST['_data_template_id']) {
                /* update all necessary template information */
                change_data_template($local_data_id, $_POST['data_template_id']);
            } elseif (!empty($_POST['data_template_id'])) {
                update_data_source_data_query_cache($local_data_id);
            }
            if ($_POST['host_id'] != $_POST['_host_id']) {
                /* push out all necessary host information */
                push_out_host($_POST['host_id'], $local_data_id);
                /* reset current host for display purposes */
                $_SESSION['sess_data_source_current_host_id'] = $_POST['host_id'];
            }
            /* if no data source path has been entered, generate one */
            if (empty($_POST['data_source_path'])) {
                generate_data_source_path($local_data_id);
            }
            /* update the title cache */
            update_data_source_title_cache($local_data_id);
        }
    }
    /* update the poller cache last to make sure everything is fresh */
    if (!is_error_message() && !empty($local_data_id)) {
        update_poller_cache($local_data_id, true);
    }
    if (isset($_POST['save_component_data_source_new']) && empty($_POST['data_template_id'])) {
        header('Location: data_sources.php?action=ds_edit&host_id=' . $_POST['host_id'] . '&new=1');
    } elseif (is_error_message() || $_POST['data_template_id'] != $_POST['_data_template_id'] || $_POST['data_input_id'] != $_POST['_data_input_id'] || $_POST['host_id'] != $_POST['_host_id']) {
        header('Location: data_sources.php?action=ds_edit&id=' . (empty($local_data_id) ? $_POST['local_data_id'] : $local_data_id) . '&host_id=' . $_POST['host_id'] . '&view_rrd=' . (isset($_POST['current_rrd']) ? $_POST['current_rrd'] : '0'));
    } else {
        header('Location: data_sources.php');
    }
}
开发者ID:MrWnn,项目名称:cacti,代码行数:101,代码来源:data_sources.php


示例11: api_data_source_enable

function api_data_source_enable($data_source_id) {
	/* sanity checks */
	validate_id_die($data_source_id, "data_source_id");

	db_execute("UPDATE data_source SET active = 1 WHERE id = " . sql_sanitize($data_source_id));
	update_poller_cache($data_source_id, false);
}
开发者ID:songchin,项目名称:Cacti,代码行数:7,代码来源:data_source_update.php


示例12: push_out_host

/** for a given data template, update all input data and the poller cache
 * @param int $host_id - id of host, if any
 * @param int $local_data_id - id of a single data source, if any
 * @param int $data_template_id - id of data template
 * works on table data_input_data and poller cache
 */
function push_out_host($host_id, $local_data_id = 0, $data_template_id = 0)
{
    /* ok here's the deal: first we need to find every data source that uses this host.
    	then we go through each of those data sources, finding each one using a data input method
    	with "special fields". if we find one, fill it will the data here FROM this host */
    /* setup the poller items array */
    $poller_items = array();
    $local_data_ids = array();
    $hosts = array();
    $sql_where = "";
    /* setup the sql where, and if using a host, get it's host information */
    if ($host_id != 0) {
        /* get all information about this host so we can write it to the data source */
        $hosts[$host_id] = db_fetch_row("SELECT id AS host_id, host.* FROM host WHERE id={$host_id}");
        $sql_where .= " AND data_local.host_id={$host_id}";
    }
    /* sql WHERE for local_data_id */
    if ($local_data_id != 0) {
        $sql_where .= " AND data_local.id={$local_data_id}";
    }
    /* sql WHERE for data_template_id */
    if ($data_template_id != 0) {
        $sql_where .= " AND data_template_data.data_template_id={$data_template_id}";
    }
    $data_sources = db_fetch_assoc("SELECT\n\t\tdata_template_data.id,\n\t\tdata_template_data.data_input_id,\n\t\tdata_template_data.local_data_id,\n\t\tdata_template_data.local_data_template_data_id,\n\t\tdata_local.host_id\n\t\tFROM (data_local, data_template_data)\n\t\tWHERE data_local.id=data_template_data.local_data_id\n\t\tAND data_template_data.data_input_id>0\n\t\t{$sql_where}");
    /* loop through each matching data source */
    if (sizeof($data_sources) > 0) {
        foreach ($data_sources as $data_source) {
            /* set the host information */
            if (!isset($hosts[$data_source["host_id"]])) {
                $hosts[$data_source["host_id"]] = db_fetch_row("SELECT * FROM host WHERE id=" . $data_source["host_id"]);
            }
            $host = $hosts[$data_source["host_id"]];
            /* get field information FROM the data template */
            if (!isset($template_fields[$data_source["local_data_template_data_id"]])) {
                $template_fields[$data_source["local_data_template_data_id"]] = db_fetch_assoc("SELECT\n\t\t\t\tdata_input_data.value,\n\t\t\t\tdata_input_data.t_value,\n\t\t\t\tdata_input_fields.id,\n\t\t\t\tdata_input_fields.type_code\n                FROM data_input_fields \n                LEFT JOIN data_input_data\n\t\t\t\tON (data_input_fields.id=data_input_data.data_input_field_id AND data_input_data.data_template_data_id=" . $data_source["local_data_template_data_id"] . ")\n\t\t\t\tWHERE data_input_fields.data_input_id=" . $data_source["data_input_id"] . "\n\t\t\t\tAND (data_input_data.t_value='' OR data_input_data.t_value is null)\n\t\t\t\tAND data_input_fields.input_output='in'");
            }
            reset($template_fields[$data_source["local_data_template_data_id"]]);
            /* loop through each field contained in the data template and push out a host value if:
            		 - the field is a valid "host field"
            		 - the value of the field is empty
            		 - the field is set to 'templated' */
            if (sizeof($template_fields[$data_source["local_data_template_data_id"]])) {
                foreach ($template_fields[$data_source["local_data_template_data_id"]] as $template_field) {
                    if (preg_match('/^' . VALID_HOST_FIELDS . '$/i', $template_field["type_code"]) && $template_field["value"] == "" && $template_field["t_value"] == "") {
                        db_execute_prepared('REPLACE INTO data_input_data (data_input_field_id, data_template_data_id, value) VALUES (?, ?, ?)', array($template_field['id'], $data_source['id'], $host[$template_field['type_code']]));
                    }
                }
            }
            /* flag an update to the poller cache as well */
            $local_data_ids[] = $data_source["local_data_id"];
            $poller_items = array_merge($poller_items, update_poller_cache($data_source["local_data_id"]));
        }
    }
    if (sizeof($local_data_ids)) {
        poller_update_poller_cache_from_buffer($local_data_ids, $poller_items);
    }
}
开发者ID:MrWnn,项目名称:cacti,代码行数:64,代码来源:utility.php


示例13: api_device_enable

function api_device_enable($device_id) {
	require_once(CACTI_BASE_PATH . "/lib/data_source/data_source_info.php");

	db_update("host",
		array(
			"disabled" => array("type" => DB_TYPE_STRING, "value" => ""),
			"id" => array("type" => DB_TYPE_INTEGER, "value" => $device_id)
			),
		array("id"));

	/* obtain a list of all data sources associated with this device */
	$data_sources = api_data_source_list(array("host_id" => $device_id));

	if (sizeof($data_sources) > 0) {
		foreach ($data_sources as $data_source) {
			update_poller_cache($data_source["id"], false);
		}
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:19,代码来源:device_update.php


示例14: form_actions

function form_actions()
{
    global $colors, $device_actions, $fields_host_edit;
    /* 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"] == "2") {
            /* Enable Selected Devices */
            for ($i = 0; $i < count($selected_items); $i++) {
                /* ================= input validation ================= */
                input_validate_input_number($selected_items[$i]);
                /* ==================================================== */
                db_execute("update host set disabled='' where id='" . $selected_items[$i] . "'");
                /* update poller cache */
                $data_sources = db_fetch_assoc("select id from data_local where host_id='" . $selected_items[$i] . "'");
                if (sizeof($data_sources) > 0) {
                    foreach ($data_sources as $data_source) {
                        update_poller_cache($data_source["id"], false);
                    }
                }
            }
        } elseif ($_POST["drp_action"] == "3") {
            /* Disable Selected Devices */
            for ($i = 0; $i < count($selected_items); $i++) {
                /* ================= input validation ================= */
                input_validate_input_number($selected_items[$i]);
                /* ==================================================== */
                db_execute("update host set disabled='on' where id='" . $selected_items[$i] . "'");
                /* update poller cache */
                db_execute("delete from poller_item where host_id='" . $selected_items[$i] . "'");
                db_execute("delete from poller_reindex where host_id='" . $selected_items[$i] . "'");
            }
        } elseif ($_POST["drp_action"] == "4") {
            /* change snmp options */
            for ($i = 0; $i < count($selected_items); $i++) {
                /* ================= input validation ================= */
                input_validate_input_number($selected_items[$i]);
                /* ==================================================== */
                reset($fields_host_edit);
                while (list($field_name, $field_array) = each($fields_host_edit)) {
                    if (isset($_POST["t_{$field_name}"])) {
                        db_execute("update host set {$field_name} = '" . $_POST[$field_name] . "' where id='" . $selected_items[$i] . "'");
                    }
                }
                push_out_host($selected_items[$i]);
            }
        } elseif ($_POST["drp_action"] == "5") {
            /* Clear Statisitics for Selected Devices */
            for ($i = 0; $i < count($selected_items); $i++) {
                /* ================= input validation ================= */
                input_validate_input_number($selected_items[$i]);
                /* ==================================================== */
                db_execute("update host set min_time = '9.99999', max_time = '0', cur_time = '0',\tavg_time = '0',\n\t\t\t\t\t\ttotal_polls = '0', failed_polls = '0',\tavailability = '100.00'\n\t\t\t\t\t\twhere id = '" . $selected_items[$i] . "'");
            }
        } elseif ($_POST["drp_action"] == "6") {
            /* change availability options */
            for ($i = 0; $i < count($selected_items); $i++) {
                /* ================= input validation ================= */
                input_validate_input_number($selected_items[$i]);
                /* ==================================================== */
                reset($fields_host_edit);
                while (list($field_name, $field_array) = each($fields_host_edit)) {
                    if (isset($_POST["t_{$field_name}"])) {
                        db_execute("update host set {$field_name} = '" . $_POST[$field_name] . "' where id='" . $selected_items[$i] . "'");
                    }
                }
                push_out_host($selected_items[$i]);
            }
        } elseif ($_POST["drp_action"] == "1") {
            /* delete */
            if (!isset($_POST["delete_type"])) {
                $_POST["delete_type"] = 2;
            }
            $data_sources_to_act_on = array();
            $graphs_to_act_on = array();
            $devices_to_act_on = array();
            for ($i = 0; $i < count($selected_items); $i++) {
                /* ================= input validation ================= */
                input_validate_input_number($selected_items[$i]);
                /* ==================================================== */
                $data_sources = db_fetch_assoc("select\n\t\t\t\t\tdata_local.id as local_data_id\n\t\t\t\t\tfrom data_local\n\t\t\t\t\twhere " . array_to_sql_or($selected_items, "data_local.host_id"));
                if (sizeof($data_sources) > 0) {
                    foreach ($data_sources as $data_source) {
                        $data_sources_to_act_on[] = $data_source["local_data_id"];
                    }
                }
                if ($_POST["delete_type"] == 2) {
                    $graphs = db_fetch_assoc("select\n\t\t\t\t\t\tgraph_local.id as local_graph_id\n\t\t\t\t\t\tfrom graph_local\n\t\t\t\t\t\twhere " . array_to_sql_or($selected_items, "graph_local.host_id"));
                    if (sizeof( 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP update_post_cache函数代码示例发布时间:2022-05-23
下一篇:
PHP update_pm_count函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap