Merge branch 'storageareas' into newpointone
This commit is contained in:
commit
c2a857b498
|
@ -62,6 +62,8 @@ our $VERSION = $ZoneMinder::Base::VERSION;
|
||||||
use ZoneMinder::Config qw(:all);
|
use ZoneMinder::Config qw(:all);
|
||||||
use ZoneMinder::Logger qw(:all);
|
use ZoneMinder::Logger qw(:all);
|
||||||
use ZoneMinder::Database qw(:all);
|
use ZoneMinder::Database qw(:all);
|
||||||
|
require ZoneMinder::Storage;
|
||||||
|
require ZoneMinder::Server;
|
||||||
|
|
||||||
use POSIX;
|
use POSIX;
|
||||||
|
|
||||||
|
@ -145,7 +147,7 @@ sub Execute {
|
||||||
|
|
||||||
if ( $self->{HasDiskPercent} )
|
if ( $self->{HasDiskPercent} )
|
||||||
{
|
{
|
||||||
my $disk_percent = getDiskPercent();
|
my $disk_percent = getDiskPercent( $$self{Storage} ? $$self{Storage}->Path() : () )
|
||||||
$sql =~ s/zmDiskPercent/$disk_percent/g;
|
$sql =~ s/zmDiskPercent/$disk_percent/g;
|
||||||
}
|
}
|
||||||
if ( $self->{HasDiskBlocks} )
|
if ( $self->{HasDiskBlocks} )
|
||||||
|
@ -221,6 +223,8 @@ sub Sql {
|
||||||
if ( $filter_expr->{terms}[$i]->{attr} =~ /^Monitor/ ) {
|
if ( $filter_expr->{terms}[$i]->{attr} =~ /^Monitor/ ) {
|
||||||
my ( $temp_attr_name ) = $filter_expr->{terms}[$i]->{attr} =~ /^Monitor(.+)$/;
|
my ( $temp_attr_name ) = $filter_expr->{terms}[$i]->{attr} =~ /^Monitor(.+)$/;
|
||||||
$self->{Sql} .= "M.".$temp_attr_name;
|
$self->{Sql} .= "M.".$temp_attr_name;
|
||||||
|
} elsif ( $filter_expr->{terms}[$i]->{attr} =~ /^Server/ ) {
|
||||||
|
$self->{Sql} .= "M.".$filter_expr->{terms}[$i]->{attr};
|
||||||
} elsif ( $filter_expr->{terms}[$i]->{attr} eq 'DateTime' ) {
|
} elsif ( $filter_expr->{terms}[$i]->{attr} eq 'DateTime' ) {
|
||||||
$self->{Sql} .= "E.StartTime";
|
$self->{Sql} .= "E.StartTime";
|
||||||
} elsif ( $filter_expr->{terms}[$i]->{attr} eq 'Date' ) {
|
} elsif ( $filter_expr->{terms}[$i]->{attr} eq 'Date' ) {
|
||||||
|
@ -246,6 +250,29 @@ sub Sql {
|
||||||
foreach my $temp_value ( split( /["'\s]*?,["'\s]*?/, $stripped_value ) ) {
|
foreach my $temp_value ( split( /["'\s]*?,["'\s]*?/, $stripped_value ) ) {
|
||||||
if ( $filter_expr->{terms}[$i]->{attr} =~ /^Monitor/ ) {
|
if ( $filter_expr->{terms}[$i]->{attr} =~ /^Monitor/ ) {
|
||||||
$value = "'$temp_value'";
|
$value = "'$temp_value'";
|
||||||
|
} elsif ( $filter_expr->{terms}[$i]->{attr} eq 'ServerHost' ) {
|
||||||
|
if ( $temp_value eq 'ZM_SERVER_HOST' ) {
|
||||||
|
$value = "'$Config{ZM_SERVER_HOST}'";
|
||||||
|
} else {
|
||||||
|
$value = "'$temp_value'";
|
||||||
|
}
|
||||||
|
} elsif ( $filter_expr->{terms}[$i]->{attr} eq 'ServerName' ) {
|
||||||
|
if ( $temp_value eq 'ZM_SERVER_NAME' ) {
|
||||||
|
$value = "'$Config{ZM_SERVER_NAME}'";
|
||||||
|
} else {
|
||||||
|
$value = "'$temp_value'";
|
||||||
|
}
|
||||||
|
} elsif ( $filter_expr->{terms}[$i]->{attr} eq 'ServerId' ) {
|
||||||
|
if ( $temp_value eq 'ZM_SERVER_ID' ) {
|
||||||
|
$value = "'$Config{ZM_SERVER_ID}'";
|
||||||
|
my $Server = $$self{Server} = new ZoneMinder::Server( $Config{ZM_SERVER_ID} );
|
||||||
|
} else {
|
||||||
|
$value = "'$temp_value'";
|
||||||
|
my $Server = $$self{Server} = new ZoneMinder::Server( $temp_value );
|
||||||
|
}
|
||||||
|
} elsif ( $filter_expr->{terms}[$i]->{attr} eq 'StorageId' ) {
|
||||||
|
$value = "'$temp_value'";
|
||||||
|
my $Storage = $$self{Storage} = new ZoneMinder::Storage( $temp_value );
|
||||||
} elsif ( $filter_expr->{terms}[$i]->{attr} eq 'Name'
|
} elsif ( $filter_expr->{terms}[$i]->{attr} eq 'Name'
|
||||||
|| $filter_expr->{terms}[$i]->{attr} eq 'Cause'
|
|| $filter_expr->{terms}[$i]->{attr} eq 'Cause'
|
||||||
|| $filter_expr->{terms}[$i]->{attr} eq 'Notes'
|
|| $filter_expr->{terms}[$i]->{attr} eq 'Notes'
|
||||||
|
@ -407,12 +434,13 @@ sub Sql {
|
||||||
|
|
||||||
sub getDiskPercent
|
sub getDiskPercent
|
||||||
{
|
{
|
||||||
my $command = "df .";
|
my $command = "df " . ($_[0] ? $_[0] : '.');
|
||||||
my $df = qx( $command );
|
my $df = qx( $command );
|
||||||
my $space = -1;
|
my $space = -1;
|
||||||
if ( $df =~ /\s(\d+)%/ms )
|
if ( $df =~ /\s(\d+)%/ms )
|
||||||
{
|
{
|
||||||
$space = $1;
|
$space = $1;
|
||||||
|
Debug( "getDiskPercent $command returned $space" );
|
||||||
}
|
}
|
||||||
return( $space );
|
return( $space );
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,10 +69,11 @@ sub new {
|
||||||
|
|
||||||
my $self = {};
|
my $self = {};
|
||||||
bless $self, $parent;
|
bless $self, $parent;
|
||||||
if ( ( $$self{id} = $id ) or $data ) {
|
if ( ( $$self{Id} = $id ) or $data ) {
|
||||||
#$log->debug("loading $parent $id") if $debug or DEBUG_ALL;
|
#$log->debug("loading $parent $id") if $debug or DEBUG_ALL;
|
||||||
$self->load( $data );
|
$self->load( $data );
|
||||||
}
|
}
|
||||||
|
return $self;
|
||||||
} # end sub new
|
} # end sub new
|
||||||
|
|
||||||
sub load {
|
sub load {
|
||||||
|
@ -80,10 +81,10 @@ sub load {
|
||||||
my $type = ref $self;
|
my $type = ref $self;
|
||||||
if ( ! $data ) {
|
if ( ! $data ) {
|
||||||
#$log->debug("Object::load Loading from db $type");
|
#$log->debug("Object::load Loading from db $type");
|
||||||
$data = $ZoneMinder::dbh->selectrow_hashref( 'SELECT * FROM Storage WHERE Id=?', {}, $$self{Id} );
|
$data = $ZoneMinder::Database::dbh->selectrow_hashref( 'SELECT * FROM Storage WHERE Id=?', {}, $$self{Id} );
|
||||||
if ( ! $data ) {
|
if ( ! $data ) {
|
||||||
if ( $ZoneMinder::dbh->errstr ) {
|
if ( $ZoneMinder::Database::dbh->errstr ) {
|
||||||
Error( "Failure to load Storage record for $$self{id}: Reason: " . $ZoneMinder::dbh->errstr );
|
Error( "Failure to load Storage record for $$self{id}: Reason: " . $ZoneMinder::Database::dbh->errstr );
|
||||||
} # end if
|
} # end if
|
||||||
} # end if
|
} # end if
|
||||||
} # end if ! $data
|
} # end if ! $data
|
||||||
|
|
|
@ -124,6 +124,8 @@ $SLANG = array(
|
||||||
'AttrMaxScore' => 'Max. Score',
|
'AttrMaxScore' => 'Max. Score',
|
||||||
'AttrMonitorId' => 'Monitor Id',
|
'AttrMonitorId' => 'Monitor Id',
|
||||||
'AttrMonitorName' => 'Monitor Name',
|
'AttrMonitorName' => 'Monitor Name',
|
||||||
|
'AttrStorageId' => 'Storage Id',
|
||||||
|
'AttrStorageName' => 'Storage Name',
|
||||||
'AttrName' => 'Name',
|
'AttrName' => 'Name',
|
||||||
'AttrNotes' => 'Notes',
|
'AttrNotes' => 'Notes',
|
||||||
'AttrSystemLoad' => 'System Load',
|
'AttrSystemLoad' => 'System Load',
|
||||||
|
|
|
@ -84,6 +84,8 @@ $attrTypes = array(
|
||||||
'DiskPercent' => translate('AttrDiskPercent'),
|
'DiskPercent' => translate('AttrDiskPercent'),
|
||||||
'DiskBlocks' => translate('AttrDiskBlocks'),
|
'DiskBlocks' => translate('AttrDiskBlocks'),
|
||||||
'SystemLoad' => translate('AttrSystemLoad'),
|
'SystemLoad' => translate('AttrSystemLoad'),
|
||||||
|
'StorageId' => translate('AttrStorageId'),
|
||||||
|
'StorageName' => translate('AttrStorageName'),
|
||||||
);
|
);
|
||||||
$opTypes = array(
|
$opTypes = array(
|
||||||
'=' => translate('OpEq'),
|
'=' => translate('OpEq'),
|
||||||
|
|
Loading…
Reference in New Issue