|
From: Bob T. <bt...@us...> - 2004-03-01 20:36:13
|
Update of /cvsroot/benson/benson3/src/tests/handlers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31814 Added Files: Makefile.in historical_handler_test.tmpl Log Message: Added the historical handler tests. --- NEW FILE: Makefile.in --- prefix=@prefix@ perlpath=@perlpath@ exec_prefix=@exec_prefix@ bindir=@bindir@ srcdir=@srcdir@ top_srcdir=@top_srcdir@ CC=@CC@ LD=@LD@ CFLAGS=-I$(top_srcdir) -I$(top_srcdir)/include -I$(top_srcdir)/src/perl @CFLAGS@ PERL_CFLAGS=@PERL_CFLAGS@ PERL_LDFLAGS=@PERL_LDFLAGS@ CPPFLAGS=@CPPFLAGS@ @DEFS@ LIBS=@LIBS@ AR=@arpath@ RANLIB=@RANLIB@ INSTALL=@INSTALL@ LDFLAGS=-L. @LDFLAGS@ TARGETS=historical_handler_test all: $(TARGETS) historical_handler_test: historical_handler_test.tmpl cat historical_handler_test.tmpl | sed -e "s:prefixpath:@prefix@:" \ | sed -e "s:perlpath:@perlpath@:" > historical_handler_test chmod 700 historical_handler_test clean: rm -f historical_handler_test distclean: clean rm -f Makefile *~ --- NEW FILE: historical_handler_test.tmpl --- #!perlpath -Iprefixpath/lib/perl use DBI; use Benson; use POSIX; my $benson = new Benson; my $current_time = time(); my $start_time = $current_time - (30 * (24 * (60*60))); my $present = POSIX::strftime("%Y-%m-%d_%H:%M:%S", localtime($current_time)); my $past = POSIX::strftime("%Y-%m-%d_%H:%M:%S", localtime($current_time)); print <<EOT; TESTING: R85historical handler 1) Populating database with 30 days of alerts (one alert per hour, per day). 2) Run R85historical handler 3) Verify results Starting phase 1.... General Information: Current time: $present Historical time: $past EOT my $dbh = DBI->connect($benson->DBIConnectString, $benson->DBIUsername, $benson->DBIPassword); my $ctr = 0; while($start_time < $current_time) { my $recv_time = POSIX::strftime("%Y-%m-%d_%H:%M:%S", localtime($start_time)); my $sql = <<EOSQL; INSERT INTO alerts (identity, destination, agent, severity, subsystem, message, received, status) VALUES ('$start_time.test.1', 'localhost', 'localhost', 'informational', 'historical_test', 'testing $ctr', to_timestamp('$recv_time','yyyy-mm-dd_HH24:MI:SS'), 'acknowledged') EOSQL my $sth = $dbh->prepare($sql); $sth->execute(); $ctr++; $start_time += 3600; } $dbh->disconnect(); print <<EOT; Rows inserted: $ctr Starting phase 2.... EOT my $handler_wrapper = "prefixpath/bin/handler_wrapper"; my $handler_type = "--handler_type=rule"; my $handler_path = "--handler_path=prefixpath/handlers/"; my $handler = "--handler=R85historical.pm"; system($handler_wrapper,$handler_type,$handler_path,$handler); # # Yeah, yeah, I know this sucks, it'll get better. # print <<EOT; Starting phase 3.... Rows inserted should be: 720 Rows deleted/moved/inserted should be: 533 EOT |