From 10a191ae5bdedd98b98c2e098abab024b256e55e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 17 Apr 2018 14:14:40 -0700 Subject: [PATCH] add event_disk_space to storage to differentiate between real used space versus event used disk space. Use this in the navbar to show actual disk use and also event disk use --- web/includes/Storage.php | 33 +++++++++++-------- web/skins/classic/css/base/skin.css | 4 +-- web/skins/classic/includes/functions.php | 12 ++++++- .../classic/views/report_event_audit.php | 6 ++-- 4 files changed, 37 insertions(+), 18 deletions(-) diff --git a/web/includes/Storage.php b/web/includes/Storage.php index ef00348d8..e524a9084 100644 --- a/web/includes/Storage.php +++ b/web/includes/Storage.php @@ -140,30 +140,37 @@ class Storage { return $usage; } public function disk_total_space() { - if ( ! array_key_exists( 'disk_total_space', $this ) ) { - $this->{'disk_total_space'} = disk_total_space( $this->Path() ); + if ( ! array_key_exists('disk_total_space', $this) ) { + $this->{'disk_total_space'} = disk_total_space($this->Path()); } return $this->{'disk_total_space'}; } + 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 ( (! array_key_exists( 'DiskSpace', $this )) or (!$this->{'DiskSpace'}) ) { - $used = 0; + if ( (! array_key_exists('disk_used_space', $this)) or (!$this->{'disk_used_space'}) ) { if ( $this->{'Type'} == 's3fs' ) { - $used = dbFetchOne('SELECT SUM(DiskSpace) AS DiskSpace FROM Events WHERE StorageId=? AND DiskSpace IS NOT NULL', 'DiskSpace', array($this->Id()) ); - - foreach ( Event::find_all( array( 'StorageId'=>$this->Id(), 'DiskSpace'=>null ) ) as $Event ) { - $Event->Storage( $this ); // Prevent further db hit - $used += $Event->DiskSpace(); - } + $this->{'disk_used_space'} = $this->disk_event_space(); } else { $path = $this->Path(); - $used = disk_total_space( $path ) - disk_free_space( $path );; + $this->{'disk_used_space'} = disk_total_space($path) - disk_free_space($path); + } + } + return $this->{'disk_used_space'}; + } // end function disk_used_space + + public function event_disk_space() { + # This isn't a function like this in php, so we have to add up the space used in each event. + if ( (! array_key_exists('DiskSpace', $this)) or (!$this->{'DiskSpace'}) ) { + $used = dbFetchOne('SELECT SUM(DiskSpace) AS DiskSpace FROM Events WHERE StorageId=? AND DiskSpace IS NOT NULL', 'DiskSpace', array($this->Id()) ); + + foreach ( Event::find_all( array('StorageId'=>$this->Id(), 'DiskSpace'=>null) ) as $Event ) { + $Event->Storage( $this ); // Prevent further db hit + $used += $Event->DiskSpace(); } $this->{'DiskSpace'} = $used; } - return $this->{'DiskSpace'}; - } + } // end function event_disk_space } ?> diff --git a/web/skins/classic/css/base/skin.css b/web/skins/classic/css/base/skin.css index 0fda49d10..3fdd5a12f 100644 --- a/web/skins/classic/css/base/skin.css +++ b/web/skins/classic/css/base/skin.css @@ -341,11 +341,11 @@ fieldset > legend { /* * Behavior classes */ -.alarm, .errorText { +.alarm, .errorText, .error { color: #ff3f34; } -.alert, .warnText { +.alert, .warnText, .warning { color: #ffa801; } diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index f53b21d54..b814e9a13 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -340,7 +340,17 @@ if ($reload == 'reload') ob_start(); if ( ! isset($storage_paths[ZM_DIR_EVENTS]) ) { array_push( $storage_areas, new Storage() ); } - $func = function($S){ return ''.$S->Name() . ': ' . $S->disk_usage_percent().'%' . ''; }; + $func = function($S){ + $class = ''; + if ( $S->disk_usage_percent() > 98 ) { + $class = "error"; + } else if ( $S->disk_usage_percent() > 90 ) { + $class = "warning"; + } + $title = human_filesize($S->disk_used_space()) . ' of ' . human_filesize($S->disk_total_space()). + ( ( $S->disk_used_space() != $S->event_disk_space() ) ? ' ' .human_filesize($S->event_disk_space()) . ' used by events' : '' ); + + return ''.$S->Name() . ': ' . $S->disk_usage_percent().'%' . ''; }; #$func = function($S){ return ''.$S->Name() . ': ' . $S->disk_usage_percent().'%' . ''; }; if ( count($storage_areas) >= 4 ) $storage_areas = Storage::find_all( array('ServerId'=>null) ); diff --git a/web/skins/classic/views/report_event_audit.php b/web/skins/classic/views/report_event_audit.php index 39f5178f0..e779d3bdf 100644 --- a/web/skins/classic/views/report_event_audit.php +++ b/web/skins/classic/views/report_event_audit.php @@ -149,11 +149,13 @@ while( $event = $result->fetch(PDO::FETCH_ASSOC) ) { for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) { $monitor = $displayMonitors[$monitor_i]; $Monitor = new Monitor($monitor); + + $montagereview_link = "?view=montagereview&live=0&MonitorId=". $monitor['Id'] . '&minTime='.$minTime.'&maxTime='.$maxTime; ?> - + -
+
', array_map(function($group_id){ $Group = new Group($group_id);