将两个图相加,当第二个RRD文件现在才启动时
我不知道如何解释我的问题......但是 我有两个 RRD 文件:
a.rrd
b.rrd
我正在尝试对这两个文件求和并将它们堆叠在图中。 像:
my $bla = RRDs::graph "-",
"--title","Test",
"--imgformat=PNG",
"--width=680",
"--height=200",
"DEF:Default0_=a.rrd:default:AVERAGE",
"DEF:Real0_=a.rrd:real:AVERAGE",
"DEF:Default1_=b.rrd:default:AVERAGE",
"DEF:Real1_=b.rrd:real:AVERAGE",
"CDEF:Default=Default0_,Default1_,+",
"CDEF:Real=Real0_,Real1_,+",
'AREA:Default#00CF00:Default Test',
'GPRINT:Default:MIN:Min\: %10.0lf%s',
'GPRINT:Default:MAX:Max\: %10.0lf%s',
'GPRINT:Default:AVERAGE:Average\: %10.0lf%s',
'GPRINT:Default:LAST:Current\: %10.0lf%s \l',
'STACK:Real#006699:Real Test',
'LINE2:Real#000000',
'GPRINT:Real:MIN:Min\: %10.0lf%s',
'GPRINT:Real:MAX:Max\: %10.0lf%s',
'GPRINT:Real:AVERAGE:Average\: %10.0lf%s',
'GPRINT:Real:LAST:Current\: %10.0lf%s \l',
我的结果是:
alt text http://www.freeimagehosting.net/uploads/8d99a4a675 .jpg
问题:它不打印文件 a.rrd 中的值,它仅显示 b.rrd 文件位置的图形。
里面有这样的内容(只有第一部分带有零):
alt text http:// www.freeimagehosting.net/uploads/e036f93797.jpg
显然,这是因为第二个图没有 unix 时间戳,而第一个图有。
那么我怎样才能用零填充它呢?或更改我的图表配置?
I don't know how to explain my problem.... but
I have two RRD files:
a.rrd
b.rrd
I'm trying to sum both of the files and STACK them up in the graph.
like:
my $bla = RRDs::graph "-",
"--title","Test",
"--imgformat=PNG",
"--width=680",
"--height=200",
"DEF:Default0_=a.rrd:default:AVERAGE",
"DEF:Real0_=a.rrd:real:AVERAGE",
"DEF:Default1_=b.rrd:default:AVERAGE",
"DEF:Real1_=b.rrd:real:AVERAGE",
"CDEF:Default=Default0_,Default1_,+",
"CDEF:Real=Real0_,Real1_,+",
'AREA:Default#00CF00:Default Test',
'GPRINT:Default:MIN:Min\: %10.0lf%s',
'GPRINT:Default:MAX:Max\: %10.0lf%s',
'GPRINT:Default:AVERAGE:Average\: %10.0lf%s',
'GPRINT:Default:LAST:Current\: %10.0lf%s \l',
'STACK:Real#006699:Real Test',
'LINE2:Real#000000',
'GPRINT:Real:MIN:Min\: %10.0lf%s',
'GPRINT:Real:MAX:Max\: %10.0lf%s',
'GPRINT:Real:AVERAGE:Average\: %10.0lf%s',
'GPRINT:Real:LAST:Current\: %10.0lf%s \l',
And my Result is:
alt text http://www.freeimagehosting.net/uploads/8d99a4a675.jpg
problem: it doesn't print the values from file a.rrd, it display the graph only from the position of the b.rrd file.
instide of something like this ( only the first part will be with zeros ):
alt text http://www.freeimagehosting.net/uploads/e036f93797.jpg
Obviously, this is because the second graph doesn't have unix timestamp when the first graph does.
so how can i fill it with zeros ? or change my graph conf ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是您问题的解决方案:)
http://oss.oetiker.ch/rrdtool/tut/cdeftutorial.en。 html
看看IF、TIME、GT等函数的使用。
你可以试试这个:
CDEF:Real=TIME,某个时间戳,GT,Real0_,Real0_,UN,0,Real0_,IF,IF,TIME,某个时间戳,GT,Real1_,Real1_,UN,0,Real1_,IF,IF,+
这意味着:
if( TIME() > 有时戳 )
返回真实0_
else if (Real0_ == UN(这是rrd文件中的NaN值) )
返回0
别的
返回真实0_
对 Real1_ 进行同样的操作,并将两个结果相加。
希望我有帮助:)
Here is the solution to your problem :)
http://oss.oetiker.ch/rrdtool/tut/cdeftutorial.en.html
Take a look at the use of IF,TIME,GT and etc. functions.
You can try this:
CDEF:Real=TIME,sometimestamp,GT,Real0_,Real0_,UN,0,Real0_,IF,IF,TIME,sometimestamp,GT,Real1_,Real1_,UN,0,Real1_,IF,IF,+
This means:
if( TIME() > sometimestamp )
return Real0_
else if (Real0_ == UN(this is the NaN value in rrd files) )
return 0
else
return Real0_
Make the same thing for the Real1_ and make the sum of the two result.
Hope I helped :)