【概要】
今天接到一个需求,要绘制cacti监控的地图,最好是不用输入帐号密码就可以直接看cacti图。根据这个需求,对cacti研究了下,发现cacti没有这个功能,所以又需要修改其源码来实现。废话不多说了,看实现方法吧。
【实现方法】
在cacti安装目录下新建一个view_image.php文件,写入如下代码:
< ?php ob_start(); ?>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
< ?php
if(empty($_REQUEST["key"])) die(':) missing key');
if($_REQUEST["key"] != 'xupeng') die(':) error key');
$guest_account = true;
include_once("./lib/rrd.php");
include("./include/global.php");
header("Content-type: image/png");
/* flush the headers now */
ob_end_clean();
session_write_close();
$graph_data_array = array();
print @rrdtool_function_graph($_GET["local_graph_id"], (array_key_exists("rra_id", $_GET) ? $_GET["rra_id"] : null), $graph_data_array);
?> |
访问方法:http://ip/view_image.php?action=view&local_graph_id=3&rra_id=2&key=xupeng


![[转]常见的nginx的配置选项](http://www.jiunile.com/wp-content/themes/xupeng/images/random/6.jpg)






My partner and I really enjoyed reading this blog post, I was just itching to know do you trade featured posts? I am always trying to find someone to make trades with and merely thought I would ask.
OK,I’d love to and what can i do for you ??
我发现你这个php不好用啊
你需要调试下。。。
可否请教,要如何的调整呢?
我不是提供代码了吗?
你好,我照您的方法做了之后,在 ie 出现的画面,就是这些代码,所以,我才想说,是不是有那些要调试的,我没做,才会变成直接出现这个 php source code….谢谢回答!
额。。不会啊~你把我提供的代码放在cacti目录下,然后用浏览器访问输入账号和密码就可以访问到了~