rrdtool.update() in Python

View: New views
8 Messages — Rating Filter:   Alert me  

rrdtool.update() in Python

by echouin12 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

So I've been working  on the python binding for rrdtool and after
encountering some problems I went back to the basics, and used the
example given in the tutorial to try to find what's wrong.

I've followed the step by step directions in Alex van den Bogaerdt's
RRDtool tutorial in the speed example and have translated it into python
but the rrdtool.update command is giving my some slack. I followed the
example but python gives me syntax errors that I can't resolve. If
anyone familiar with the rrdtool python binding could give a clue as to
what's going on I would really appreciate it.  Here's my code, I cut and
pasted it from the website, but I get this error when I run the code
File "redo.py", line 11
    rrdtool.update('test.rrd',920804700:12345)
    ^
SyntaxError: invalid syntax


import rrdtool
import os
import time

rrdtool.create('test.rrd',
    '--start', 920804400,
    'DS:speed:COUNTER:600:U:U',
    'RRA:AVERAGE:0.5:1:24 ',
    'RRA:AVERAGE:0.5:6:10')
           
 rrdtool.update('test.rrd', 920804700:12345, 920805000:12357,
920805300:12363)
 rrdtool.update('test.rrd', 920805600:12363, 920805900:12363,
920806200:12373)
 rrdtool.update('test.rrd', 920806500:12383, 920806800:12393,
920807100:12399)
 rrdtool.update('test.rrd', 920807400:12405, 920807700:12411,
920808000:12415)
 rrdtool.update('test.rrd', 920808300:12420, 920808600:12422,
920808900:12423)

 rrdtool.graph('test.png',                                
         '--start', 920804400
         '--end', 920808000,            
         'DEF:myspeed=test.rrd:speed:AVERAGE',            
         'LINE2:myspeed#FF0000')


I really appreciate the help!!

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

Parent Message unknown rrdtool.update() in Python-HELP

by echouin12 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Does anyone even use the python binding for rrdtool?? I've been stuck on
this for days, I think it has something to do with python interpreting
the update() properly but I've covered all my bases and I am still
coming up empty. Anyone, the developers of this binding???, someone
please take a look at my code and let me know how to update() an RRD
using the python binding, because I can do it through rrdtool alone but
my supervisor wants to use python.

>
> Any help is greatly appreciated!! Thanks
>
> Emily Chouinard wrote:
>> So I've been working  on the python binding for rrdtool and after
>> encountering some problems I went back to the basics, and used the
>> example given in the tutorial to try to find what's wrong.
>>
>> I've followed the step by step directions in Alex van den Bogaerdt's
>> RRDtool tutorial in the speed example and have translated it into
>> python but the rrdtool.update command is giving my some slack. I
>> followed the example but python gives me syntax errors that I can't
>> resolve. If anyone familiar with the rrdtool python binding could
>> give a clue as to what's going on I would really appreciate it.  
>> Here's my code, I cut and pasted it from the website, but I get this
>> error when I run the code
>> File "redo.py", line 11
>>    rrdtool.update('test.rrd',920804700:12345)
>>    ^
>> SyntaxError: invalid syntax
>>
>>
>> import rrdtool
>> import os
>> import time
>>
>> rrdtool.create('test.rrd',
>>    '--start', 920804400,
>>    'DS:speed:COUNTER:600:U:U',
>>    'RRA:AVERAGE:0.5:1:24 ',
>>    'RRA:AVERAGE:0.5:6:10')
>>            rrdtool.update('test.rrd', 920804700:12345,
>> 920805000:12357, 920805300:12363)
>> rrdtool.update('test.rrd', 920805600:12363, 920805900:12363,
>> 920806200:12373)
>> rrdtool.update('test.rrd', 920806500:12383, 920806800:12393,
>> 920807100:12399)
>> rrdtool.update('test.rrd', 920807400:12405, 920807700:12411,
>> 920808000:12415)
>> rrdtool.update('test.rrd', 920808300:12420, 920808600:12422,
>> 920808900:12423)
>>
>> rrdtool.graph('test.png',                                        
>> '--start', 920804400
>>         '--end', 920808000,                    
>> 'DEF:myspeed=test.rrd:speed:AVERAGE',                    
>> 'LINE2:myspeed#FF0000')
>>
>>
>> I really appreciate the help!!
>>
>
>
>

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

