Browse Source

修复节点离线提醒

admin 7 years ago
parent
commit
287fe6b3bb

+ 1 - 1
app/Console/Commands/AutoCheckNodeTCP.php

@@ -165,7 +165,7 @@ class AutoCheckNodeTCP extends Command
      */
      */
     private function notifyMasterByEmail($title, $content, $nodeName, $nodeServer)
     private function notifyMasterByEmail($title, $content, $nodeName, $nodeServer)
     {
     {
-        if (self::$systemConfig['is_node_crash_warning'] && self::$systemConfig['crash_warning_email']) {
+        if (self::$systemConfig['crash_warning_email']) {
             $logId = Helpers::addEmailLog(self::$systemConfig['crash_warning_email'], $title, $content);
             $logId = Helpers::addEmailLog(self::$systemConfig['crash_warning_email'], $title, $content);
             Mail::to(self::$systemConfig['crash_warning_email'])->send(new nodeCrashWarning($logId, $nodeName, $nodeServer));
             Mail::to(self::$systemConfig['crash_warning_email'])->send(new nodeCrashWarning($logId, $nodeName, $nodeServer));
         }
         }

+ 8 - 6
app/Console/Commands/AutoJob.php

@@ -538,12 +538,14 @@ class AutoJob extends Command
     // 检测节点是否离线
     // 检测节点是否离线
     private function checkNodeStatus()
     private function checkNodeStatus()
     {
     {
-        $nodeList = SsNode::query()->where('status', 1)->get();
-        foreach ($nodeList as $node) {
-            // 10分钟内无节点负载信息且TCP检测认为不是离线则认为是后端炸了
-            $nodeTTL = SsNodeInfo::query()->where('node_id', $node->id)->where('log_time', '>=', strtotime("-10 minutes"))->orderBy('id', 'desc')->first();
-            if (!$nodeTTL) {
-                ServerChan::send('节点异常警告', "节点**{$node->name}【{$node->ip}】**异常:**心跳异常,可能离线了**");
+        if (Helpers::systemConfig()['is_node_crash_warning']) {
+            $nodeList = SsNode::query()->where('status', 1)->get();
+            foreach ($nodeList as $node) {
+                // 10分钟内无节点负载信息且TCP检测认为不是离线则认为是后端炸了
+                $nodeTTL = SsNodeInfo::query()->where('node_id', $node->id)->where('log_time', '>=', strtotime("-10 minutes"))->orderBy('id', 'desc')->first();
+                if (!$nodeTTL) {
+                    ServerChan::send('节点异常警告', "节点**{$node->name}【{$node->ip}】**异常:**心跳异常,可能离线了**");
+                }
             }
             }
         }
         }
     }
     }

+ 1 - 1
resources/views/admin/system.blade.php

@@ -549,7 +549,7 @@
                                                             <label for="is_node_crash_warning" class="col-md-3 control-label">节点离线提醒</label>
                                                             <label for="is_node_crash_warning" class="col-md-3 control-label">节点离线提醒</label>
                                                             <div class="col-md-9">
                                                             <div class="col-md-9">
                                                                 <input type="checkbox" class="make-switch" @if($is_node_crash_warning) checked @endif id="is_node_crash_warning" data-on-color="success" data-off-color="danger" data-on-text="启用" data-off-text="关闭">
                                                                 <input type="checkbox" class="make-switch" @if($is_node_crash_warning) checked @endif id="is_node_crash_warning" data-on-color="success" data-off-color="danger" data-on-text="启用" data-off-text="关闭">
-                                                                <span class="help-block"> 启用后如果节点离线则发出提醒邮件 </span>
+                                                                <span class="help-block"> 启用后如果节点离线则通过ServerChan推送提醒 </span>
                                                             </div>
                                                             </div>
                                                         </div>
                                                         </div>
                                                         <div class="col-md-6 col-sm-6 col-xs-12">
                                                         <div class="col-md-6 col-sm-6 col-xs-12">