[rrd-developers] create-update-fetch

Info info at daleenterprise.com
Tue Mar 29 04:11:17 CEST 2011


Try placing your "l = l + 1;" statement after the rrdtool.fetch()  
statment since you're actually not fetching 0 when you get there.

On Mar 23, 2011, at 02:34 AM, Oxana Lazareva wrote:

> Hello!
>
>
>
> I’m learning RRDTool,
>
> I created this trivial example (by Python),
>
> but I have a problem.
>
> I created ‘target.rrd’, I put 10 value in this rrd, but then I’m  
> doing ‘fetch’ I’m getting only 9 value. Why?
>
>
>
> #!/usr/bin/env python
>
> import Globals
>
> from Products.ZenUtils.ZenScriptBase import ZenScriptBase
>
> from transaction import commit
>
>
>
> dmd = ZenScriptBase(connect=True, noopts=True).dmd
>
>
>
> from Products.ZenUtils import Time
>
> import re
>
> import sys
>
> import rrdtool, tempfile
>
> import time
>
> import inspect
>
> from optparse import OptionParser
>
> import random
>
> parser = OptionParser()
>
>
>
> ret = rrdtool.create ('target.rrd',
>
>         '--start', '1300665600',
>
>         '--step', '60',
>
>         'DS:mem: GAUGE:600:0:671744',
>
>         'DS:mem1:GAUGE:600:0:671744',
>
>
>
>         'RRA:AVERAGE:0.5:1:600',
>
>         'RRA:AVERAGE:0.5:5:700')
>
> print ret
>
> if ret:
>
>     print rrdtool.error()
>
> n = 1300888800
>
> l = 0
>
> input = 0
>
> output = 0
>
>
>
> while l < 10:
>
>     input = random.randrange(1000,1500)
>
>
>
>     output += random.randrange(1000, 1500)
>
>
>
>     ret=rrdtool.update('target.rrd',str(n) + ':' + str(input) + ':'  
> + str (output));
>
>     print str(input) + '; ' + str(output)
>
>
>
>     if ret:
>
>         print rrdtool.error()
>
>     l = l + 1
>
>     n = n + 300
>
> info = rrdtool.info('target.rrd')
>
>
>
> print info['last_update']
>
>
>
> print info ['ds[mem].minimal_heartbeat']
>
> print rrdtool.fetch ('target.rrd', 'AVERAGE',
>
>                      '--resolution', '1',
>
>                      '--start', '1300795600',
>
>                      '--end', '1300924800')
>
>
>
> RESULTS:
>
> (None, None)
>
> (None, None)
>
> (1195.0, 2093.0)
>
> (1252.0, 3244.0)
>
> (1181.0, 4720.0)
>
> (1084.0, 5914.0)
>
> (1065.0, 7007.0)
>
> (1359.0, 8499.0)
>
> (1045.0, 9538.0)
>
> (1045.0, 10793.0)
>
> (1170.0, 11795.0)
>
> (None, None)
>
> (None, None)
>
>
>
> Oxana Lazareva
>
>
>
> SITRONICS Telecom Solutions, Czech Republic a. s.
>
> Ohradní 1369/8
> 140 00  Praha 4, Czech Republic
>
>
>
> _______________________________________________
> rrd-developers mailing list
> rrd-developers at lists.oetiker.ch
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.oetiker.ch/pipermail/rrd-developers/attachments/20110328/f1442d70/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 188 bytes
Desc: This is a digitally signed message part
Url : http://lists.oetiker.ch/pipermail/rrd-developers/attachments/20110328/f1442d70/attachment-0001.pgp 


More information about the rrd-developers mailing list