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


PHP run_data_query函数代码示例

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


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

示例1: device_reload_query

function device_reload_query() {
	/* ================= input validation ================= */
	input_validate_input_number(get_request_var("id"));
	input_validate_input_number(get_request_var("device_id"));
	/* ==================================================== */

	run_data_query(get_request_var("device_id"), get_request_var("id"));
}
开发者ID:songchin,项目名称:Cacti,代码行数:8,代码来源:device_form.php

示例2: each

	$i = 0;

	/* get all items on the form and write values for them  */
	while (list($name, $array) = each($input)) {
		if (isset($_POST[$name])) {
			db_execute("update settings set value='" . $_POST[$name] . "' where name='$name'");
		}
	}

	setcookie(session_name(),"",time() - 3600,"/");

	kill_session_var("sess_config_array");
	kill_session_var("sess_host_cache_array");

	/* just in case we have hard drive graphs to deal with */
	run_data_query(db_fetch_cell("select id from host where hostname='127.0.0.1'"), 6);

	/* it's always a good idea to re-populate the poller cache to make sure everything is refreshed and
	up-to-date */
	repopulate_poller_cache();

	db_execute("delete from version");
	db_execute("insert into version (cacti) values ('" . $config["cacti_version"] . "')");

	header ("Location: ../index.php");
	exit;
}elseif (($_REQUEST["step"] == "8") && ($_REQUEST["install_type"] == "3")) {
	/* if the version is not found, die */
	if (!is_int($old_version_index)) {
		print "	<p style='font-family: Verdana, Arial; font-size: 16px; font-weight: bold; color: red;'>Error</p>
			<p style='font-family: Verdana, Arial; font-size: 12px;'>Invalid Cacti version
开发者ID:songchin,项目名称:Cacti,代码行数:31,代码来源:index.php

示例3: api_device_save

function api_device_save($id, $host_template_id, $description, $hostname, $snmp_community, $snmp_version,
	$snmp_username, $snmp_password, $snmp_port, $snmp_timeout, $disabled) {
	/* fetch some cache variables */
	if (empty($id)) {
		$_host_template_id = 0;
	}else{
		$_host_template_id = db_fetch_cell("select host_template_id from host where id=$id");
	}

	$save["id"] = $id;
	$save["host_template_id"] = form_input_validate($host_template_id, "host_template_id", "^[0-9]+$", false, 3);
	$save["description"] = form_input_validate($description, "description", "", false, 3);
	$save["hostname"] = form_input_validate($hostname, "hostname", "", false, 3);
	$save["snmp_community"] = form_input_validate($snmp_community, "snmp_community", "", true, 3);
	$save["snmp_version"] = form_input_validate($snmp_version, "snmp_version", "", true, 3);
	$save["snmp_username"] = form_input_validate($snmp_username, "snmp_username", "", true, 3);
	$save["snmp_password"] = form_input_validate($snmp_password, "snmp_password", "", true, 3);
	$save["snmp_port"] = form_input_validate($snmp_port, "snmp_port", "^[0-9]+$", false, 3);
	$save["snmp_timeout"] = form_input_validate($snmp_timeout, "snmp_timeout", "^[0-9]+$", false, 3);
	$save["disabled"] = form_input_validate($disabled, "disabled", "", true, 3);

	$host_id = 0;

	if (!is_error_message()) {
		$host_id = sql_save($save, "host");

		if ($host_id) {
			raise_message(1);

			/* push out relavant fields to data sources using this host */
			push_out_host($host_id, 0);

			/* the host substitution cache is now stale; purge it */
			kill_session_var("sess_host_cache_array");

			/* update title cache for graph and data source */
			update_data_source_title_cache_from_host($host_id);
			update_graph_title_cache_from_host($host_id);
		}else{
			raise_message(2);
		}

		/* if the user changes the host template, add each snmp query associated with it */
		if (($host_template_id != $_host_template_id) && (!empty($host_template_id))) {
			$snmp_queries = db_fetch_assoc("select snmp_query_id from host_template_snmp_query where host_template_id=$host_template_id");

			if (sizeof($snmp_queries) > 0) {
			foreach ($snmp_queries as $snmp_query) {
				db_execute("replace into host_snmp_query (host_id,snmp_query_id,reindex_method) values ($host_id," . $snmp_query["snmp_query_id"] . "," . DATA_QUERY_AUTOINDEX_BACKWARDS_UPTIME . ")");

				/* recache snmp data */
				run_data_query($host_id, $snmp_query["snmp_query_id"]);
			}
			}

			$graph_templates = db_fetch_assoc("select graph_template_id from host_template_graph where host_template_id=$host_template_id");

			if (sizeof($graph_templates) > 0) {
			foreach ($graph_templates as $graph_template) {
				db_execute("replace into host_graph (host_id,graph_template_id) values ($host_id," . $graph_template["graph_template_id"] . ")");
			}
			}
		}
	}

	return $host_id;
}
开发者ID:songchin,项目名称:Cacti,代码行数:67,代码来源:api_device.php

示例4: host_reload_query

function host_reload_query()
{
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request('id'));
    input_validate_input_number(get_request_var_request('host_id'));
    /* ==================================================== */
    run_data_query($_REQUEST['host_id'], $_REQUEST['id']);
}
开发者ID:MrWnn,项目名称:cacti,代码行数:8,代码来源:graphs_new.php

示例5: host_reload_query

function host_reload_query()
{
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var("id"));
    input_validate_input_number(get_request_var("host_id"));
    /* ==================================================== */
    run_data_query($_GET["host_id"], $_GET["id"]);
}
开发者ID:songchin,项目名称:Cacti,代码行数:8,代码来源:host.php