Re: rrdtool.update() in Python-HELP

by Alex van den Bogaerdt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Jun 25, 2008 at 08:51:04AM -0400, Emily Chouinard wrote:
> Does anyone even use the python binding for rrdtool?? I've been stuck on
> this for days, I think it has something to do with python interpreting
> the update() properly but I've covered all my bases and I am still
> coming up empty. Anyone, the developers of this binding???, someone
> please take a look at my code and let me know how to update() an RRD
> using the python binding, because I can do it through rrdtool alone but
> my supervisor wants to use python.


google for "rrdtool python update" and get 184,000 hits.

Not all of them will be useful, but it should contain some examples.

--
Alex van den Bogaerdt
http://www.vandenbogaerdt.nl/rrdtool/

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

Re: rrdtool.update() in Python-HELP

by Bernard Li-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Emily:

On Wed, Jun 25, 2008 at 7:28 AM, Alex van den Bogaerdt
<alex@...> wrote:

> google for "rrdtool python update" and get 184,000 hits.
>
> Not all of them will be useful, but it should contain some examples.

And I can confirm that the Python bindings do work -- I have tested
rrdtool 1.2.23 and even 1.3.0.

Cheers,

Bernard

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

Parent Message unknown Re: rrdtool.update() in Python-HELP

by Yiannis Vavouranakis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



> Does anyone even use the python binding for rrdtool??

I've been using it successfully for the past couple of months or so...

>> File "redo.py", line 11
>>    rrdtool.update('test.rrd',920804700:12345)
>>    ^
>> SyntaxError: invalid syntax
>>
>>
>> import rrdtool
>> import os
>> import time
>>
>> rrdtool.create('test.rrd',
>>    '--start', 920804400,
>>    'DS:speed:COUNTER:600:U:U',
>>    'RRA:AVERAGE:0.5:1:24 ',
>>    'RRA:AVERAGE:0.5:6:10')
>>            rrdtool.update('test.rrd', 920804700:12345,
>> 920805000:12357, 920805300:12363)
>> rrdtool.update('test.rrd', 920805600:12363, 920805900:12363,
>> 920806200:12373)
>> rrdtool.update('test.rrd', 920806500:12383, 920806800:12393,
>> 920807100:12399)
>> rrdtool.update('test.rrd', 920807400:12405, 920807700:12411,
>> 920808000:12415)
>> rrdtool.update('test.rrd', 920808300:12420, 920808600:12422,
>> 920808900:12423)
>>
>> rrdtool.graph('test.png',                                        
>> '--start', 920804400
>>         '--end', 920808000,                    
>> 'DEF:myspeed=test.rrd:speed:AVERAGE',                    
>> 'LINE2:myspeed#FF0000')
>>

Is it me, or you've indented the first update()?

Also, since python is an interpreted language that comes with an interactive
shell, have you tried feeding each line individually to the interpreter?

Regards,
Yiannis Vavouranakis


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

Parent Message unknown Re: rrdtool.update() in Python-HELP

by Yiannis Vavouranakis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Update on the python-rrdtool issue:

It seems that my version (at least) of the python bindings requires that ALL
arguments are strings. So this

<snip>
rrdtool.update('test.rrd', 920804700:12345, 920805000:12357,
920805300:12363)
</snip>

Will not work (for a number of reasons, one being that ":"  signifies
name-value pairs in dictionaries). Instead, this

<snip>
rrdtool.update('test.rrd', '920804700:12345', '920805000:12357',
'920805300:12363')
</snip>

Will work like a charm. So taking the script you posted, and turning
everything into strings, I get a working script (I also deleted that extra
indent I was talking about):

<snip>

import rrdtool, os, time
rrdtool.create('test.rrd','--start', '920804400',
               'DS:speed:COUNTER:600:U:U',
               'RRA:AVERAGE:0.5:1:24',
               'RRA:AVERAGE:0.5:6:10')
rrdtool.update('test.rrd', '920804700:12345',
               '920805000:12357', '920805300:12363')
rrdtool.update('test.rrd', '920805600:12363',
               '920805900:12363', '920806200:12373')
rrdtool.update('test.rrd', '920806500:12383',
               '920806800:12393', '920807100:12399')
