1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-07-10 10:40:03 +08:00

ServerMonitor资源监控阀值可配置

This commit is contained in:
xiaochong0302 2022-12-20 16:36:13 +08:00
parent 2a20d1eb2e
commit 254a78f246
3 changed files with 25 additions and 3 deletions

View File

@ -1,5 +1,6 @@
### [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)

View File

@ -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));
}

View File

@ -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;