[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rrd-developers
Subject:    Re: [rrd-developers] create-update-fetch
From:       Info <info () daleenterprise ! com>
Date:       2011-03-29 2:11:17
Message-ID: F49D5056-9032-414A-A06B-25B5852F55FE () daleenterprise ! com
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/alternative)]


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@lists.oetiker.ch
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers


[Attachment #7 (unknown)]

<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; \
-webkit-line-break: after-white-space; ">Try placing your "l = l + 1;" statement \
after the rrdtool.fetch() statment since you're actually not fetching 0 when you get \
there.<div><br><div><div>On Mar 23, 2011, at 02:34 AM, Oxana Lazareva wrote:</div><br \
class="Apple-interchange-newline"><blockquote type="cite"><div \
class="WordSection1"><p class="MsoNormal"><span \
lang="CS">Hello</span>!<o:p></o:p></p><p class="MsoNormal"><o:p> </o:p></p><p \
class="MsoNormal">I’m learning RRDTool, <o:p></o:p></p><p class="MsoNormal">I created \
this trivial example (by Python),<o:p></o:p></p><p class="MsoNormal">but I have a \
problem.<o:p></o:p></p><p class="MsoNormal">I created ‘target.rrd’, I put 10 value in \
this rrd, but then I’m doing ‘fetch’ I’m getting only 9 value. Why?<o:p></o:p></p><p \
class="MsoNormal"><o:p> </o:p></p><p class="MsoNormal">#!/usr/bin/env \
python<o:p></o:p></p><p class="MsoNormal">import Globals<o:p></o:p></p><p \
class="MsoNormal">from Products.ZenUtils.ZenScriptBase import \
ZenScriptBase<o:p></o:p></p><p class="MsoNormal">from transaction import \
commit<o:p></o:p></p><p class="MsoNormal"><o:p> </o:p></p><p class="MsoNormal">dmd = \
ZenScriptBase(connect=True, noopts=True).dmd<o:p></o:p></p><p class="MsoNormal"><o:p> \
</o:p></p><p class="MsoNormal">from Products.ZenUtils import Time<o:p></o:p></p><p \
class="MsoNormal">import re<o:p></o:p></p><p class="MsoNormal">import \
sys<o:p></o:p></p><p class="MsoNormal">import rrdtool, tempfile<o:p></o:p></p><p \
class="MsoNormal">import time<o:p></o:p></p><p class="MsoNormal">import \
inspect<o:p></o:p></p><p class="MsoNormal">from optparse import \
OptionParser<o:p></o:p></p><p class="MsoNormal">import random<o:p></o:p></p><p \
class="MsoNormal">parser = OptionParser()<o:p></o:p></p><p class="MsoNormal"><o:p> \
</o:p></p><p class="MsoNormal">ret = rrdtool.create ('target.rrd',<o:p></o:p></p><p \
class="MsoNormal">        '--start', '1300665600',<o:p></o:p></p><p \
class="MsoNormal">        '--step', '60',<o:p></o:p></p><p class="MsoNormal">        \
'DS:mem: GAUGE:600:0:671744',<o:p></o:p></p><p class="MsoNormal">        \
'DS:mem1:GAUGE:600:0:671744',<o:p></o:p></p><p class="MsoNormal"><o:p> </o:p></p><p \
class="MsoNormal">        'RRA:AVERAGE:0.5:1:600',<o:p></o:p></p><p \
class="MsoNormal">        'RRA:AVERAGE:0.5:5:700')<o:p></o:p></p><p \
class="MsoNormal">print ret<o:p></o:p></p><p class="MsoNormal">if \
ret:<o:p></o:p></p><p class="MsoNormal">    print rrdtool.error()<o:p></o:p></p><p \
class="MsoNormal">n = 1300888800<o:p></o:p></p><p class="MsoNormal">l = \
0<o:p></o:p></p><p class="MsoNormal">input = 0<o:p></o:p></p><p \
class="MsoNormal">output = 0<o:p></o:p></p><p class="MsoNormal"><o:p> </o:p></p><p \
class="MsoNormal">while l &lt; 10:<o:p></o:p></p><p class="MsoNormal">    input = \
random.randrange(1000,1500)<o:p></o:p></p><p class="MsoNormal"><o:p> </o:p></p><p \
class="MsoNormal">    output += random.randrange(1000, 1500)<o:p></o:p></p><p \
class="MsoNormal"><o:p> </o:p></p><p class="MsoNormal">    \
ret=rrdtool.update('target.rrd',str(n) + ':' + str(input) + ':' + str \
(output));<o:p></o:p></p><p class="MsoNormal">    print str(input) + '; ' + \
str(output)<o:p></o:p></p><p class="MsoNormal"><o:p> </o:p></p><p class="MsoNormal">  \
if ret:<o:p></o:p></p><p class="MsoNormal">        print \
rrdtool.error()<o:p></o:p></p><p class="MsoNormal">    l = l + 1<o:p></o:p></p><p \
class="MsoNormal">    n = n + 300<o:p></o:p></p><p class="MsoNormal">info = \
rrdtool.info('target.rrd')<o:p></o:p></p><p class="MsoNormal"><o:p> </o:p></p><p \
class="MsoNormal">print info['last_update']<o:p></o:p></p><p class="MsoNormal"><o:p> \
</o:p></p><p class="MsoNormal">print info \
['ds[mem].minimal_heartbeat']<o:p></o:p></p><p class="MsoNormal">print rrdtool.fetch \
('target.rrd', 'AVERAGE',<o:p></o:p></p><p class="MsoNormal">                     \
'--resolution', '1',<o:p></o:p></p><p class="MsoNormal">                     \
'--start', '1300795600',<o:p></o:p></p><p class="MsoNormal">                     \
'--end', '1300924800')<o:p></o:p></p><p class="MsoNormal"><o:p> </o:p></p><p \
class="MsoNormal">RESULTS:<o:p></o:p></p><p class="MsoNormal">(None, \
None)<o:p></o:p></p><p class="MsoNormal">(None, None)<o:p></o:p></p><p \
class="MsoNormal">(1195.0, 2093.0)<o:p></o:p></p><p class="MsoNormal">(1252.0, \
3244.0)<o:p></o:p></p><p class="MsoNormal">(1181.0, 4720.0)<o:p></o:p></p><p \
class="MsoNormal">(1084.0, 5914.0)<o:p></o:p></p><p class="MsoNormal">(1065.0, \
7007.0)<o:p></o:p></p><p class="MsoNormal">(1359.0, 8499.0)<o:p></o:p></p><p \
class="MsoNormal">(1045.0, 9538.0)<o:p></o:p></p><p class="MsoNormal">(1045.0, \
10793.0)<o:p></o:p></p><p class="MsoNormal">(1170.0, 11795.0)<o:p></o:p></p><p \
class="MsoNormal">(None, None)<o:p></o:p></p><p class="MsoNormal">(None, \
None)<o:p></o:p></p><p class="MsoNormal"><o:p> </o:p></p><p \
class="MsoNormal"><b><span lang="CS" \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">Oxana \
Lazareva<o:p></o:p></span></b></p><p class="MsoNormal"><span lang="CS" \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><o:p> \
</o:p></span></p><p class="MsoNormal"><span lang="CS" \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">SITRONICS \
Telecom Solutions, Czech Republic a. s.<o:p></o:p></span></p><p \
class="MsoNormal"><span lang="CS" \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">Ohradní \
1369/8<br>140 00  Praha 4, Czech Republic<o:p></o:p></span></p><p \
class="MsoNormal"><o:p> </o:p></p></div><div style="margin-top: 0px; margin-right: \
0px; margin-bottom: 0px; margin-left: 0px; \
">_______________________________________________</div><div style="margin-top: 0px; \
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">rrd-developers mailing \
list</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; \
margin-left: 0px; "><a \
href="mailto:rrd-developers@lists.oetiker.ch">rrd-developers@lists.oetiker.ch</a></div><div \
style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><a \
href="https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers">https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers</a></div> \
</blockquote></div><br></div></body></html>


["PGP.sig" (application/pgp-signature)]

_______________________________________________
rrd-developers mailing list
rrd-developers@lists.oetiker.ch
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic