我使用rrdtool python扩展来保存rrd中的数据:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationVariants.all { variant ->
if (!variant.buildType.isDebuggable()) {
variant.outputs.each { output ->
def apk = output.outputFile;
def newName = "app-release-" + getDate() + ".apk";
output.outputFile = new File(apk.parentFile, newName);
}
}
}
}
}
循环工作4次,我想获得4分。但我只得到3:
## Creating db.
rrdtool.create(rrd_file,
'--step', '2',
'DS:%s:GAUGE:4:U:U' % DSNAME,
'RRA:AVERAGE:0,5:1:288',
)
value = 23
for i in range(4):
rrdtool.update('/home/way/workspace/RrdDaemon/test', "%s:%s" % (datetime_2_sec(str(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))), str(value)))
sleep(2)
我试图改变心跳,步骤,xff - 没有什么可以帮助我。现在我尝试1次迭代:
1460382646: -nan
1460382648: 2,3000000000e+01
1460382650: 2,3000000000e+01
1460382652: 2,3000000000e+01
1460382654: -nan
时间戳:1460385371
结果:
for i in range(1):
rrdtool.update('/home/way/workspace/RrdDaemon/test', "%s:%s" % (datetime_2_sec(str(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))), str(value)))
sudo rrdtool info test:
1460385368: -nan
1460385370: -nan
1460385372: -nan
我做错了什么或rrd工作的方式? 谢谢。
答案 0 :(得分:0)
您遇到的问题是您正在从未知状态进入已知状态。 minimal_heartbeat定义了两次更新之间允许的最大间隔,以便rrdtool考虑更新之间包含有效数据的时间。
这也意味着在一段未知数据之后的第一次更新仅用于指示再次知道数据的时间......下一次更新(在minimal_heartbeat定义的时间间隔内)。