Tobi, I think you must be correct. I rewrote the Python script in C (using system(3)), and I don't have the problem anymore. Thanks.
-David On Sat, Jan 15, 2011 at 5:43 AM, Tobias Oetiker <[email protected]> wrote: > Hi David, > > my guess is that python is not blocking for the run_cmd to complete > ... and thus it is possible that the os executes the rrdtool > instances 'not in order' > > cheers > tobi > > Thursday David Eisner wrote: > >> In an effort to grok rrdtool I've written a little python script [1] >> that calls rrdtool update to generate some synthetic data. >> >> However, when I run the script, I sometimes see errors like this: >> >> $ ./rra_test.py >> rm test_rra.rrd >> rrdtool create test_rra.rrd --start 1293857700 DS:tst:GAUGE:600:0:U >> RRA:AVERAGE:0.5:5:10 >> 0 rrdtool update test_rra.rrd 1293858000:100 >> 1 rrdtool update test_rra.rrd 1293858300:101 >> 2 rrdtool update test_rra.rrd 1293858600:102 >> 3 rrdtool update test_rra.rrd 1293858900:103 >> 4 rrdtool update test_rra.rrd 1293859200:104 >> ERROR: test_rra.rrd: illegal attempt to update using time 1293858900 >> when last update time is 1293859200 (minimum one second step) >> 5 rrdtool update test_rra.rrd 1293859500:105 >> 6 rrdtool update test_rra.rrd 1293859800:106 >> 7 rrdtool update test_rra.rrd 1293860100:107 >> >> It doesn't happen all the time.The sleep statements in the script are >> an attempt to mitigate the problem. If I increase the sleep time in >> the loop from 10ms to 100ms, I don't see the problem. >> >> Presumably this isn't common during "real" rrdtool use, but I'm >> curious to know why it's happening. Is there some kind of race >> condition with subsequent calls to rrdupdate interfering with previous >> invocations? If so, why? >> >> This is rrdtool 1.4.4 on Centos 5.5, i386. >> >> Thanks. >> >> -David >> >> >> [1] The script: >> >> #!/usr/bin/env python >> >> import sys >> from subprocess import Popen >> from time import sleep >> >> fname = 'test_rra.rrd' >> start_time = 1293858000 >> step = 300 >> npoints = 8 >> start_val = 100 >> >> def run_cmd(cmd): >> print cmd >> Popen(cmd, shell=True) >> >> >> run_cmd( "rm " + fname ) >> run_cmd( "rrdtool create " + fname + " --start " + str(start_time-step) + >> " DS:tst:GAUGE:600:0:U RRA:AVERAGE:0.5:5:10" ) >> >> sleep(0.1) >> >> t = start_time >> v = start_val >> for i in range(npoints): >> print i, >> run_cmd("rrdtool update %s %d:%d" % (fname, t, v)) >> v += 1 >> t += step >> sleep(0.01) >> >> sys.exit(0) >> >> >> > > -- > Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland > http://it.oetiker.ch [email protected] ++41 62 775 9902 / sb: -9900 > -- David Eisner http://cradle.brokenglass.com _______________________________________________ rrd-users mailing list [email protected] https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
