<?php
$fd=popen("/usr/local/rrdtool/bin/rrdtool - ","w");
if(!$fd){
print("cannot open");
return;
}
$start=1245000000;
$end=1245500000;
$t="--start $start --end $end";
$def="DEF:t1=\"sample.rrd\":item1:AVERAGE DEF:t2=sample.rrd:item2:AVERAGE";
$line="LINE1:t1#00ff00 LINE2:t2#330088";
$command="$t $def $line\r\n";$i=0;
while(1){
if(fwrite($fd," graph - ".$command)==false){
fclose($fd);
$fd=popen("/usr/local/rrdtool/bin/rrdtool - ","w");
if($i>4){
print("cannot write");
return;
}else{
$i++;
}
continue;
}else{
fflush($fd); break;
}
}
if(isset($fd)){
print fpassthru($fd);
exit;
}
?>
图片出不来???
第二行改成$fd=popen("/usr/local/rrdtool/bin/rrdtool - >1.png","w");可以生成1.png图片
$fd=popen("/usr/local/rrdtool/bin/rrdtool - ","w");
if(!$fd){
print("cannot open");
return;
}
$start=1245000000;
$end=1245500000;
$t="--start $start --end $end";
$def="DEF:t1=\"sample.rrd\":item1:AVERAGE DEF:t2=sample.rrd:item2:AVERAGE";
$line="LINE1:t1#00ff00 LINE2:t2#330088";
$command="$t $def $line\r\n";$i=0;
while(1){
if(fwrite($fd," graph - ".$command)==false){
fclose($fd);
$fd=popen("/usr/local/rrdtool/bin/rrdtool - ","w");
if($i>4){
print("cannot write");
return;
}else{
$i++;
}
continue;
}else{
fflush($fd); break;
}
}
if(isset($fd)){
print fpassthru($fd);
exit;
}
?>
图片出不来???
第二行改成$fd=popen("/usr/local/rrdtool/bin/rrdtool - >1.png","w");可以生成1.png图片
解决方案 »
- MySQL有分区工具吗?
- 大家帮我看下接这个网站系统要多少钱?(好象有点复杂)
- 求助贴
- php 飞信接口怎么不能用了
- SunGavin Joomla:Google浏览器中显示正常,IE浏览器中显示不正常,怀疑是<jdoc:include 的问题,求大侠指点
- 织梦二次开发,标签扩展问题。我在开发新的标签。关于dedetag.class.php 静态模板类的使用的问题。
- php取经人,我写了个代码怎么不能实现啊?大家帮忙!
- php乱码怎么解决
- 帮我看下这段代码 主要问题是数字重复
- 求把汉字转成字符组成的源码,可有现成的,或多少钱?
- 请教下了解多迪php培训机构的朋友,这家培训机构的名声怎样?
- 求一个iis下的rewrite规则
而且print fpassthru($fd);输出0,
不知道该怎么写,高手?????
while(1){
if(fwrite($fd," graph - ".$command)==false){
fclose($fd);
$fd=popen("/usr/local/rrdtool/bin/rrdtool - ","w");
if($i>4){
print("cannot write");
return;
}else{
$i++;
}
没看明白这写的什么东西,支持一下,顶上去
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) && (!isset($rrd_struc["fd"]) || (sizeof($rrd_struc["fd"]) == 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 (!isset($rrd_struc["fd"]) || (sizeof($rrd_struc["fd"]) == 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 (!isset($rrd_struc["fd"]) || (sizeof($rrd_struc["fd"]) == 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)) {
$line = "";
while (!feof($fp)) {
$line .= fgets($fp, 4096);
} return $line;
} break;
case RRDTOOL_OUTPUT_STDERR:
if (isset($fp)) {
$output = fgets($fp, 1000000); 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)) {
return fpassthru($fp);
} break;
}
}