Python rrdtool try catch statement


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Python rrdtool try catch statement
# 1  
Old 03-18-2013
Python rrdtool try catch statement

I have a Python script that updates an rrd file with data it pulls from a database. Here is a snippet of the Python code
Code:
for i in range(numrowed):
                row = curred.fetchone()
                time_stamp = row[0]
                rx_max = row[1]
 
                ret = rrdtool.update(ds_file.rrd,'%s:%s' %(time_stamp,rx_max)); 
                      if ret:
                         print rrdtool.error()
           i = i + 1

My problem is that the script crashes anytime there is a duplicate time stamp because rrdtool allows only one value per timestamp. Thus i get this error

Traceback (most recent call last):
File "rrdfile_update.py", line 40, in <module>
ret = rrdtool.update(ds_file.rrd,'%s:%s' %(time_stamp,rx_max));
rrdtool.error: ds_file: illegal attempt to update using time 1363358441 when last update time is 1363358441 (minimum one second step)

I will appreciate very much if you can help me with a Python try catch statement to help skip this error and continue to update the rrd file with the next timestamp and value so the script does not stop.

Help very much appreciated. Thanks
# 2  
Old 03-26-2013
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Python-rrdtool try except rrdtool.error module object has no attribute error

I have this code that gives this error on Linux and will be grateful if you can help import rrdtool try: ret_asd = rrdtool.update(myfile.rrd,'N:%s:%s' %(metric1, metric2)); except rrdtool.error, e: print e When i run the above i get the below error except... (1 Reply)
Discussion started by: kaf3773
1 Replies

2. Shell Programming and Scripting

Bash script for rrdtool

Hello all, I am very new to shell scripting. I messed with basic examples in college, but this this the first work related project I am trying to work on. I am trying to test the rrdtool on our office wan link by measuring the bandwidth utilization. The script concept is fairly easy, but I am... (2 Replies)
Discussion started by: AdrianT04
2 Replies

3. Red Hat

Why do we use RRDtool in MRTG?

Hi Guys, Why do we use RRDtool in MRTG? I have implemented MRTG for some routers, I have read some notes about RRDTOOL also but don't know what is use of these tool. Any one one please explain me the use of RRDTOOL in their own words? (1 Reply)
Discussion started by: manalisharmabe
1 Replies

4. UNIX for Dummies Questions & Answers

rrdtool question

Hi, DEF:clients=cccam.rrd:kliensek:AVERAGE DEF:activeclients=cccam_actclient.rrd:activeclients:AVERAGE "LINE1:clients#0000FF:Connected clients" COMMENT:" \n" "LINE2:activeclients#99FF00:Active clients" COMMENT:" \n" GPRINT:clients:LAST:'Current'\%5.0lf%s COMMENT:" \n"... (2 Replies)
Discussion started by: adriankoooo
2 Replies

5. Shell Programming and Scripting

For loop statement - catch error

I'm having a question about for loops. (bash) I have the following for example: for file in `ls *.txt` do read file ... done Now when there is a file present there is no problem, now when there is no file present I get the following output in my standard mail box : "No such... (4 Replies)
Discussion started by: lumdev
4 Replies

6. HP-UX

compiling the RRDtool

I tried to compile the RRDtool on HP-UX (IA56). I have gcc-3.4.3 and perl 5.8.0 I got this: Writing Makefile for RRDs cd perl-shared && make /opt/perl/bin/perl /opt/perl/lib/5.8.0/ExtUtils/xsubpp -typemap /opt/perl/lib/5.8.0/ExtUtils/typemap RRDs.xs > RRDs.xsc && mv... (2 Replies)
Discussion started by: Kalin
2 Replies
Login or Register to Ask a Question