mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-07-13 14:42:27 -04:00
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
This commit is contained in:
@@ -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
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -341,11 +341,11 @@ fieldset > legend {
|
||||
/*
|
||||
* Behavior classes
|
||||
*/
|
||||
.alarm, .errorText {
|
||||
.alarm, .errorText, .error {
|
||||
color: #ff3f34;
|
||||
}
|
||||
|
||||
.alert, .warnText {
|
||||
.alert, .warnText, .warning {
|
||||
color: #ffa801;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 '<span title="'.human_filesize($S->disk_used_space()) . ' of ' . human_filesize($S->disk_total_space()).'">'.$S->Name() . ': ' . $S->disk_usage_percent().'%' . '</span>'; };
|
||||
$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 '<span class="'.$class.'" title="'.$title.'">'.$S->Name() . ': ' . $S->disk_usage_percent().'%' . '</span>'; };
|
||||
#$func = function($S){ return '<span title="">'.$S->Name() . ': ' . $S->disk_usage_percent().'%' . '</span>'; };
|
||||
if ( count($storage_areas) >= 4 )
|
||||
$storage_areas = Storage::find_all( array('ServerId'=>null) );
|
||||
|
||||
@@ -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;
|
||||
?>
|
||||
<tr id="<?php echo 'monitor_id-'.$monitor['Id'] ?>" title="<?php echo $monitor['Id'] ?>">
|
||||
<td class="colId"><a href="?view=watch&mid=<?php echo $monitor['Id']?>"><?php echo $monitor['Id'] ?></a></td>
|
||||
<td class="colId"><a href="<?php echo $montagereview_link ?>"><?php echo $monitor['Id'] ?></a></td>
|
||||
<td class="colName">
|
||||
<a href="?view=watch&mid=<?php echo $monitor['Id']?>"><?php echo $monitor['Name'] ?></a><br/><div class="small text-nowrap text-muted">
|
||||
<a href="<?php echo $montagereview_link ?>"><?php echo $monitor['Name'] ?></a><br/><div class="small text-nowrap text-muted">
|
||||
<?php echo implode('<br/>',
|
||||
array_map(function($group_id){
|
||||
$Group = new Group($group_id);
|
||||
|
||||
Reference in New Issue
Block a user