#!/usr/bin/perl -w -I../../lib/
# 
# $Id: db-backend-daemon.pl,v 1.4 2002/03/07 09:19:17 fpmip Exp $
#
# Daemon which gets XML agent reports and status from designated drop 
# directories.  The data are then put in a postgres database for further
# analysis.

# Author : Tycho Fruru <tycho@fruru.com>

# Copyright (C) 2001 Tycho Fruru <tycho@fruru.com>
# Copyright (C) 2001 Conostix S.A. Luxembourg - Tycho Fruru <tycho@conostix.com>

# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#

require "db-config.pl";
require "db-backend-utils.pl";
require "update-db-backend.pl";

use IPFC::Log;
use DBI;

if ($> == 0) { die "do not run db-backend-daemon.pl as root" }

IPFC::Log::set_verbosity($VERBOSITY);
IPFC::Log::logger(1,"db-backend-daemon version $VERSION starting ...\n");

DBI->trace(0);

# for now we do just one iteration

my $iteration = 0;

while ($iteration < 1000) 
{
	update_db_backend();
	IPFC::Log::logger(3,"Sleeping $POLL_INTERVAL seconds ...\n");
	sleep($POLL_INTERVAL);
	$iteration++;
}

IPFC::Log::logger(1,"db-backend-daemon stopping after $iteration runs ...\n");
