diff --git a/CHANGELOG.md b/CHANGELOG.md index 1065dd5a..97bde1bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### [v1.6.2](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.1)(2023-01-12) + +- ServerMonitor资源监控阀值可配置 + ### [v1.6.1](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.1)(2022-12-12) - 富文本编辑器增加粘贴图片和远程图片本地化 diff --git a/app/Console/Tasks/ServerMonitorTask.php b/app/Console/Tasks/ServerMonitorTask.php index 1ac2e14b..8f054931 100644 --- a/app/Console/Tasks/ServerMonitorTask.php +++ b/app/Console/Tasks/ServerMonitorTask.php @@ -53,7 +53,9 @@ class ServerMonitorTask extends Task $load = sys_getloadavg(); - if ($load[1] > $cpuCount * 0.8) { + $limit = $this->getConfig()->path('server_monitor.cpu', 0.8); + + if ($load[1] > $cpuCount * $limit) { return sprintf("cpu负载超过%s", $load[1]); } @@ -82,7 +84,9 @@ class ServerMonitorTask extends Task $left = 100 * ($available / $total); - if ($left < 20) { + $limit = $this->getConfig()->path('server_monitor.memory', 10); + + if ($left < $limit) { return sprintf("memory剩余不足%s%%", round($left)); } @@ -96,7 +100,9 @@ class ServerMonitorTask extends Task $left = 100 * $free / $total; - if ($left < 20) { + $limit = $this->getConfig()->path('server_monitor.disk', 20); + + if ($left < $limit) { return sprintf("disk剩余不足%s%%", round($left)); } diff --git a/app/Library/AppInfo.php b/app/Library/AppInfo.php index 1242f294..70774c80 100644 --- a/app/Library/AppInfo.php +++ b/app/Library/AppInfo.php @@ -16,7 +16,7 @@ class AppInfo protected $link = 'https://www.koogua.com'; - protected $version = '1.6.1'; + protected $version = '1.6.2'; public function __get($name) { @@ -28,6 +28,8 @@ class AppInfo if (isset($this->{$name})) { return $this->{$name}; } + + return null; } } \ No newline at end of file diff --git a/config/config.default.php b/config/config.default.php index 41836295..2ee61586 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -172,4 +172,19 @@ $config['websocket']['connect_address'] = 'your_domain.com:8282'; */ $config['websocket']['register_address'] = '127.0.0.1:1238'; +/** + * 资源监控: CPU负载(0.1-1.0) + */ +$config['server_monitor']['cpu'] = 0.8; + +/** + * 资源监控: 内存剩余占比(10-100)% + */ +$config['server_monitor']['memory'] = 10; + +/** + * 资源监控: 磁盘剩余占比(10-100)% + */ +$config['server_monitor']['disk'] = 20; + return $config;