|
|
@@ -11,22 +11,21 @@ class Alarm
|
|
|
// 推送预警信息API
|
|
|
private static $reportApi = '/api/report';
|
|
|
|
|
|
- // 业务环境白名单
|
|
|
- private static $allowPlatform = ['ng-frontend-api.elken.com', 'ng-backend-api.elken.com'];
|
|
|
-
|
|
|
public static function reportAlarm($message)
|
|
|
{
|
|
|
+ // 业务环境白名单
|
|
|
+// $allowPlatform = \Yii::$app->params['allowPlatform'];
|
|
|
// 是否开启预警信息推送
|
|
|
$reportAlarmOpen = Cache::getSystemConfig()['reportAlarmOpen']['VALUE'];
|
|
|
// 业务平台token
|
|
|
$message['platform-id'] = \Yii::$app->params['alarmAccessToken'];
|
|
|
// 日志入库
|
|
|
Tool::alarmCall($message);
|
|
|
-
|
|
|
+ // 日志写文件
|
|
|
LoggerTool::error($message);
|
|
|
|
|
|
// 业务环境过滤
|
|
|
- if ($reportAlarmOpen && (count(self::$allowPlatform) == 0 || in_array($_SERVER['HTTP_HOST'], self::$allowPlatform))) {
|
|
|
+ if ($reportAlarmOpen /**&& (count($allowPlatform) == 0 || in_array($_SERVER['HTTP_HOST'], $allowPlatform))*/) {
|
|
|
$result = self::curl(json_encode($message));
|
|
|
if ($result['code'] != 200) {
|
|
|
// 重新推送一次,如果失败,写错误日志
|
|
|
@@ -36,11 +35,13 @@ class Alarm
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
+ $reason = '';
|
|
|
if ($reportAlarmOpen == '0') {
|
|
|
$reason = '上报预警平台状态不允许(reportAlarmOpen=关闭)';
|
|
|
- } else {
|
|
|
- $reason = '主机地址不在白名单中(host=' . $_SERVER['HTTP_HOST'] . ')';
|
|
|
}
|
|
|
+// if (!count($allowPlatform)) {
|
|
|
+// $reason = '主机地址不在白名单中(host=' . $_SERVER['HTTP_HOST'] . ')';
|
|
|
+// }
|
|
|
LoggerTool::error('预警信息上报平台取消. traceId【' . $message['trace-id'] . '】. 原因:' . $reason);
|
|
|
}
|
|
|
}
|