powered by Jive Software

Script to put audit log (messages) to PostGres DB

This is Perl script

#!/usr/bin/perl

use XML::Simple;

use DBI;

use File::Remove;

$dbh = DBI->connect(“dbi:Pg:dbname=YOUR_DB”,“PG_ROOT_USER”,"",

{PrintError => 0});

if ($DBI::err != 0) {

print $DBI::errstr . “\n”;

exit($DBI::err);

}

  1. create object

$xml = new XML::Simple;

my @logFiles = </opt/jive_messenger/logs/jive.audit-1.log>;

  1. read XML file

foreach $file (@logFiles)

{

$data = $xml->XMLin($file);

foreach $message (@{$data->{packet}})

{

$from = $message->{message}->;

$from =~ s/@.*//g;

$to = $message->The specified item was not found.->’’)";

$sth = $dbh->prepare($query);

$rv = $sth->execute();

if (!defined $rv) {

print "An error has aqueries ‘’$query’’ by number: " . $dbh->errstr . “\n”;

exit(0);

}

File::Remove::remove ($file);

}

}

$sth->finish();

$dbh->disconnect();[/i]