fix: Fix the initialization issue of alert tasks (#10191)

This commit is contained in:
2025-08-29 13:56:15 +08:00 committed by GitHub
parent 339d6732d7
commit dfbd364f60
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 36 additions and 15 deletions

View file

@ -1,6 +1,7 @@
package hook
import (
"github.com/1Panel-dev/1Panel/agent/app/service"
"github.com/1Panel-dev/1Panel/agent/utils/alert_push"
"os"
"strings"
@ -23,6 +24,7 @@ func Init() {
loadLocalDir()
initDockerConf()
initAlertTask()
}
func initGlobalData() {
@ -125,3 +127,7 @@ func initDockerConf() {
constant.DaemonJsonPath = "/var/snap/docker/current/config/daemon.json"
}
}
func initAlertTask() {
service.NewIAlertTaskHelper().ResetTask()
}

View file

@ -3759,7 +3759,8 @@ const message = {
sshLogin: 'SSH Login Exception Alert',
panelIpLogin: 'Panel Login IP Exception Alert',
sshIpLogin: 'SSH Login IP Exception Alert',
ipWhiteListHelper: 'IPs in the whitelist are not restricted by any rules',
ipWhiteListHelper:
'IPs in the whitelist are not restricted by rules, and there will be no alert upon successful login',
nodeExceptionRule: 'Node exception alert, sent {0} times per day',
licenseExceptionRule: 'License exception alert, sent {0} times per day',
panelLoginRule: 'Panel login alert, sent {0} times per day',

View file

@ -3637,7 +3637,8 @@ const message = {
sshLogin: 'SSHログイン異常アラート',
panelIpLogin: 'パネルログインIP異常アラート',
sshIpLogin: 'SSHログインIP異常アラート',
ipWhiteListHelper: 'ホワイトリスト内のIPはいかなるルールの制限も受けません',
ipWhiteListHelper:
'ホワイトリストに登録されたIPはルールの制限を受けずログインが成功してもアラートは発生しません',
nodeExceptionRule: 'ノード異常アラートは1日あたり{0}回送信',
licenseExceptionRule: 'ライセンス異常アラートは1日あたり{0}回送信',
panelLoginRule: 'パネルログインアラートは1日あたり{0}回送信',

View file

@ -3573,7 +3573,8 @@ const message = {
sshLogin: 'SSH 로그인 이상 알림',
panelIpLogin: '패널 로그인 IP 이상 알림',
sshIpLogin: 'SSH 로그인 IP 이상 알림',
ipWhiteListHelper: '화이트리스트에 있는 IP는 어떠한 규칙의 제한도 받지 않습니다',
ipWhiteListHelper:
'화이트리스트에 있는 IP는 규칙의 제한을 받지 않으며, 로그인에 성공해도 알림이 발생하지 않습니다',
nodeExceptionRule: '노드 이상 알림은 하루 {0} 전송',
licenseExceptionRule: '라이선스 이상 알림은 하루 {0} 전송',
panelLoginRule: '패널 로그인 알림은 하루 {0} 전송',

View file

@ -3723,7 +3723,8 @@ const message = {
sshLogin: 'Amaran Log Masuk SSH Tidak Normal',
panelIpLogin: 'Amaran IP Log Masuk Panel Tidak Normal',
sshIpLogin: 'Amaran IP Log Masuk SSH Tidak Normal',
ipWhiteListHelper: 'IP dalam senarai putih tidak tertakluk kepada sebarang peraturan',
ipWhiteListHelper:
'IP dalam senarai putih tidak tertakluk kepada peraturan, dan tiada amaran akan dikeluarkan apabila log masuk berjaya',
nodeExceptionRule: 'Amaran kerosakan nod, dihantar {0} kali sehari',
licenseExceptionRule: 'Amaran kerosakan lesen, dihantar {0} kali sehari',
panelLoginRule: 'Amaran log masuk panel, dihantar {0} kali sehari',

View file

@ -3731,7 +3731,8 @@ const message = {
sshLogin: 'Alerta de Exceção de Login SSH',
panelIpLogin: 'Alerta de Exceção de IP de Login no Painel',
sshIpLogin: 'Alerta de Exceção de IP de Login SSH',
ipWhiteListHelper: 'IPs na lista branca não estão sujeitos a nenhuma regra',
ipWhiteListHelper:
'Os IPs na lista de permissões não são restringidos pelas regras e não haverá alerta em caso de login bem-sucedido',
nodeExceptionRule: 'Alerta de exceção de , enviado {0} vezes por dia',
licenseExceptionRule: 'Alerta de exceção de licença, enviado {0} vezes por dia',
panelLoginRule: 'Alerta de login no painel, enviado {0} vezes por dia',

View file

@ -3722,7 +3722,8 @@ const message = {
sshLogin: 'Оповещение о сбое входа по SSH',
panelIpLogin: 'Оповещение о сбое IP входа в панель',
sshIpLogin: 'Оповещение о сбое IP входа по SSH',
ipWhiteListHelper: 'IP-адреса в белом списке не подпадают под действие каких-либо правил',
ipWhiteListHelper:
'IP-адреса в белом списке не ограничиваются правилами, и при успешном входе оповещение не создается',
nodeExceptionRule: 'Оповещение о сбое узла, отправляется {0} раз в день',
licenseExceptionRule: 'Оповещение о сбое лицензии, отправляется {0} раз в день',
panelLoginRule: 'Оповещение о входе в панель, отправляется {0} раз в день',

View file

@ -3801,7 +3801,8 @@ const message = {
sshLogin: 'SSH Girişi Hatası Uyarısı',
panelIpLogin: 'Panel Girişi IP Hatası Uyarısı',
sshIpLogin: 'SSH Girişi IP Hatası Uyarısı',
ipWhiteListHelper: 'Beyaz listedeki IPler herhangi bir kuralla kısıtlanmaz',
ipWhiteListHelper:
'Beyaz listedeki IPler kurallara tabi değildir ve başarılı girişlerde uyarı oluşturulmaz',
nodeExceptionRule: 'Düğüm hatası uyarısı, günde {0} kez gönderilir',
licenseExceptionRule: 'Lisans hatası uyarısı, günde {0} kez gönderilir',
panelLoginRule: 'Panel girişi uyarısı, günde {0} kez gönderilir',

View file

@ -3499,7 +3499,7 @@ const message = {
sshLogin: 'SSH 登入異常告警',
panelIpLogin: '面板登入 IP 異常告警',
sshIpLogin: 'SSH 登入 IP 異常告警',
ipWhiteListHelper: '白名單中的 IP 不受任何規則限制',
ipWhiteListHelper: '白名單中的 IP 不受規則限制成功登入時也不會產生警報',
nodeExceptionRule: '節點異常告警每天發送 {0} ',
licenseExceptionRule: '許可證異常告警每天發送 {0} ',
panelLoginRule: '面板登入告警每天發送 {0} ',

View file

@ -3469,7 +3469,7 @@ const message = {
sshLogin: 'SSH 登录异常告警',
panelIpLogin: '面板登录 IP 异常告警',
sshIpLogin: 'SSH 登录 IP 异常告警',
ipWhiteListHelper: '白名单中的 IP 不受任何规则限制',
ipWhiteListHelper: '白名单中的 IP 不受规则限制登录成功不进行告警',
nodeExceptionRule: '节点异常告警每天发送 {0} ',
licenseExceptionRule: '许可证异常告警每天发送 {0} ',
panelLoginRule: '面板登录告警每天发送 {0} ',

View file

@ -18,8 +18,16 @@
<template v-if="isMaster">
<el-option value="panelPwdEndTime" :label="$t('xpack.alert.panelPwdEndTime')" />
<el-option value="panelLogin" :label="$t('xpack.alert.panelLogin')" />
<el-option value="licenseException" :label="$t('xpack.alert.licenseException')" />
<el-option value="nodeException" :label="$t('xpack.alert.nodeException')" />
<el-option
v-if="isProductPro"
value="licenseException"
:label="$t('xpack.alert.licenseException')"
/>
<el-option
v-if="isProductPro"
value="nodeException"
:label="$t('xpack.alert.nodeException')"
/>
<el-option value="panelUpdate" :label="$t('xpack.alert.panelUpdate')" />
</template>
<el-option value="sshLogin" :label="$t('xpack.alert.sshLogin')" />
@ -142,7 +150,7 @@ import { UpdateAlertStatus, SearchAlerts, DeleteAlert } from '@/api/modules/aler
import { storeToRefs } from 'pinia';
const globalStore = GlobalStore();
const { isMaster } = storeToRefs(globalStore);
const { isMaster, isProductPro } = storeToRefs(globalStore);
const { t } = i18n.global;
const loading = ref(false);

View file

@ -371,7 +371,7 @@ import { routerToName } from '@/utils/router';
import { checkCidr, checkCidrV6, checkIpV4V6 } from '@/utils/util';
const globalStore = GlobalStore();
const { isMaster } = storeToRefs(globalStore);
const { isMaster, isProductPro } = storeToRefs(globalStore);
interface DialogProps {
title: string;
@ -441,10 +441,10 @@ const allTaskOptions = [
{ value: 'panelPwdEndTime', label: 'xpack.alert.panelPwdEndTime', show: isMaster.value },
{ value: 'panelLogin', label: 'xpack.alert.panelLogin', show: isMaster.value },
{ value: 'sshLogin', label: 'xpack.alert.sshLogin', show: true },
{ value: 'licenseException', label: 'xpack.alert.licenseException', show: isMaster.value },
{ value: 'licenseException', label: 'xpack.alert.licenseException', show: isMaster.value && isProductPro.value },
{ value: 'ssl', label: 'xpack.alert.ssl', show: true },
{ value: 'siteEndTime', label: 'xpack.alert.siteEndTime', show: true },
{ value: 'nodeException', label: 'xpack.alert.nodeException', show: isMaster.value },
{ value: 'nodeException', label: 'xpack.alert.nodeException', show: isMaster.value && isProductPro.value },
{ value: 'cpu', label: 'xpack.alert.cpu', show: true },
{ value: 'memory', label: 'xpack.alert.memory', show: true },
{ value: 'disk', label: 'xpack.alert.disk', show: true },