<?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图片
解决方案 »
- 100分 急!!!PHP显示postgresql数据库中bytea的图片
- 想下载MySQL-essential-5.0.45-win32.msi和php-5.2.4-Win32.zip
- 用thinkPHP开发时老是碰到session丢失的现象
- UCHome 短信群发
- uploadify 无法上传大文件问题
- eclipse设置工作路径权限不够,请大侠帮忙
- my sql 数据库迁移,只迁移指定条件的数据,怎么实现?急求!!!!
- 想将163博客搬家到csdn来,有工具推荐吗
- 正则表达式如何过滤HTML标签中的属性值?
- 微信公众平台,微信支付接口,curl错误代码58
- 请教下了解多迪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;
}
}