implement disk_used_blocks in Storage. Also use Type() instead of ->{Type} to get default value.

pull/3040/head
Isaac Connor 2020-08-17 16:57:53 -04:00
parent 72cad5f6d6
commit 479768a2a4
1 changed files with 9 additions and 1 deletions

View File

@ -69,6 +69,14 @@ class Storage extends ZM_Object {
return $this->{'EventCount'};
}
public function disk_used_blocks() {
$df = shell_exec('df '.escapeshellarg($this->Path()));
$space = -1;
if ( preg_match('/\s(\d+)\s+\d+\s+\d+%/ms', $df, $matches) )
$space = $matches[1];
return $space;
}
public function disk_usage_percent() {
$path = $this->Path();
if ( ! $path ) {
@ -106,7 +114,7 @@ class Storage extends ZM_Object {
public function disk_used_space() {
# This isn't a function like this in php, so we have to add up the space used in each event.
if ( ( !property_exists($this, 'disk_used_space')) or !$this->{'disk_used_space'} ) {
if ( $this->{'Type'} == 's3fs' ) {
if ( $this->Type() == 's3fs' ) {
$this->{'disk_used_space'} = $this->event_disk_space();
} else {
$path = $this->Path();