Start roughing in pre and post conditions

This commit is contained in:
Isaac Connor 2020-07-30 12:13:09 -04:00
parent aa3b48e7c0
commit 34b079fa9e
1 changed files with 16 additions and 3 deletions

View File

@ -82,6 +82,13 @@ sub Execute {
my $self = $_[0];
my $sql = $self->Sql(undef);
if ( @{$$self{PreConditions}} ) {
foreach my $term ( @{$$self{PreConditions}} ) {
if ( $$term{attr} eq 'DiskPercent' ) {
}
}
}
if ( $self->{HasDiskPercent} ) {
my $disk_percent = getDiskPercent($$self{Storage} ? $$self{Storage}->Path() : ());
$sql =~ s/zmDiskPercent/$disk_percent/g;
@ -104,12 +111,13 @@ sub Execute {
return;
}
my @results;
while ( my $event = $sth->fetchrow_hashref() ) {
push @results, $event;
}
$sth->finish();
Debug('Loaded ' . @results . " events for filter $_[0]{Name} using query ($sql)");
Debug('Loaded ' . @results . ' events for filter '.$$self{Name}.' using query ('.$sql.')"');
if ( $self->{HasNonSqlConditions} ) {
}
return @results;
}
@ -183,18 +191,23 @@ sub Sql {
$self->{Sql} .= "weekday( E.EndTime )";
#
} elsif ( $term->{attr} eq 'EventExists' ) {
push @{$self->{PreConditions}}, $term;
} elsif ( $term->{attr} eq 'DiskSpace' ) {
$self->{Sql} .= 'E.DiskSpace';
$self->{HasDiskPercent} = !undef;
push @{$self->{PostConditions}}, $term;
} elsif ( $term->{attr} eq 'DiskPercent' ) {
$self->{Sql} .= 'zmDiskPercent';
$self->{HasDiskPercent} = !undef;
$self->{HasPreCondition} = !undef;
} elsif ( $term->{attr} eq 'DiskBlocks' ) {
$self->{Sql} .= 'zmDiskBlocks';
$self->{HasDiskBlocks} = !undef;
$self->{HasPreCondition} = !undef;
} elsif ( $term->{attr} eq 'SystemLoad' ) {
$self->{Sql} .= 'zmSystemLoad';
$self->{HasSystemLoad} = !undef;
$self->{HasPreCondition} = !undef;
} else {
$self->{Sql} .= 'E.'.$term->{attr};
}