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


PHP rrd_close函数代码示例

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


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

示例1: export_build_graphs


//.........这里部分代码省略.........
			from graph_templates_graph
				left join graph_templates on (graph_templates_graph.graph_template_id=graph_templates.id)
			    left join graph_local on (graph_templates_graph.local_graph_id=graph_local.id)
			where graph_local.host_id=".get_host_id($parent_tree_item_id)."
			  and graph_templates_graph.local_graph_id!=0
			  and graph_templates_graph.export='on'
			order by graph_templates_graph.title_cache";
	}else {
		/* searching for the graph_tree_items of the tree_id which are graphs */
		$req="select distinct
				graph_templates_graph.id,
				graph_templates_graph.local_graph_id,
				graph_templates_graph.height,
				graph_templates_graph.width,
				graph_templates_graph.title_cache,
				graph_templates.name,
				graph_local.host_id,
				graph_tree_items.id as gtid
			from graph_templates_graph
				left join graph_tree_items on (graph_templates_graph.local_graph_id=graph_tree_items.local_graph_id)
			    left join graph_templates on (graph_templates_graph.graph_template_id=graph_templates.id)
			    left join graph_local on (graph_templates_graph.local_graph_id=graph_local.id)
			where graph_tree_items.graph_tree_id =".$tree_id."
			  and graph_templates_graph.local_graph_id!=0
			  and graph_templates_graph.export='on'
			order by graph_templates_graph.title_cache";
	}

	$graphs=db_fetch_assoc($req);
	$rras = db_fetch_assoc("select
		rra.id,
		rra.name
		from rra
		order by timespan");

	/* open a pipe to rrdtool for writing */
	$rrdtool_pipe = rrd_init();

	/* for each graph... */
	$i = 0;
	foreach($graphs as $graph)  {
		/* this test gives us the graph_tree_items which are just under the parent_graph_tree_item */
		if (((get_tree_item_type($parent_tree_item_id)=="header") || ($parent_tree_item_id == 0)) && (get_parent_id($graph["gtid"], "graph_tree_items","graph_tree_id = ".$tree_id) != $parent_tree_item_id))  {
			/* do nothing */
		}else {
			/* settings for preview graphs */
			$graph_data_array["graph_height"] = "100";
			$graph_data_array["graph_width"] = "300";
			$graph_data_array["graph_nolegend"] = true;
			$graph_data_array["export"] = true;
			$graph_data_array["export_filename"] = "'".$path."'/thumb_".$graph["local_graph_id"].".png";

			rrdtool_function_graph($graph["local_graph_id"], 0, $graph_data_array, $rrdtool_pipe);
			$total_graphs_created++;

			/* generate html files for each graph */
			$fp_graph_index = fopen($cacti_export_path."/".$path."/graph_".$graph["local_graph_id"].".html", "w");
			fwrite($fp_graph_index, HTML_HEADER_TREE);
			draw_html_left_tree($fp_graph_index,$tree_id);
			fwrite($fp_graph_index, HTML_GRAPH_HEADER_ONE_TREE);
			fwrite($fp_graph_index, "<strong>Graph - " . $graph["title_cache"] . "</strong>");
			fwrite($fp_graph_index, HTML_GRAPH_HEADER_TWO);
			fwrite($fp_graph_index, "<td>");

			/* reset vars for actual graph image creation */
			reset($rras);
			unset($graph_data_array);

			/* generate graphs for each rra */
			foreach ($rras as $rra) {
				$graph_data_array["export"] = true;
				$graph_data_array["export_filename"] = "'".$path."'/graph_".$graph["local_graph_id"]."_".$rra["id"].".png";

				rrdtool_function_graph($graph["local_graph_id"], $rra["id"], $graph_data_array, $rrdtool_pipe);
				$total_graphs_created++;

				/* write image related html */
				fwrite($fp_graph_index, "<div align=center><img src='graph_".$graph["local_graph_id"]."_".$rra["id"].".png' border=0></div>\n
					<div align=center><strong>".$rra["name"]."</strong></div><br>");
			}

			fwrite($fp_graph_index, "</tr></table>");
			fwrite($fp_graph_index, HTML_FOOTER_TREE);
			fclose($fp_graph_index);

			/* main graph page html */
			fwrite($fp, "<td align='center' width='\" . (98 / 2) . \"%'><a href='graph_" . $graph["local_graph_id"] . ".html'><img src='thumb_" . $graph["local_graph_id"] . ".png' border='0' alt='" . $graph["title_cache"] . "'></a></td>\n");
			$i++;
			if (($i == 2)) {
				$i = 0;
				fwrite($fp, "</tr><tr>");
			}
		}
	}

	/* close the rrdtool pipe */
	rrd_close($rrdtool_pipe);

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

示例2: list

		display_help();
		exit;
	}
}

