[rtg] rtg status?

Chris Caputo ccaputo at alt.net
Fri Jan 9 15:27:35 EST 2009


On Sat, 10 Jan 2009, Adrian Chadd wrote:
> If you've emailed to the list about changes you've made to rtg and you'd 
> like them included, let me know, and I'll create a project and try to 
> coordinnate stuff.
> 
> My hope is that enough people with enough coordinated changes can 
> improve the codebase enough to just hand back something better to the 
> main RTG source gatekeepers so they don't have to do anything but just 
> commit the patches. :)
> 
> I'm only going to do it if I get interest from people with patches right 
> now, so please poke me.

These are my current patch related emails.

Thanks,
Chris

--

Date: Tue, 5 Aug 2008 10:21:37 +0000 (UTC)
From: Chris Caputo <ccaputo at alt.net>
To: rtg at lists.grdata.com
Subject: [rtg] PostgreSQL with current CVS

Please consider the following patch against the current CVS tree:

  http://www.caputo.com/foss/rtg/rtg.postgresql_fixes.20080805.diff

  (apply with "patch -p0" in rtg directory)

Changes:

  src/librtgpgsql.c: Adds support for __db_commit(), __db_intSpeed() and 
  __db_populate().

  src/rtgplot.c: Re-enables PostgreSQL compatibility.

  targetmaker/etc/targetmaker: Adds support for PostgreSQL.

Before running targetmaker, create your rtg database and add the following 
to it:

--
  CREATE TABLE router (
    rid SERIAL NOT NULL,
    name char(120) NOT NULL default '',
    pop char(10) NOT NULL default '',
    popid smallint NOT NULL default '0'
  );
  CREATE INDEX router_idx ON router (rid);

  CREATE TABLE interface (
    id SERIAL NOT NULL,
    name char(255) NOT NULL default '',
    rid int NOT NULL default '0',
    speed bigint default NULL,
    description char(255) default NULL,
    status boolean default true
  );
  CREATE INDEX interface_idx ON interface (id);
--

Be sure to change DB_TYPE in targetmaker.cfg as follows:

  $DB_TYPE = "Postgres";

And adjust rtg.conf as follows:

  DB_Driver   librtgpgsql.so
  Threads 1

(I only tested single-threaded mode.)

Also, I've adapted a version of 95.pl for PostreSQL at:

  http://www.caputo.com/foss/rtg/rtg95pg.20080805

All of the above was tested with version 8.2 of PostgreSQL.

Feedback welcome!

Thanks,
Chris
_______________________________________________

Date: Wed, 7 Jan 2009 18:54:59 +0000 (UTC)
From: Chris Caputo <ccaputo at alt.net>
To: Matt Simerson <matt.simerson at gmail.com>
Cc: rtg at lists.grdata.com
Subject: [rtg] handle database disconnects

On Wed, 7 Jan 2009, Matt Simerson wrote:
>   1. if the RTG poller loses the connection to the DB, it does not 
>      reconnect.  Ever.

For this I use the following simple patch in combination with having rtg 
be supervised by daemontools (http://cr.yp.to/daemontools.html) with "run" 
script:

  #!/bin/sh
  exec fghack /usr/local/rtg/bin/rtgpoll -v -t /usr/local/rtg/etc/targets.cfg

I run with my recent Postgres patches, but as long as the mysql and oracle 
db_insert() code returns an error on database insert failure, which they 
appear to do, this should work.

It isn't graceful, since you lose one or more periods of data, but at 
least it recovers from database issues once the database is nominal.  A 
better fix would be to have the reconnect code be in rtg, but this was 
easy.

Chris

---

diff -u -p -r1.41 rtgsnmp.c
--- src/rtgsnmp.c	19 Jan 2008 03:01:32 -0000	1.41
+++ src/rtgsnmp.c	7 Jan 2009 18:41:28 -0000
@@ -345,7 +345,9 @@ void *poller(void *thread_args)
 					PT_MUTEX_LOCK(&stats.mutex);
 					stats.db_inserts++;
 					PT_MUTEX_UNLOCK(&stats.mutex);
-				} 
+				} else {
+					fatal("Fatal database error.\n");
+				}
 			} /* insert_val > 0 or withzeros */	
 		} /* !dboff */


More information about the RTG mailing list