Make getDiskPercent take an optional path. When a Server is specified, add it to the Filter object so that we can use in getDiskPercent
This commit is contained in:
parent
710197a4f2
commit
3d00c3a50d
|
@ -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} )
|
||||||
|
@ -263,9 +265,14 @@ sub Sql {
|
||||||
} elsif ( $filter_expr->{terms}[$i]->{attr} eq 'ServerId' ) {
|
} elsif ( $filter_expr->{terms}[$i]->{attr} eq 'ServerId' ) {
|
||||||
if ( $temp_value eq 'ZM_SERVER_ID' ) {
|
if ( $temp_value eq 'ZM_SERVER_ID' ) {
|
||||||
$value = "'$Config{ZM_SERVER_ID}'";
|
$value = "'$Config{ZM_SERVER_ID}'";
|
||||||
|
my $Server = $$self{Server} = new ZoneMinder::Server( $Config{ZM_SERVER_ID} );
|
||||||
} else {
|
} else {
|
||||||
$value = "'$temp_value'";
|
$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'
|
||||||
|
@ -427,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 );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue