Switch from a MIN_AGE constant in zmaudit.pl to using a ZM_AUDIT_MIN_AGE Config setting
This commit is contained in:
parent
82f5ab5175
commit
a5fed03524
|
@ -2368,7 +2368,6 @@ body = "ZM alarm detected - %EL% secs, %EF%/%EFA% frames, t%EST%/m%ESM%/a%ESA% s
|
||||||
category => "system",
|
category => "system",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name => "ZM_AUDIT_CHECK_INTERVAL",
|
name => "ZM_AUDIT_CHECK_INTERVAL",
|
||||||
default => "900",
|
default => "900",
|
||||||
description => "How often to check database and filesystem consistency",
|
description => "How often to check database and filesystem consistency",
|
||||||
|
@ -2390,6 +2389,19 @@ body = "ZM alarm detected - %EL% secs, %EF%/%EFA% frames, t%EST%/m%ESM%/a%ESA% s
|
||||||
type => $types{integer},
|
type => $types{integer},
|
||||||
category => "system",
|
category => "system",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name => "ZM_AUDIT_MIN_AGE",
|
||||||
|
default => "86400",
|
||||||
|
description => "The minimum age in seconds event data must be in order to be deleted.",
|
||||||
|
help => qqq("
|
||||||
|
The zmaudit daemon exists to check that the saved information
|
||||||
|
in the database and on the filesystem match and are consistent
|
||||||
|
with each other. Event files or db records that are younger than
|
||||||
|
this setting will not be deleted and a warning will be given.
|
||||||
|
"),
|
||||||
|
type => $types{integer},
|
||||||
|
category => "system",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name => "ZM_FORCED_ALARM_SCORE",
|
name => "ZM_FORCED_ALARM_SCORE",
|
||||||
default => "255",
|
default => "255",
|
||||||
|
|
|
@ -56,7 +56,6 @@ use bytes;
|
||||||
#
|
#
|
||||||
# ==========================================================================
|
# ==========================================================================
|
||||||
|
|
||||||
use constant MIN_AGE => 300; # Minimum age when we will delete anything
|
|
||||||
use constant MAX_AGED_DIRS => 10; # Number of event dirs to check age on
|
use constant MAX_AGED_DIRS => 10; # Number of event dirs to check age on
|
||||||
use constant RECOVER_TAG => "(r)"; # Tag to append to event name when recovered
|
use constant RECOVER_TAG => "(r)"; # Tag to append to event name when recovered
|
||||||
use constant RECOVER_TEXT => "Recovered."; # Text to append to event notes when recovered
|
use constant RECOVER_TEXT => "Recovered."; # Text to append to event notes when recovered
|
||||||
|
@ -246,7 +245,7 @@ MAIN: while( $loop ) {
|
||||||
{
|
{
|
||||||
while ( my ( $fs_event, $age ) = each(%$fs_events ) )
|
while ( my ( $fs_event, $age ) = each(%$fs_events ) )
|
||||||
{
|
{
|
||||||
if ( !defined($db_events->{$fs_event}) && ($age < 0 || ($age > MIN_AGE)) )
|
if ( !defined($db_events->{$fs_event}) && ($age < 0 || ($age > $Config{ZM_AUDIT_MIN_AGE})) )
|
||||||
{
|
{
|
||||||
aud_print( "Filesystem event '$fs_monitor/$fs_event' does not exist in database" );
|
aud_print( "Filesystem event '$fs_monitor/$fs_event' does not exist in database" );
|
||||||
if ( confirm() )
|
if ( confirm() )
|
||||||
|
@ -308,11 +307,10 @@ MAIN: while( $loop ) {
|
||||||
{
|
{
|
||||||
while ( my ( $db_event, $age ) = each(%$db_events ) )
|
while ( my ( $db_event, $age ) = each(%$db_events ) )
|
||||||
{
|
{
|
||||||
if ( !defined($fs_events->{$db_event}) && ($age > MIN_AGE) )
|
if ( !defined($fs_events->{$db_event}) ) {
|
||||||
{
|
if ( $age > $Config{ZM_AUDIT_MIN_AGE} ) {
|
||||||
aud_print( "Database event '$db_monitor/$db_event' does not exist in filesystem" );
|
aud_print( "Database event '$db_monitor/$db_event' does not exist in filesystem" );
|
||||||
if ( confirm() )
|
if ( confirm() ) {
|
||||||
{
|
|
||||||
my $res = $deleteEventSth->execute( $db_event )
|
my $res = $deleteEventSth->execute( $db_event )
|
||||||
or Fatal( "Can't execute: ".$deleteEventSth->errstr() );
|
or Fatal( "Can't execute: ".$deleteEventSth->errstr() );
|
||||||
$res = $deleteFramesSth->execute( $db_event )
|
$res = $deleteFramesSth->execute( $db_event )
|
||||||
|
@ -321,13 +319,16 @@ MAIN: while( $loop ) {
|
||||||
or Fatal( "Can't execute: ".$deleteStatsSth->errstr() );
|
or Fatal( "Can't execute: ".$deleteStatsSth->errstr() );
|
||||||
$cleaned = 1;
|
$cleaned = 1;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
aud_print( "Database event '$db_monitor/$db_event' does not exist in filesystem but too young to delete." );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#aud_print( "Database monitor '$db_monitor' does not exist in filesystem" );
|
aud_print( "Database monitor '$db_monitor' does not exist in filesystem" );
|
||||||
#if ( confirm() )
|
#if ( confirm() )
|
||||||
#{
|
#{
|
||||||
# We don't actually do this in case it's new
|
# We don't actually do this in case it's new
|
||||||
|
@ -363,7 +364,7 @@ MAIN: while( $loop ) {
|
||||||
# Remove empty events (with no frames)
|
# Remove empty events (with no frames)
|
||||||
$cleaned = 0;
|
$cleaned = 0;
|
||||||
my $selectEmptyEventsSql = "SELECT * FROM Events as E LEFT JOIN Frames as F ON (E.Id = F.EventId)
|
my $selectEmptyEventsSql = "SELECT * FROM Events as E LEFT JOIN Frames as F ON (E.Id = F.EventId)
|
||||||
WHERE isnull(F.EventId) AND now() - interval ".MIN_AGE." second > E.StartTime";
|
WHERE isnull(F.EventId) AND now() - interval ".$Config{ZM_AUDIT_MIN_AGE}." second > E.StartTime";
|
||||||
my $selectEmptyEventsSth = $dbh->prepare_cached( $selectEmptyEventsSql )
|
my $selectEmptyEventsSth = $dbh->prepare_cached( $selectEmptyEventsSql )
|
||||||
or Fatal( "Can't prepare '$selectEmptyEventsSql': ".$dbh->errstr() );
|
or Fatal( "Can't prepare '$selectEmptyEventsSql': ".$dbh->errstr() );
|
||||||
$res = $selectEmptyEventsSth->execute()
|
$res = $selectEmptyEventsSth->execute()
|
||||||
|
@ -434,7 +435,7 @@ MAIN: while( $loop ) {
|
||||||
LEFT JOIN Monitors as M on E.MonitorId = M.Id
|
LEFT JOIN Monitors as M on E.MonitorId = M.Id
|
||||||
INNER JOIN Frames as F on E.Id = F.EventId
|
INNER JOIN Frames as F on E.Id = F.EventId
|
||||||
WHERE isnull(E.Frames) or isnull(E.EndTime)
|
WHERE isnull(E.Frames) or isnull(E.EndTime)
|
||||||
GROUP BY E.Id HAVING EndTime < (now() - interval ".MIN_AGE." second)"
|
GROUP BY E.Id HAVING EndTime < (now() - interval ".$Config{ZM_AUDIT_MIN_AGE}." second)"
|
||||||
;
|
;
|
||||||
my $selectUnclosedEventsSth = $dbh->prepare_cached( $selectUnclosedEventsSql )
|
my $selectUnclosedEventsSth = $dbh->prepare_cached( $selectUnclosedEventsSql )
|
||||||
or Fatal( "Can't prepare '$selectUnclosedEventsSql': ".$dbh->errstr() );
|
or Fatal( "Can't prepare '$selectUnclosedEventsSql': ".$dbh->errstr() );
|
||||||
|
|
Loading…
Reference in New Issue