|
From: Leech, J. <jl...@vi...> - 2009-01-09 17:04:51
|
Bryan,
Thanks for the patch. If it could be made more rigorous, I think it
would be appropriate to include as an option. I will give it some more
thought.
-Jonathan
-----Original Message-----
From: Bryan Wann [mailto:bwa...@wa...]
Sent: Saturday, January 03, 2009 1:43 PM
To: jrt...@li...
Subject: Re: [Jrtg-users] Poller.java - thread question
On Mon, 17 Nov 2008, Leech, Jonathan wrote:
> You want to be careful normalizing the times, so as not to affect the
> rate calculations. So don't change the time going in to the
> TargetStatistic object, but rather change it at the time of insert in
> the database (if you are using RTGDBDriver its on line 175). The
> safest / easiest way to do that would be to round the significant
> digits out of the poll time (if you have a 5 minute poll cycle, put
> the times at :00
> :05 :10, etc). Otherwise you would have to take extra care to make
> sure your change is compatible with the buffering in DBBuffer.
This is what I've done so far to handle this. It's not a rigorous
solution, since your poll interval could straddle a 5 minute boundary
depending how long the cycle is and when it was started. That is, some
inserts could be at 00:45 more could be at 00:50.
This could be a problem with or without the patch depending why you want
to do it. In my case I just make it a point to start up the poller at a
5 minute boundary.
This may not patch cleanly as my line numbers are a bit off and I don't
use a 'rate' column.
--- RTGDBDriver.java.orig3 2009-01-02 17:52:24.000000000 -0500
+++ RTGDBDriver.java 2009-01-03 00:54:46.000000000 -0500
@@ -171,11 +171,18 @@
try {
Connection con = connection.get();
synchronized(con) {
+
+ GregorianCalendar gc = new GregorianCalendar();
+ gc.setTime( new java.util.Date( targetValue.timestamp ) );
+ gc.set( Calendar.MINUTE, ( gc.get(Calendar.MINUTE) / 5 ) *
5 );
+ gc.set( Calendar.SECOND, 0 );
+ long newts = gc.getTimeInMillis();
+
ps = con.prepareStatement("insert delayed into " +
targetValue.name + "_" + targetValue.interfaceValues.deviceValues.RID
+ " (id, dtime, counter) values "
+ " (?,?,?)");
ps.setLong(1, targetValue.interfaceValues.IID);
- ps.setTimestamp(2, new
java.sql.Timestamp(targetValue.timestamp), cal);
+ ps.setTimestamp(2, new java.sql.Timestamp( newts ), cal);
ps.setLong(3, targetValue.value.longValue());
ps.execute();
int count = connectionToCount.get(con) + 1;
Met vriendelijke groet/kind regards,
bryan
------------------------------------------------------------------------
------
_______________________________________________
Jrtg-users mailing list
Jrt...@li...
https://lists.sourceforge.net/lists/listinfo/jrtg-users
|