Re: create-update-fetch

Info <[email protected]>
Newsgroups gmane.comp.db.rrdtool.devel
Message-ID <[email protected]>
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
> [email protected]
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers

_______________________________________________
rrd-developers mailing list
[email protected]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers
PGP.sig (application/pgp-signature, 188 B) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.