add disk_usage_percent and fix whitespace
parent
5604fe5610
commit
f06723a178
|
@ -31,6 +31,15 @@ class Storage {
|
||||||
}
|
}
|
||||||
return $this->{'Name'};
|
return $this->{'Name'};
|
||||||
}
|
}
|
||||||
|
public function Name() {
|
||||||
|
if ( isset( $this->{'Name'} ) and ( $this->{'Name'} != '' ) ) {
|
||||||
|
return $this->{'Name'};
|
||||||
|
} else if ( ! isset($this->{'Id'}) ) {
|
||||||
|
return 'Default';
|
||||||
|
}
|
||||||
|
return $this->{'Name'};
|
||||||
|
}
|
||||||
|
|
||||||
public function __call( $fn, array $args= NULL){
|
public function __call( $fn, array $args= NULL){
|
||||||
if(isset($this->{$fn})){
|
if(isset($this->{$fn})){
|
||||||
return $this->{$fn};
|
return $this->{$fn};
|
||||||
|
@ -47,5 +56,19 @@ class Storage {
|
||||||
}
|
}
|
||||||
return $storage_areas;
|
return $storage_areas;
|
||||||
}
|
}
|
||||||
|
public function disk_usage_percent() {
|
||||||
|
$path = $this->Path();
|
||||||
|
$total = disk_total_space( $path );
|
||||||
|
if ( ! $total ) {
|
||||||
|
Error("disk_total_space returned false for " . $path );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
$free = disk_free_space( $path );
|
||||||
|
if ( ! $free ) {
|
||||||
|
Error("disk_free_space returned false for " . $path );
|
||||||
|
}
|
||||||
|
$usage = round(($total - $free) / $total * 100);
|
||||||
|
return $usage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue