+ [task#121514] Show volume metrics.
This commit is contained in:
@@ -10,6 +10,7 @@ declare(strict_types=1);
|
||||
* @version $Id$
|
||||
* @link https://www.zentao.net
|
||||
* @property actionModel $action
|
||||
* @property cneModel $cne
|
||||
*/
|
||||
class instanceModel extends model
|
||||
{
|
||||
@@ -958,6 +959,31 @@ class instanceModel extends model
|
||||
return array('color' => $color, 'tip' => $tip, 'rate' => $rate . '%', 'usage' => helper::formatKB($metrics->usage), 'limit' => helper::formatKB($metrics->limit));
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印存储使用信息。
|
||||
* Print the volume usage.
|
||||
*
|
||||
* @param object $instance
|
||||
* @param object $metrics
|
||||
* @static
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public static function printVolUsage(object $instance, object $metrics): array
|
||||
{
|
||||
if($instance->source === 'user') return array('color' => '', 'tip' => '', 'rate' => '', 'usage' => '', 'limit' => '');
|
||||
$rate = $instance->status == 'stopped' ? 0 : $metrics->rate;
|
||||
$tip = "{$rate}% = " . helper::formatKB($metrics->usage) . ' / ' . helper::formatKB($metrics->limit);
|
||||
|
||||
if(empty($color) && $rate == 0) $color = 'gray';
|
||||
if(empty($color) && $rate > 0 && $rate < 50) $color = 'secondary';
|
||||
if(empty($color) && $rate >= 0 && $rate < 70) $color = 'warning';
|
||||
if(empty($color) && $rate >= 0 && $rate < 90) $color = 'important';
|
||||
if(empty($color) && $rate >= 80) $color = 'danger';
|
||||
|
||||
return array('color' => $color, 'tip' => $tip, 'rate' => $rate . '%', 'usage' => helper::formatKB($metrics->usage), 'limit' => helper::formatKB($metrics->limit));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查内存是否充足。
|
||||
* Check the free memory of cluster is enough to install app.
|
||||
|
||||
Reference in New Issue
Block a user