summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Wall <richard@largo>2010-08-29 19:02:34 +0100
committerRichard Wall <richard@largo>2010-08-29 19:02:34 +0100
commit24751968187f59cdbb45a17b37f188fc9e169c1c (patch)
treee21835ed674c80e0bf9ebbddc03ce2864a3b6ce2
parentbce8a067e4b37b36bade0ed1f1c5348553c6e822 (diff)
build an rrd file with simple / testable content
-rw-r--r--jarmonbuild/commands.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/jarmonbuild/commands.py b/jarmonbuild/commands.py
index c63848b..48e679b 100644
--- a/jarmonbuild/commands.py
+++ b/jarmonbuild/commands.py
@@ -8,6 +8,7 @@ import logging
import os
import shutil
import sys
+import time
from optparse import OptionParser
from subprocess import check_call, PIPE
@@ -217,18 +218,27 @@ class BuildTestDataCommand(BuildCommand):
command_name = 'testdata'
def main(self, argv):
+ """
+ Create an RRD file with values 0-9 entered at 1 second intervals from
+ 1980-01-01 00:00:00 (the first date that rrdtool allows)
+ """
+ from datetime import datetime
from pyrrd.rrd import DataSource, RRA, RRD
-
+ start = int(datetime(1980, 1, 1, 0, 0).strftime('%s'))
dss = []
rras = []
- filename = '/tmp/test.rrd'
- dss.append(DataSource(dsName='speed', dsType='COUNTER', heartbeat=600))
- rras.append(RRA(cf='AVERAGE', xff=0.5, steps=1, rows=24))
- rras.append(RRA(cf='AVERAGE', xff=0.5, steps=6, rows=10))
- my_rrd = RRD(filename, ds=dss, rra=rras, start=0)
+ filename = os.path.join(self.build_dir, 'test.rrd')
+
+ rows = 10
+
+ dss.append(DataSource(dsName='speed', dsType='GAUGE', heartbeat=1))
+ rras.append(RRA(cf='AVERAGE', xff=0.5, steps=1, rows=rows))
+ my_rrd = RRD(filename, ds=dss, rra=rras, start=start, step=1)
my_rrd.create()
- my_rrd.bufferValue(1, '12363')
- my_rrd.bufferValue(2, '12363')
+
+ for i, t in enumerate(range(start, start+rows, 1)):
+ my_rrd.bufferValue(t+1, i)
+
my_rrd.update()