rrdtool.update('test.rrd', '920807400:12405',
               '920807700:12411', '920808000:12415')
rrdtool.update('test.rrd', '920808300:12420',
               '920808600:12422', '920808900:12423')
rrdtool.graph('test.png','--start', '920804400',
              '--end', '920808000',
              'DEF:myspeed=test.rrd:speed:AVERAGE',
              'LINE2:myspeed#FF0000')

</snip>
This produced a pretty nice step graph on my machine. As a sidenote, I kept
all your imports, although you're not using anything from os or time
anywhere in the script you posted.

Hope that helped.

Yiannis Vavouranakis

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

Re: rrdtool.update() in Python-HELP

by echouin12 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks everyone for your help!


Bernard Li wrote:

> Hi Emily:
>
> On Wed, Jun 25, 2008 at 7:28 AM, Alex van den Bogaerdt
> <alex@...> wrote:
>
>  
>> google for "rrdtool python update" and get 184,000 hits.
>>
>> Not all of them will be useful, but it should contain some examples.
>>    
>
> And I can confirm that the Python bindings do work -- I have tested
> rrdtool 1.2.23 and even 1.3.0.
>
> Cheers,
>
> Bernard
>
> _______________________________________________
> rrd-users mailing list
> rrd-users@...
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
>
>
>  

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

Parent Message unknown Re: rrdtool.update() in Python

by echouin12 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks, I got it all figured out now, just trying to apply these ideas
to my project!

Korthrun wrote:

> On Tue, Jun 24, 2008 at 11:33 AM, Emily Chouinard <cousin17@...> wrote:
>  
>> So I've been working  on the python binding for rrdtool and after
>> encountering some problems I went back to the basics, and used the
>> example given in the tutorial to try to find what's wrong.
>>
>> I've followed the step by step directions in Alex van den Bogaerdt's
>> RRDtool tutorial in the speed example and have translated it into python
>> but the rrdtool.update command is giving my some slack. I followed the
>> example but python gives me syntax errors that I can't resolve. If
>> anyone familiar with the rrdtool python binding could give a clue as to
>> what's going on I would really appreciate it.  Here's my code, I cut and
>> pasted it from the website, but I get this error when I run the code
>> File "redo.py", line 11
>>    rrdtool.update('test.rrd',920804700:12345)
>>    ^
>> SyntaxError: invalid syntax
>>
>>
>> import rrdtool
>> import os
>> import time
>>
>> rrdtool.create('test.rrd',
>>    '--start', 920804400,
>>    'DS:speed:COUNTER:600:U:U',
>>    'RRA:AVERAGE:0.5:1:24 ',
>>    'RRA:AVERAGE:0.5:6:10')
>>
>>  rrdtool.update('test.rrd', 920804700:12345, 920805000:12357,
>> 920805300:12363)
>>  rrdtool.update('test.rrd', 920805600:12363, 920805900:12363,
>> 920806200:12373)
>>  rrdtool.update('test.rrd', 920806500:12383, 920806800:12393,
>> 920807100:12399)
>>  rrdtool.update('test.rrd', 920807400:12405, 920807700:12411,
>> 920808000:12415)
>>  rrdtool.update('test.rrd', 920808300:12420, 920808600:12422,
>> 920808900:12423)
>>
>>  rrdtool.graph('test.png',
>>         '--start', 920804400
>>         '--end', 920808000,
>>         'DEF:myspeed=test.rrd:speed:AVERAGE',
>>         'LINE2:myspeed#FF0000')
>>
>>
>> I really appreciate the help!!
>>
>> _______________________________________________
>> rrd-users mailing list
>> rrd-users@...
>> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
>>
>>    
> rrdtool.update('test.rrd', 920804700:12345, 920805000:12357, 920805300:12363)
> With those values unquoted, python is going to try to treat them as
> python directives of some sort.
> If you quote them this script will run fine.
> Well I didn't test the graph part.
> Don't forget to quote what you're passing to --start in your create().
>
> rrdtool.update('test.rrd', '920804700:12345', '920805000:12357',
> '920805300:12363')
>
>
>  

_______________________________________________
rrd-users mailing list
rrd-users@...
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
LightInTheBox - Buy quality products at wholesale price