/* record the start time */
list($micro,$seconds) = split(" ", microtime());
$start = $seconds + $micro;

/* open a pipe to rrdtool for writing */
$rrdtool_pipe = rrd_init();

$rrds_processed = 0;

while (db_fetch_cell("SELECT count(*) FROM poller_output") > 0) {
	$rrds_processed = $rrds_processed + process_poller_output($rrdtool_pipe, FALSE);
}

echo "There were $rrds_processed, RRD updates made this pass\n";

rrd_close($rrdtool_pipe);

/*	display_help - displays the usage of the function */
function display_help () {
	print "Cacti Empty Poller Output Table Script 1.0, Copyright 2007 - The Cacti Group\n\n";
	print "usage: poller_output_empty.php [-h] [--help] [-v] [--version]\n\n";
	print "-v --version  - Display this help message\n";
	print "-h --help     - Display this help message\n";
}

?>
开发者ID:songchin,项目名称:Cacti,代码行数:31,代码来源:poller_output_empty.php

示例3: rrdtool_execute

function rrdtool_execute($command_line, $log_to_stdout, $output_flag, &$rrd_struc = array(), $logopt = "WEBLOG") {
	global $config;

	if (!is_numeric($output_flag)) {
		$output_flag = RRDTOOL_OUTPUT_STDOUT;
	}

	/* WIN32: before sending this command off to rrdtool, get rid
	of all of the '\' characters. Unix does not care; win32 does.
	Also make sure to replace all of the fancy \'s at the end of the line,
	but make sure not to get rid of the "\n"'s that are supposed to be
	in there (text format) */
	$command_line = str_replace("\\\n", " ", $command_line);

	/* output information to the log file if appropriate */
	if (read_config_option("log_verbosity") >= POLLER_VERBOSITY_DEBUG) {
		cacti_log("CACTI2RRD: " . read_config_option("path_rrdtool") . " $command_line", $log_to_stdout, $logopt);
	}

	/* if we want to see the error output from rrdtool; make sure to specify this */
	if (($output_flag == RRDTOOL_OUTPUT_STDERR) && (sizeof($rrd_struc) == 0)) {
		$command_line .= " 2>&1";
	}

	/* use popen to eliminate the zombie issue */
	if ($config["cacti_server_os"] == "unix") {
		/* an empty $rrd_struc array means no fp is available */
		if (sizeof($rrd_struc) == 0) {
			session_write_close();
			$fp = popen(read_config_option("path_rrdtool") . escape_command(" $command_line"), "r");
		}else{
			$i = 0;

			while (1) {
				if (fwrite(rrd_get_fd($rrd_struc, RRDTOOL_PIPE_CHILD_READ), escape_command(" $command_line") . "\r\n") == false) {
					cacti_log("ERROR: Detected RRDtool Crash attempting to perform write");

					/* close the invalid pipe */
					rrd_close($rrd_struc);

					/* open a new rrdtool process */
					$rrd_struc = rrd_init();

					if ($i > 4) {
						cacti_log("FATAL: RRDtool Restart Attempts Exceeded.  Giving up on command.");

						break;
					}else{
						$i++;
					}

					continue;
				}else{
					fflush(rrd_get_fd($rrd_struc, RRDTOOL_PIPE_CHILD_READ));

					break;
				}
			}
		}
	}elseif ($config["cacti_server_os"] == "win32") {
		/* an empty $rrd_struc array means no fp is available */
		if (sizeof($rrd_struc) == 0) {
			session_write_close();
			$fp = popen(read_config_option("path_rrdtool") . escape_command(" $command_line"), "rb");
		}else{
			$i = 0;

			while (1) {
				if (fwrite(rrd_get_fd($rrd_struc, RRDTOOL_PIPE_CHILD_READ), escape_command(" $command_line") . "\r\n") == false) {
					cacti_log("ERROR: Detected RRDtool Crash attempting to perform write");

					/* close the invalid pipe */
					rrd_close($rrd_struc);

					/* open a new rrdtool process */
					$rrd_struc = rrd_init();

					if ($i > 4) {
						cacti_log("FATAL: RRDtool Restart Attempts Exceeded.  Giving up on command.");

						break;
					}else{
						$i++;
					}

					continue;
				}else{
					fflush(rrd_get_fd($rrd_struc, RRDTOOL_PIPE_CHILD_READ));

					break;
				}
			}
		}
	}

	switch ($output_flag) {
		case RRDTOOL_OUTPUT_NULL:
			return; break;
		case RRDTOOL_OUTPUT_STDOUT:
			if (isset($fp)) {
//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:rrd.php

示例4: boost_rrdtool_execute_internal

function boost_rrdtool_execute_internal($command_line, $log_to_stdout, $output_flag, $logopt = "WEBLOG")
{
    global $config, $rrdtool_pipe;
    static $last_command;
    if (!is_numeric($output_flag)) {
        $output_flag = RRDTOOL_OUTPUT_STDOUT;
    }
    /* WIN32: before sending this command off to rrdtool, get rid
    	of all of the '\' characters. Unix does not care; win32 does.
    	Also make sure to replace all of the fancy \'s at the end of the line,
    	but make sure not to get rid of the "\n"'s that are supposed to be
    	in there (text format) */
    $command_line = str_replace("\\\n", " ", $command_line);
    /* output information to the log file if appropriate */
    if (read_config_option("log_verbosity") >= POLLER_VERBOSITY_DEBUG) {
        cacti_log("CACTI2RRD: " . read_config_option("path_rrdtool") . " {$command_line}", $log_to_stdout, $logopt);
    }
    /* if we want to see the error output from rrdtool; make sure to specify this */
    if ($output_flag == RRDTOOL_OUTPUT_STDERR) {
        if (!(is_resource($rrdtool_pipe) || is_array($rrdtool_pipe))) {
            $command_line .= " 2>&1";
        }
    }
    /* an empty $rrdtool_pipe resource or no array means no fd is available */
    if (!(is_resource($rrdtool_pipe) || is_array($rrdtool_pipe))) {
        if ($config["cacti_server_os"] == "unix") {
            $popen_type = "r";
        } else {
            $popen_type = "rb";
        }
        session_write_close();
        $fp = popen(read_config_option("path_rrdtool") . escape_command(" {$command_line}"), $popen_type);
    } else {
        $i = 0;
        while (1) {
            if (function_exists("rrd_get_fd")) {
                $fd = rrd_get_fd($rrdtool_pipe, RRDTOOL_PIPE_CHILD_READ);
            } else {
                $fd = $rrdtool_pipe;
            }
            if (fwrite($fd, escape_command(" {$command_line}") . "\r\n") == false) {
                cacti_log("ERROR: Detected RRDtool Crash on '{$command_line}'.  Last command was '{$last_command}'");
                /* close the invalid pipe */
                rrd_close($rrdtool_pipe);
                /* open a new rrdtool process */
                $rrdtool_pipe = rrd_init();
                if ($i > 4) {
                    cacti_log("FATAL: RRDtool Restart Attempts Exceeded.  Giving up on command.");
                    break;
                } else {
                    $i++;
                }
                continue;
            } else {
                fflush($fd);
                break;
            }
        }
    }
    /* store the last command to provide rrdtool segfault diagnostics */
    $last_command = $command_line;
    switch ($output_flag) {
        case RRDTOOL_OUTPUT_NULL:
            return;
            break;
        case RRDTOOL_OUTPUT_STDOUT:
            if (isset($fp) && is_resource($fp)) {
                $line = "";
                while (!feof($fp)) {
                    $line .= fgets($fp, 4096);
                }
                pclose($fp);
                return $line;
            }
            break;
        case RRDTOOL_OUTPUT_STDERR:
            if (isset($fp) && is_resource($fp)) {
                $line = "";
                while (!feof($fp)) {
                    $line .= fgets($fp, 4096);
                }
                pclose($fp);
                if (substr($output, 1, 3) == "PNG") {
                    return "OK";
                }
                if (substr($output, 0, 5) == "GIF87") {
                    return "OK";
                }
                print $output;
            }
            break;
        case RRDTOOL_OUTPUT_GRAPH_DATA:
            if (isset($fp) && is_resource($fp)) {
                $line = "";
                while (!feof($fp)) {
                    $line .= fgets($fp, 4096);
                }
                pclose($fp);
                return $line;
            }
//.........这里部分代码省略.........
开发者ID:resmon,项目名称:resmon-cacti,代码行数:101,代码来源:setup.php

示例5: export_tree_graphs_and_graph_html


//.........这里部分代码省略.........
    if (sizeof($hosts)) {
        foreach ($hosts as $host) {
            $hosts_sql = "SELECT DISTINCT\n\t\t\tgraph_templates_graph.id,\n\t\t\tgraph_templates_graph.local_graph_id,\n\t\t\tgraph_templates_graph.height,\n\t\t\tgraph_templates_graph.width,\n\t\t\tgraph_templates_graph.title_cache,\n\t\t\tgraph_templates.name,\n\t\t\tgraph_local.host_id\n\t\t\tFROM (graph_tree_items, graph_templates_graph)\n\t\t\t{$sql_join}\n\t\t\tWHERE ((graph_templates_graph.local_graph_id<>0)\n\t\t\t{$sql_where}\n\t\t\tAND (graph_local.host_id=" . $host["host_id"] . ")\n\t\t\tAND (graph_templates_graph.export='on'))\n\t\t\tORDER BY graph_templates_graph.title_cache";
            $host_graphs = db_fetch_assoc($hosts_sql);
            if (sizeof($host_graphs)) {
                if (sizeof($graphs)) {
                    $graphs = array_merge($host_graphs, $graphs);
                } else {
                    $graphs = $host_graphs;
                }
            }
        }
    }
    /* now get the list of graphs placed within the tree */
    if ($tree_id == 0) {
        $sql_where = "WHERE graph_templates_graph.local_graph_id!=0\n\t\t\t{$sql_where}\n\t\t\tAND graph_templates_graph.export='on'";
    } else {
        $sql_where = "WHERE graph_tree_items.graph_tree_id =" . $tree_id . "\n\t\t\t{$sql_where}\n\t\t\tAND graph_templates_graph.local_graph_id!=0\n\t\t\tAND graph_templates_graph.export='on'";
    }
    $non_host_sql = "SELECT\n\t\tgraph_templates_graph.id,\n\t\tgraph_templates_graph.local_graph_id,\n\t\tgraph_templates_graph.height,\n\t\tgraph_templates_graph.width,\n\t\tgraph_templates_graph.title_cache,\n\t\tgraph_templates.name,\n\t\tgraph_local.host_id,\n\t\tgraph_tree_items.id AS gtid\n\t\tFROM (graph_tree_items, graph_templates_graph)\n\t\t{$sql_join}\n\t\t{$sql_where}\n\t\tAND graph_tree_items.local_graph_id = graph_templates_graph.local_graph_id\n\t\tAND graph_templates_graph.export='on'\n\t\tORDER BY graph_templates_graph.title_cache";
    $non_host_graphs = db_fetch_assoc($non_host_sql);
    if (sizeof($non_host_graphs)) {
        if (sizeof($graphs)) {
            $graphs = array_merge($non_host_graphs, $graphs);
        } else {
            $graphs = $non_host_graphs;
        }
    }
    /* open a pipe to rrdtool for writing */
    $rrdtool_pipe = rrd_init();
    /* for each graph... */
    $i = 0;
    if (sizeof($graphs) > 0) {
        foreach ($graphs as $graph) {
            $rras = get_associated_rras($graph["local_graph_id"]);
            /* settings for preview graphs */
            $graph_data_array["graph_height"] = read_config_option("export_default_height");
            $graph_data_array["graph_width"] = read_config_option("export_default_width");
            $graph_data_array["graph_nolegend"] = true;
            $graph_data_array["export"] = true;
            if (read_config_option("export_tree_isolation") == "on") {
                $graph_data_array["export_filename"] = "/" . $path . "/graphs/thumb_" . $graph["local_graph_id"] . ".png";
                $export_filename = $cacti_export_path . "/" . $path . "/graphs/thumb_" . $graph["local_graph_id"] . ".png";
            } else {
                $graph_data_array["export_filename"] = "/graphs/thumb_" . $graph["local_graph_id"] . ".png";
                $export_filename = $cacti_export_path . "/graphs/thumb_" . $graph["local_graph_id"] . ".png";
            }
            if (!array_search($export_filename, $exported_files)) {
                /* add the graph to the exported list */
                array_push($exported_files, $export_filename);
                export_log("Creating Graph '" . $cacti_export_path . $graph_data_array["export_filename"] . "'");
                /* generate the graph */
                rrdtool_function_graph($graph["local_graph_id"], 0, $graph_data_array, $rrdtool_pipe);
                $total_graphs_created++;
                /* generate html files for each graph */
                if (read_config_option("export_tree_isolation") == "on") {
                    export_log("Creating File  '" . $cacti_export_path . "/" . $path . "/graph_" . $graph["local_graph_id"] . ".html'");
                    $fp_graph_index = fopen($cacti_export_path . "/" . $path . "/graph_" . $graph["local_graph_id"] . ".html", "w");
                } else {
                    export_log("Creating File  '" . $cacti_export_path . "/graph_" . $graph["local_graph_id"] . ".html'");
                    $fp_graph_index = fopen($cacti_export_path . "/graph_" . $graph["local_graph_id"] . ".html", "w");
                }
                fwrite($fp_graph_index, HTML_HEADER_TREE);
                /* write the code for the tree at the left */
                draw_html_left_tree($fp_graph_index, $tree_id);
                fwrite($fp_graph_index, HTML_GRAPH_HEADER_ONE_TREE);
                fwrite($fp_graph_index, "<strong>Graph - " . $graph["title_cache"] . "</strong></td></tr>");
                fwrite($fp_graph_index, HTML_GRAPH_HEADER_TWO_TREE);
                fwrite($fp_graph_index, "<td>");
                /* reset vars for actual graph image creation */
                reset($rras);
                unset($graph_data_array);
                /* generate graphs for each rra */
                foreach ($rras as $rra) {
                    $graph_data_array["export"] = true;
                    if (read_config_option("export_tree_isolation") == "on") {
                        $graph_data_array["export_filename"] = "/" . $path . "/graphs/graph_" . $graph["local_graph_id"] . "_" . $rra["id"] . ".png";
                    } else {
                        $graph_data_array["export_filename"] = "/graphs/graph_" . $graph["local_graph_id"] . "_" . $rra["id"] . ".png";
                    }
                    export_log("Creating Graph '" . $cacti_export_path . $graph_data_array["export_filename"] . "'");
                    rrdtool_function_graph($graph["local_graph_id"], $rra["id"], $graph_data_array, $rrdtool_pipe);
                    $total_graphs_created++;
                    /* write image related html */
                    if (read_config_option("export_tree_isolation") == "off") {
                        fwrite($fp_graph_index, "<div align=center><img src='graphs/graph_" . $graph["local_graph_id"] . "_" . $rra["id"] . ".png' border=0></div>\n\n\t\t\t\t\t\t<div align=center><strong>" . $rra["name"] . "</strong></div><br>");
                    } else {
                        fwrite($fp_graph_index, "<div align=center><img src='" . "graphs/graph_" . $graph["local_graph_id"] . "_" . $rra["id"] . ".png' border=0></div>\n\n\t\t\t\t\t\t<div align=center><strong>" . $rra["name"] . "</strong></div><br>");
                    }
                }
                fwrite($fp_graph_index, "</td></tr></table></td></tr></table>");
                fwrite($fp_graph_index, HTML_FOOTER_TREE);
                fclose($fp_graph_index);
            }
        }
    }
    /* close the rrdtool pipe */
    rrd_close($rrdtool_pipe);
    return $total_graphs_created;
}
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:graph_export.php

示例6: export


//.........这里部分代码省略.........
	check_remove($cacti_export_path . "/index.html");

	/* open pointer to the new index file */
	$fp_index = fopen($cacti_export_path . "/index.html", "w");

	/* get a list of all graphs that need exported */
	$graphs = db_fetch_assoc("select
		graph_templates_graph.id,
		graph_templates_graph.local_graph_id,
		graph_templates_graph.height,
		graph_templates_graph.width,
		graph_templates_graph.title_cache,
		graph_templates.name,
		graph_local.host_id
		from graph_templates_graph left join graph_templates on graph_templates_graph.graph_template_id=graph_templates.id
		left join graph_local on graph_templates_graph.local_graph_id=graph_local.id
		where graph_templates_graph.local_graph_id!=0 and graph_templates_graph.export='on'
		order by graph_templates_graph.title_cache");
	$rras = db_fetch_assoc("select
		rra.id,
		rra.name
		from rra
		order by steps");

	/* write the html header data to the index file */
	fwrite($fp_index, HTML_HEADER);
	fwrite($fp_index, HTML_GRAPH_HEADER_ONE);
	fwrite($fp_index, "<strong>Displaying " . sizeof($graphs) . " Exported Graph" . ((sizeof($graphs) > 1) ? "s" : "") . "</strong>");
	fwrite($fp_index, HTML_GRAPH_HEADER_TWO);

	/* open a pipe to rrdtool for writing */
	$rrdtool_pipe = rrd_init();

	/* for each graph... */
	$i = 0; $k = 0;
	if ((sizeof($graphs) > 0) && (sizeof($rras) > 0)) {
	foreach ($graphs as $graph) {
		check_remove($cacti_export_path . "/thumb_" . $graph["local_graph_id"] . ".png");
		check_remove($cacti_export_path . "/graph_" . $graph["local_graph_id"] . ".html");

		/* settings for preview graphs */
		$graph_data_array["graph_height"] = "100";
		$graph_data_array["graph_width"] = "300";
		$graph_data_array["graph_nolegend"] = true;
		$graph_data_array["export"] = true;
		$graph_data_array["export_filename"] = "thumb_" . $graph["local_graph_id"] . ".png";
		rrdtool_function_graph($graph["local_graph_id"], 0, $graph_data_array, $rrdtool_pipe);

		/* generate html files for each graph */
		$fp_graph_index = fopen($cacti_export_path . "/graph_" . $graph["local_graph_id"] . ".html", "w");

		fwrite($fp_graph_index, HTML_HEADER);
		fwrite($fp_graph_index, HTML_GRAPH_HEADER_ONE);
		fwrite($fp_graph_index, "<strong>Graph - " . $graph["title_cache"] . "</strong>");
		fwrite($fp_graph_index, HTML_GRAPH_HEADER_TWO);
		fwrite($fp_graph_index, "<td>");

		/* reset vars for actual graph image creation */
		reset($rras);
		unset($graph_data_array);

		/* generate graphs for each rra */
		foreach ($rras as $rra) {
			$graph_data_array["export"] = true;
			$graph_data_array["export_filename"] = "graph_" . $graph["local_graph_id"] . "_" . $rra["id"] . ".png";

			rrdtool_function_graph($graph["local_graph_id"], $rra["id"], $graph_data_array, $rrdtool_pipe);

			/* write image related html */
			fwrite($fp_graph_index, "<div align=center><img src='graph_" . $graph["local_graph_id"] . "_" . $rra["id"] . ".png' border=0></div>\n
				<div align=center><strong>" . $rra["name"] . "</strong></div><br>");
		}

		fwrite($fp_graph_index, "</td>");
		fwrite($fp_graph_index, HTML_GRAPH_FOOTER);
		fwrite($fp_graph_index, HTML_FOOTER);
		fclose($fp_graph_index);

		/* main graph page html */
		fwrite($fp_index, "<td align='center' width='" . (98 / 2) . "%'><a href='graph_" . $graph["local_graph_id"] . ".html'><img src='thumb_" . $graph["local_graph_id"] . ".png' border='0' alt='" . $graph["title_cache"] . "'></a></td>\n");

		$i++;
		$k++;

		if (($i == 2) && ($k < count($graphs))) {
			$i = 0;
			fwrite($fp_index, "</tr><tr>");
		}

	}
	}else{ fwrite($fp_index, "<td><em>No Graphs Found.</em></td>");
	}

	/* close the rrdtool pipe */
	rrd_close($rrdtool_pipe);

	fwrite($fp_index, HTML_GRAPH_FOOTER);
	fwrite($fp_index, HTML_FOOTER);
	fclose($fp_index);
}
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:graph_export.php

示例7: output_rrd_data

function output_rrd_data($start_time, $force = FALSE)
{
    global $start, $max_run_duration, $config, $debug, $get_memory, $memory_used;
    global $rrdtool_pipe, $rrdtool_read_pipe;
    include_once $config['base_path'] . '/lib/rrd.php';
    $boost_poller_status = read_config_option('boost_poller_status');
    $rrd_updates = 0;
    /* implement process lock control for boost */
    if (!db_fetch_cell("SELECT GET_LOCK('poller_boost', 1)")) {
        if ($debug) {
            cacti_log('DEBUG: Found lock, so another boost process is running');
        }
        return -1;
    }
    /* detect a process that has overrun it's warning time */
    if (substr_count($boost_poller_status, 'running')) {
        $status_array = explode(':', $boost_poller_status);
        if (!empty($status_array[1])) {
            $previous_start_time = strtotime($status_array[1]);
            /* if the runtime was exceeded, allow the next process to run */
            if ($previous_start_time + $max_run_duration < $start_time) {
                cacti_log('WARNING: Detected Poller Boost Overrun, Possible Boost Poller Crash', FALSE, 'BOOST SVR');
            }
        }
    }
    /* if the poller is not running, or has never run, start */
    /* mark the boost server as running */
    db_execute("REPLACE INTO settings (name, value) VALUES ('boost_poller_status', 'running - start time:" . date('Y-m-d G:i:s') . "')");
    $current_time = date('Y-m-d G:i:s', $start_time);
    $rrdtool_pipe = rrd_init();
    $rrdtool_read_pipe = rrd_init();
    $runtime_exceeded = false;
    /* let's set and track memory usage will we */
    if (!function_exists('memory_get_peak_usage')) {
        $get_memory = true;
        $memory_used = memory_get_usage();
    } else {
        $get_memory = false;
    }
    $delayed_inserts = db_fetch_row("SHOW STATUS LIKE 'Not_flushed_delayed_rows'");
    while ($delayed_inserts['Value']) {
        cacti_log('BOOST WAIT: Waiting 1s for delayed inserts are made', true, 'SYSTEM');
        usleep(1000000);
        $delayed_inserts = db_fetch_row("SHOW STATUS LIKE 'Not_flushed_delayed_rows'");
    }
    /* split poller_output_boost */
    $archive_table = 'poller_output_boost_arch_' . time();
    db_execute("RENAME TABLE poller_output_boost TO {$archive_table}");
    db_execute("CREATE TABLE poller_output_boost LIKE {$archive_table}");
    $more_arch_tables = db_fetch_assoc("SELECT table_name AS name\n\t\tFROM information_schema.tables\n\t\tWHERE table_schema=SCHEMA()\n\t\tAND table_name LIKE 'poller_output_boost_arch_%'\n\t\tAND table_name!='{$archive_table}'\n\t\tAND table_rows>0;");
    if (count($more_arch_tables)) {
        foreach ($more_arch_tables as $table) {
            $table_name = $table['name'];
            db_execute("INSERT INTO {$archive_table} SELECT * FROM {$table_name}");
            db_execute("TRUNCATE TABLE {$table_name}");
        }
    }
    if (!strlen($archive_table)) {
        cacti_log('ERROR: Failed to retrieve archive table name');
        return -1;
    }
    while (1) {
        $rows = db_fetch_cell("SELECT count(*) FROM {$archive_table}");
        if ($rows > 0) {
            $rrd_updates += boost_process_poller_output(FALSE, '', $current_time);
            if ($get_memory) {
                $cur_memory = memory_get_usage();
                if ($cur_memory > $memory_used) {
                    $memory_used = $cur_memory;
                }
            }
        } else {
            break;
        }
        if (time() - $start > $max_run_duration && !$runtime_exceeded) {
            cacti_log('WARNING: RRD On Demand Updater Exceeded Runtime Limits. Continuing to Process!!!');
            $runtime_exceeded = true;
        }
    }
    /* tell the main poller that we are done */
    db_execute("REPLACE INTO settings (name, value) VALUES ('boost_poller_status', 'complete - end time:" . date('Y-m-d G:i:s') . "')");
    /* log memory usage */
    if (function_exists('memory_get_peak_usage')) {
        db_execute("REPLACE INTO settings (name, value) VALUES ('boost_peak_memory', '" . memory_get_peak_usage() . "')");
    } else {
        db_execute("REPLACE INTO settings (name, value) VALUES ('boost_peak_memory', '" . $memory_used . "')");
    }
    rrd_close($rrdtool_pipe);
    rrd_close($rrdtool_read_pipe);
    /* cleanup  - remove empty arch tables */
    $tables = db_fetch_assoc("SELECT table_name AS name\n\t\tFROM information_schema.tables\n\t\tWHERE table_schema=SCHEMA()\n\t\tAND table_name LIKE 'poller_output_boost_arch_%'\n\t\tAND table_rows=0;");
    if (count($tables)) {
        foreach ($tables as $table) {
            db_execute('DROP TABLE ' . $table['name']);
        }
    }
    db_execute("SELECT RELEASE_LOCK('poller_boost');");
    return $rrd_updates;
}
开发者ID:MrWnn,项目名称:cacti,代码行数:99,代码来源:poller_boost.php

示例8:

				log_save(sprintf(_("Maximum Runtime of %i Seconds Exceeded for Poller id=%i - Exiting"), MAX_POLLER_RUNTIME, $poller_id), SEV_ERROR, FACIL_POLLER, "", $poller_id, 0, true);
				db_execute("update poller set run_state = 'Timeout' where poller_id=" . $poller_id);

				/* manage cacti syslog size */
				log_maintain(true);

				exit;
			}

			sleep(1);
		}
	}

	/* close RRDTool */
	if ($poller_id == 1) { rrd_close($rrdtool_pipe, $rrd_processes); }

	/* process poller commands */
	$command_string = read_config_option("path_php_binary");
	$extra_args = "-q " . CACTI_BASE_PATH . "/poller_commands.php";
	exec_background($command_string, "$extra_args");

	if ($poller_id == 1) {
		/* graph export */
		$command_string = read_config_option("path_php_binary");
		$extra_args = "-q " . CACTI_BASE_PATH . "/poller_export.php";
		exec_background($command_string, "$extra_args");

		/* i don't know why we are doing this */
		db_execute("truncate table poller_time");
开发者ID:songchin,项目名称:Cacti,代码行数:29,代码来源:poller.php


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