示例6: add_host_dq_graphs

function add_host_dq_graphs($host_id, $dq, $field = '', $regex = '', $include = true)
{
    global $config;
    /* add entry if it does not exist */
    $exists = db_fetch_cell("SELECT count(*) FROM host_snmp_query WHERE host_id={$host_id} AND snmp_query_id={$dq}");
    if (!$exists) {
        db_execute("REPLACE INTO host_snmp_query (host_id,snmp_query_id,reindex_method) VALUES ({$host_id}, {$dq}, 1)");
    }
    /* recache snmp data */
    debug('Reindexing Host');
    run_data_query($host_id, $dq);
    $graph_templates = db_fetch_assoc('SELECT * 
		FROM snmp_query_graph 
		WHERE snmp_query_id=' . $dq);
    debug('Adding Graphs');
    if (sizeof($graph_templates)) {
        foreach ($graph_templates as $gt) {
            mikrotik_dq_graphs($host_id, $dq, $gt['graph_template_id'], $gt['id'], $field, $regex, $include);
        }
    }
}
开发者ID:Cacti,项目名称:plugin_mikrotik,代码行数:21,代码来源:poller_graphs.php

示例7: createDQGraph

function createDQGraph($snmp_query_array, $graphTitle, $force) {

	/* is this data query already associated (independent of the reindex method) */
	$exists_already = db_fetch_cell("SELECT COUNT(device_id) FROM device_snmp_query WHERE device_id=" . $snmp_query_array["device_id"] . " AND snmp_query_id=" . $snmp_query_array["snmp_query_id"]);
	if ((isset($exists_already)) &&
	($exists_already > 0)) {
		/* yes: do nothing, everything's fine */
	}else{
		db_execute("REPLACE INTO device_snmp_query (device_id,snmp_query_id,reindex_method) " .
					   "VALUES (" .
		$snmp_query_array["device_id"] . "," .
		$snmp_query_array["snmp_query_id"] . "," .
		$snmp_query_array["reindex_method"] .
						")");
		/* recache snmp data, this is time consuming,
		 * but should happen only once even if multiple graphs
		 * are added for the same data query
		 * because we checked above, if dq was already associated */
		run_data_query($snmp_query_array["device_id"], $snmp_query_array["snmp_query_id"]);
	}

	$snmp_query_array["snmp_index_on"] = get_best_data_query_index_type($snmp_query_array["device_id"], $snmp_query_array["snmp_query_id"]);

	$snmp_indexes = db_fetch_assoc("SELECT snmp_index " .
										"FROM device_snmp_cache " .
										"WHERE device_id=" . $snmp_query_array["device_id"] . " " .
										"AND snmp_query_id=" . $snmp_query_array["snmp_query_id"] . " " .
										"AND field_name='" . $snmp_query_array["snmp_field"] . "' " .
										"AND field_value='" . $snmp_query_array["snmp_value"] . "'");

	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 " .
												"FROM graph_local " .
												"WHERE graph_template_id=" . $snmp_query_array["graph_template_id"] . " " .
												"AND device_id=" . $snmp_query_array["device_id"] . " " .
												"AND snmp_query_id=" . $snmp_query_array["snmp_query_id"] . " " .
												"AND snmp_index='" . $snmp_query_array["snmp_index"] . "'");

			if (isset($existsAlready) && $existsAlready > 0) {
				$dataSourceId = db_fetch_cell("SELECT
						data_template_rrd.local_data_id
						FROM graph_templates_item, data_template_rrd
						WHERE graph_templates_item.local_graph_id = " . $existsAlready . "
						AND graph_templates_item.task_item_id = data_template_rrd.id
						LIMIT 1");
				echo __("NOTE: Not Adding Graph - this graph already exists - graph-id: (%d) - data-source-id: (%d)", $existsAlready, $dataSourceId) . "\n";
				continue;
			}

			$empty = array(); /* Suggested Values are not been implemented */
			$returnArray = create_complete_graph_from_template($snmp_query_array["graph_template_id"], $snmp_query_array["device_id"], $snmp_query_array, $empty);

			if ($graphTitle != "") {
				db_execute("UPDATE graph_templates_graph " .
								"SET title='" . $graphTitle ."' " .
								"WHERE local_graph_id=" . $returnArray["local_graph_id"]);
				update_graph_title_cache($returnArray["local_graph_id"]);
			}

			$dataSourceId = db_fetch_cell("SELECT " .
					"data_template_rrd.local_data_id " .
					"FROM graph_templates_item, data_template_rrd " .
					"WHERE graph_templates_item.local_graph_id = " . $returnArray["local_graph_id"] . " " .
					"AND graph_templates_item.task_item_id = data_template_rrd.id " .
					"LIMIT 1");

			foreach($returnArray["local_data_id"] as $item) {
				push_out_device($snmp_query_array["device_id"], $item);
				$dataSourceId .= (strlen($dataSourceId) ? ", " : "") . $item;
			}

			echo __("Graph Added - graph-id: (%d) - data-source-ids: (%d)", $returnArray["local_graph_id"], $dataSourceId) . "\n";
		}
	}else{
		echo __("ERROR: Could not find snmp-field %s (%d) for device-id %d (%s)", $snmp_query_array["snmp_field"], $snmp_query_array["snmp_value"], $snmp_query_array["device_id"], $devices[$snmp_query_array["device_id"]]["hostname"]) . "\n";
		echo __("Try php -q graph_list.php --device-id=%s --list-snmp-fields", $snmp_query_array["device_id"]) . "\n";
		exit(1);
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:82,代码来源:graph_create.php

示例8: each

	while (list($name, $array) = each($input)) {
		if (isset($_POST[$name])) {
			db_execute("replace into settings (name,value) values ('$name','" . $_POST[$name] . "')");
		}
	}

	setcookie(session_name(),"",time() - 3600,"/");

	kill_session_var("sess_config_array");
	kill_session_var("sess_host_cache_array");

	/* just in case we have hard drive graphs to deal with */
	$host_id = db_fetch_cell("select id from host where hostname='127.0.0.1'");

	if (!empty($host_id)) {
		run_data_query($host_id, 6);
	}

	/* it's always a good idea to re-populate the poller cache to make sure everything is refreshed and
	up-to-date */
	repopulate_poller_cache();

	db_execute("delete from version");
	db_execute("insert into version (cacti) values ('" . $config["cacti_version"] . "')");

	header ("Location: ../index.php");
	exit;
}elseif (($_REQUEST["step"] == "8") && ($_REQUEST["install_type"] == "3")) {
	/* if the version is not found, die */
	if (!is_int($old_version_index)) {
		print "	<p style='font-family: Verdana, Arial; font-size: 16px; font-weight: bold; color: red;'>Error</p>
开发者ID:songchin,项目名称:Cacti,代码行数:31,代码来源:index.php

示例9: api_device_save

function api_device_save($id, $host_template_id, $description, $hostname, $snmp_community, $snmp_version, $snmp_username, $snmp_password, $snmp_port, $snmp_timeout, $disabled, $availability_method, $ping_method, $ping_port, $ping_timeout, $ping_retries, $notes, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $max_oids, $device_threads)
{
    global $config;
    include_once $config['base_path'] . '/lib/utility.php';
    include_once $config['base_path'] . '/lib/variables.php';
    include_once $config['base_path'] . '/lib/data_query.php';
    /* fetch some cache variables */
    if (empty($id)) {
        $_host_template_id = 0;
    } else {
        $_host_template_id = db_fetch_cell_prepared('SELECT host_template_id FROM host WHERE id=?', array($id));
    }
    $save['id'] = form_input_validate($id, 'id', '^[0-9]+$', false, 3);
    $save['host_template_id'] = form_input_validate($host_template_id, 'host_template_id', '^[0-9]+$', false, 3);
    $save['description'] = form_input_validate($description, 'description', '', false, 3);
    $save['hostname'] = form_input_validate(trim($hostname), 'hostname', '', false, 3);
    $save['notes'] = form_input_validate($notes, 'notes', '', true, 3);
    $save['snmp_version'] = form_input_validate($snmp_version, 'snmp_version', '', true, 3);
    $save['snmp_community'] = form_input_validate($snmp_community, 'snmp_community', '', true, 3);
    if ($save['snmp_version'] == 3) {
        $save['snmp_username'] = form_input_validate($snmp_username, 'snmp_username', '', true, 3);
        $save['snmp_password'] = form_input_validate($snmp_password, 'snmp_password', '', true, 3);
        $save['snmp_auth_protocol'] = form_input_validate($snmp_auth_protocol, 'snmp_auth_protocol', "^\\[None\\]|MD5|SHA\$", true, 3);
        $save['snmp_priv_passphrase'] = form_input_validate($snmp_priv_passphrase, 'snmp_priv_passphrase', '', true, 3);
        $save['snmp_priv_protocol'] = form_input_validate($snmp_priv_protocol, 'snmp_priv_protocol', "^\\[None\\]|DES|AES128\$", true, 3);
        $save['snmp_context'] = form_input_validate($snmp_context, 'snmp_context', '', true, 3);
    } else {
        $save['snmp_username'] = '';
        $save['snmp_password'] = '';
        $save['snmp_auth_protocol'] = '';
        $save['snmp_priv_passphrase'] = '';
        $save['snmp_priv_protocol'] = '';
        $save['snmp_context'] = '';
    }
    $save['snmp_port'] = form_input_validate($snmp_port, 'snmp_port', '^[0-9]+$', false, 3);
    $save['snmp_timeout'] = form_input_validate($snmp_timeout, 'snmp_timeout', '^[0-9]+$', false, 3);
    /* disabled = 'on'   => regexp '^on$'
     * not disabled = '' => no regexp, but allow nulls */
    $save['disabled'] = form_input_validate($disabled, 'disabled', '^on$', true, 3);
    $save['availability_method'] = form_input_validate($availability_method, 'availability_method', '^[0-9]+$', false, 3);
    $save['ping_method'] = form_input_validate($ping_method, 'ping_method', '^[0-9]+$', false, 3);
    $save['ping_port'] = form_input_validate($ping_port, 'ping_port', '^[0-9]+$', true, 3);
    $save['ping_timeout'] = form_input_validate($ping_timeout, 'ping_timeout', '^[0-9]+$', true, 3);
    $save['ping_retries'] = form_input_validate($ping_retries, 'ping_retries', '^[0-9]+$', true, 3);
    $save['max_oids'] = form_input_validate($max_oids, 'max_oids', '^[0-9]+$', true, 3);
    $save['device_threads'] = form_input_validate($device_threads, 'device_threads', '^[0-9]+$', true, 3);
    $save = api_plugin_hook_function('api_device_save', $save);
    $host_id = 0;
    if (!is_error_message()) {
        $host_id = sql_save($save, 'host');
        if ($host_id) {
            raise_message(1);
            /* push out relavant fields to data sources using this host */
            push_out_host($host_id, 0);
            /* the host substitution cache is now stale; purge it */
            kill_session_var('sess_host_cache_array');
            /* update title cache for graph and data source */
            update_data_source_title_cache_from_host($host_id);
            update_graph_title_cache_from_host($host_id);
        } else {
            raise_message(2);
        }
        /* if the user changes the host template, add each snmp query associated with it */
        if ($host_template_id != $_host_template_id && !empty($host_template_id)) {
            $snmp_queries = db_fetch_assoc_prepared('SELECT snmp_query_id FROM host_template_snmp_query WHERE host_template_id = ?', array($host_template_id));
            if (sizeof($snmp_queries) > 0) {
                foreach ($snmp_queries as $snmp_query) {
                    db_execute_prepared('REPLACE INTO host_snmp_query (host_id, snmp_query_id, reindex_method) VALUES (?, ?, ?)', array($host_id, $snmp_query['snmp_query_id'], read_config_option('reindex_method')));
                    /* recache snmp data */
                    run_data_query($host_id, $snmp_query['snmp_query_id']);
                }
            }
            $graph_templates = db_fetch_assoc_prepared('SELECT graph_template_id FROM host_template_graph WHERE host_template_id = ?', array($host_template_id));
            if (sizeof($graph_templates) > 0) {
                foreach ($graph_templates as $graph_template) {
                    db_execute_prepared('REPLACE INTO host_graph (host_id, graph_template_id) VALUES (?, ?)', array($host_id, $graph_template['graph_template_id']));
                    api_plugin_hook_function('add_graph_template_to_host', array('host_id' => $host_id, 'graph_template_id' => $graph_template['graph_template_id']));
                }
            }
        }
    }
    # now that we have the id of the new host, we may plugin postprocessing code
    $save['id'] = $host_id;
    snmpagent_api_device_new($save);
    api_plugin_hook_function('api_device_new', $save);
    return $host_id;
}
开发者ID:MrWnn,项目名称:cacti,代码行数:87,代码来源:api_device.php

示例10: api_graphs_new_reload_query

function api_graphs_new_reload_query() {
	run_data_query(get_request_var("device_id"), get_request_var("id"));
}
开发者ID:songchin,项目名称:Cacti,代码行数:3,代码来源:graphs_new_form.php

示例11: db_execute

		if ($debug) {
			print $sql_upd1 . $sql_upd2 . $sql_upd3 . "\n";
		} else {
			$ok = db_execute($sql_upd1 . $sql_upd2 . $sql_upd3);
			# add the snmp query name for printout
			$old["snmp_query_name"] = db_fetch_cell("SELECT name FROM snmp_query WHERE id=" . $old["snmp_query_id"]);

			if ($ok) {

				if (!$quietMode) {
					echo __("Data Query (%s: %s) reindex method (%s: %s) updated for %s Device(s)", $old["snmp_query_id"], $old["snmp_query_name"], $new["reindex_method"], $reindex_types{$new["reindex_method"]}, sizeof($verified_devices)) . "\n";
				}

				foreach ($verified_devices as $verified_device) {
					/* recache snmp data */
					run_data_query($verified_device["id"], $old["snmp_query_id"]);
					if (!$quietMode) {
						if (is_error_message()) {
							echo __("ERROR: Rerun of this data query failed for device (%s: %s) data query (%s: %s) reindex method (%s: %s)", $verified_device["id"], $verified_device["hostname"], $old["snmp_query_id"], $old["snmp_query_name"], $new["reindex_method"], $reindex_types[$new["reindex_method"]]) . "\n";
						} else {
							echo __("Data Query (%s: %s) reindex method (%s: %s) rerun for Device (%s: %s)", $old["snmp_query_id"], $old["snmp_query_name"], $new["reindex_method"], $reindex_types{$new["reindex_method"]}, $verified_device["id"], $verified_device["hostname"]) . "\n";
						}
					}
				}
			} else {
				echo __("ERROR: Failed to update Data Query (%s: %s) reindex method (%s: %s) for %s Device(s)", $old["snmp_query_id"], $old["snmp_query_name"], $new["reindex_method"], $reindex_types{$new["reindex_method"]}, sizeof($verified_devices)) . "\n";
			}
		}
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:30,代码来源:data_query_update.php

示例12: each

	while (list($name, $array) = each($input)) {
		if (isset($_POST[$name])) {
			db_execute("replace into settings (name,value) values ('$name','" . get_request_var_post($name) . "')");
		}
	}

	setcookie(session_name(),"",time() - 3600,"/");

	kill_session_var("sess_config_array");
	kill_session_var("sess_device_cache_array");

	/* just in case we have hard drive graphs to deal with */
	$device_id = db_fetch_cell("select id from device where hostname='127.0.0.1'");

	if (!empty($device_id)) {
		run_data_query($device_id, 6);
	}

	/* it's not always a good idea to re-populate the poller cache to make sure everything is
	refreshed and up-to-date */
	if ($repopulate) {
		repopulate_poller_cache();
	}

	db_execute("delete from version");
	db_execute("insert into version (cacti) values ('" . CACTI_VERSION . "')");

	header ("Location: ../index.php");
	exit;
}elseif ((get_request_var_request("step") == "8") && (get_request_var_request("install_type") == "3")) {
	/* if the version is not found, die */
开发者ID:songchin,项目名称:Cacti,代码行数:31,代码来源:index.php

示例13: create_ds_graphs

function create_ds_graphs($args)
{
    $hostId = $args["hostId"];
    $hostTemplateId = $args["hostTemplateId"];
    $description = $args["description"];
    $queryTypeIds = $args["queryTypeIds"];
    $snmpQueryId = $args["snmpQueryId"];
    $ignoreIntsLike = $args["ignoreIntsLike"];
    if (!isset($hostId) || !isset($description) || !isset($queryTypeIds) || !isset($snmpQueryId)) {
        echo "ERROR: create_ds_graph: Missing required arguments\n";
        exit(1);
    }
    /* Check if host has associated data query */
    $host_data_query = "SELECT snmp_query_id\n                       FROM   host_snmp_query\n                       WHERE  host_id='{$hostId}'\n                          AND snmp_query_id='{$snmpQueryId}'";
    $snmpQuery = db_fetch_cell($host_data_query);
    if (!$snmpQuery) {
        // The query is not yet int the database.  Insert it
        debug("Inserting missing host_snmp_query");
        $insertQuery = "REPLACE INTO host_snmp_query (host_id,snmp_query_id,reindex_method) \n                            VALUES ({$hostId},{$snmpQueryId},2)";
        $r = db_execute($insertQuery);
        if (!$r) {
            echo "ERROR: DB operation failed for {$insertQuery}\n";
            return 0;
        }
        // recache snmp data
        debug("Running Data query for new query id: {$snmpQueryId}");
        run_data_query($hostId, $snmpQueryId);
    }
    $snmpQueryArray = array();
    $snmpQueryArray["snmp_query_id"] = $snmpQueryId;
    $snmpQueryArray["snmp_index_on"] = get_best_data_query_index_type($hostId, $snmpQueryId);
    $indexes_query = "SELECT snmp_index\n                     FROM   host_snmp_cache\n                     WHERE  host_id='{$hostId}'\n                        AND snmp_query_id='{$snmpQueryId}'";
    if (isset($args["snmpCriteria"]) && $args["snmpCriteria"] != "") {
        $indexes_query .= " AND " . $args["snmpCriteria"];
    }
    $snmpIndexes = db_fetch_assoc($indexes_query);
    // Interfaces to ignore
    if ($snmpQueryId == 1 && count($snmpIndexes) && isset($ignoreIntsLike) && count($ignoreIntsLike)) {
        $ignQuery = "SELECT snmp_index\n                  FROM   host_snmp_cache\n                  WHERE  host_id='{$hostId}'\n                    AND  snmp_query_id=1\n                    AND  field_name='ifDescr'";
        $patts = array();
        foreach ($ignoreIntsLike as $patt) {
            array_push($patts, "field_value LIKE '{$patt}'");
        }
        $crit = implode(' OR ', $patts);
        $ignQuery .= " AND ({$crit})";
        $ignIndexes = db_fetch_assoc($ignQuery);
        // Make into an associative array for faster lookups
        $ignHash = array();
        foreach ($ignIndexes as $row) {
            $ignHash[$row["snmp_index"]] = TRUE;
        }
        if (count($ignHash)) {
            // Now exclude the indexes that matched the ignore patterns
            $temparr = array();
            foreach ($snmpIndexes as $row) {
                if (!isset($ignHash[$row["snmp_index"]])) {
                    array_push($temparr, $row);
                }
            }
            $snmpIndexes = $temparr;
        }
    }
    if (count($snmpIndexes)) {
        $graphsCreated = 0;
        $graphs = db_fetch_assoc("SELECT id, snmp_index, graph_template_id\n                              FROM   graph_local\n                              WHERE  host_id={$hostId}\n                                AND  snmp_query_id={$snmpQueryId}");
        foreach ($graphs as $row) {
            $graphsBySnmpIndex[$row["snmp_index"]][$row["graph_template_id"]] = $row["id"];
        }
        foreach ($queryTypeIds as $queryTypeId => $templateId) {
            $snmpQueryArray["snmp_query_graph_id"] = $queryTypeId;
            foreach ($snmpIndexes as $row) {
                $snmpIndex = $row["snmp_index"];
                if (isset($graphsBySnmpIndex[$snmpIndex][$templateId])) {
                    $graphId = $graphsBySnmpIndex[$snmpIndex][$templateId];
                    debug("{$description}: Graph already exists: ({$graphId})");
                    continue;
                }
                $snmpQueryArray["snmp_index"] = $snmpIndex;
                $empty = array();
                $returnArray = create_complete_graph_from_template($templateId, $hostId, $snmpQueryArray, $empty);
                echo "{$description}: Added Graph id: " . $returnArray["local_graph_id"] . "\n";
                $graphsCreated++;
            }
        }
        if ($graphsCreated > 0) {
            push_out_host($hostId, 0);
            return $graphsCreated;
        }
    } else {
        debug("{$description}: No rows in query: {$indexes_query}");
    }
}
开发者ID:mzagrabe,项目名称:Netdot,代码行数:92,代码来源:netdot_to_cacti.php

示例14: create_ds_graphs

function create_ds_graphs($args)
{
    $hostId = $args["hostId"];
    $hostTemplateId = $args["hostTemplateId"];
    $description = $args["description"];
    $queryTypeIds = $args["queryTypeIds"];
    $snmpQueryId = $args["snmpQueryId"];
    if (!isset($hostId) || !isset($description) || !isset($queryTypeIds) || !isset($snmpQueryId)) {
        echo "ERROR: create_ds_graph: Missing required arguments\n";
        exit(1);
    }
    /* Check if host has associated data query */
    $host_data_query = "SELECT snmp_query_id\n                       FROM   host_snmp_query\n                       WHERE  host_id='{$hostId}'\n                          AND snmp_query_id='{$snmpQueryId}'";
    $snmpQuery = db_fetch_cell($host_data_query);
    if (!$snmpQuery) {
        // The query is not yet int the database.  Insert it
        debug("Inserting missing host_snmp_query");
        $insertQuery = "REPLACE INTO host_snmp_query (host_id,snmp_query_id,reindex_method) \n                            VALUES ({$hostId},{$snmpQueryId},2)";
        $r = db_execute($insertQuery);
        if (!$r) {
            echo "ERROR: DB operation failed for {$insertQuery}\n";
            return 0;
        }
        // recache snmp data
        debug("Running Data query for new query id: {$snmpQueryId}");
        run_data_query($hostId, $snmpQueryId);
    }
    $snmpQueryArray = array();
    $snmpQueryArray["snmp_query_id"] = $snmpQueryId;
    $snmpQueryArray["snmp_index_on"] = get_best_data_query_index_type($hostId, $snmpQueryId);
    $indexes_query = "SELECT snmp_index\n                     FROM   host_snmp_cache\n                     WHERE  host_id='{$hostId}'\n                        AND snmp_query_id='{$snmpQueryId}'";
    if (isset($args["snmpCriteria"]) && $args["snmpCriteria"] != "") {
        $indexes_query .= " AND " . $args["snmpCriteria"];
    }
    $snmpIndexes = db_fetch_assoc($indexes_query);
    if (sizeof($snmpIndexes)) {
        $graphsCreated = 0;
        $graphs = db_fetch_assoc("SELECT id, snmp_index, graph_template_id\n                              FROM   graph_local\n                              WHERE  host_id={$hostId}\n                                AND  snmp_query_id={$snmpQueryId}");
        foreach ($graphs as $row) {
            $graphsBySnmpIndex[$row["snmp_index"]][$row["graph_template_id"]] = $row["id"];
        }
        foreach ($queryTypeIds as $queryTypeId => $templateId) {
            $snmpQueryArray["snmp_query_graph_id"] = $queryTypeId;
            foreach ($snmpIndexes as $row) {
                $snmpIndex = $row["snmp_index"];
                if (isset($graphsBySnmpIndex[$snmpIndex][$templateId])) {
                    $graphId = $graphsBySnmpIndex[$snmpIndex][$templateId];
                    debug("{$description}: Graph already exists: ({$graphId})");
                    continue;
                }
                $snmpQueryArray["snmp_index"] = $snmpIndex;
                $empty = array();
                $returnArray = create_complete_graph_from_template($templateId, $hostId, $snmpQueryArray, $empty);
                echo "{$description}: Added Graph id: " . $returnArray["local_graph_id"] . "\n";
                $graphsCreated++;
            }
        }
        if ($graphsCreated > 0) {
            push_out_host($hostId, 0);
            return $graphsCreated;
        }
    } else {
        debug("{$description}: No rows in query: {$indexes_query}");
    }
}
开发者ID:richwellman,项目名称:Netdot,代码行数:65,代码来源:netdot_to_cacti.php

示例15: host_reload_query

function host_reload_query()
{
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var("id"));
    input_validate_input_number(get_request_var("host_id"));
    /* ==================================================== */
    /* modify for multi user start */
    if (!check_host($_GET["host_id"])) {
        access_denied();
    }
    /* modify for multi user end */
    run_data_query($_GET["host_id"], $_GET["id"]);
}
开发者ID:resmon,项目名称:resmon-cacti,代码行数:13,代码来源:host.php


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