diff --git a/bin/pgaudit_analyze b/bin/pgaudit_analyze index e052d5b..69a3c1f 100755 --- a/bin/pgaudit_analyze +++ b/bin/pgaudit_analyze @@ -33,6 +33,7 @@ pgaudit_analyze [options] --socket-path socket directory used by PostgreSQL (default to system default directory) --log-file location of the log file for pgaudit_analyze (defaults to /var/log/pgaudit_analyze.log) --user specify postgres user instead of using pgaudit_analyze invoker + --database specify database name to save audit info to (default is database from log) General Options: --help display usage and exit @@ -121,6 +122,7 @@ my $iPort = 5432; my $strSocketPath; my $strLogOutFile = '/var/log/pgaudit_analyze.log'; my $strDbUser = getpwuid($<); +my $strDbOverride; GetOptions ('help' => \$bHelp, @@ -128,7 +130,8 @@ GetOptions ('help' => \$bHelp, 'port=s' => \$iPort, 'socket-path=s' => \$strSocketPath, 'log-file=s' => \$strLogOutFile, - 'user=s' => \$strDbUser) + 'user=s' => \$strDbUser, + 'database=s' => \$strDbOverride) or pod2usage(2); # Display version and exit if requested @@ -688,7 +691,7 @@ while(!$bDone) my $strSessionId = $$stryRow[LOG_FIELD_SESSION_ID]; my $lSessionLineNum = $$stryRow[LOG_FIELD_SESSION_LINE_NUM]; my $strUserName = $$stryRow[LOG_FIELD_USER_NAME]; - my $strDatabaseName = $$stryRow[LOG_FIELD_DATABASE_NAME]; + my $strDatabaseName = $strDbOverride || $$stryRow[LOG_FIELD_DATABASE_NAME]; if (defined($strUserName) && $strAuditUserName ne $strUserName && defined($strDatabaseName) && databaseGet($strDatabaseName) &&