alarm email add human time

This commit is contained in:
xiaomlove
2024-03-23 23:18:30 +08:00
parent 92bfa5df84
commit dc318819bb
5 changed files with 7 additions and 5 deletions

View File

@@ -98,8 +98,7 @@ class Test extends Command
*/
public function handle()
{
$interval = 100;
$diff = sprintf("*/%d * * * *", ceil($interval/60));
$diff = get_setting("system.alarm_email_receiver");
dd($diff);
}

View File

@@ -250,6 +250,7 @@ LUA;
continue;
}
$receiverUid = get_setting("system.alarm_email_receiver");
do_log("receiverUid: $receiverUid");
if (empty($receiverUid)) {
$locale = Locale::getDefault();
$subject = self::getAlarmEmailSubject($locale);
@@ -282,7 +283,9 @@ LUA;
"level" => $level,
"last_time" => $lastTime > 0 ? Carbon::createFromTimestamp($lastTime)->toDateTimeString() : "",
"elapsed_seconds" => $lastTime > 0 ? $now->getTimestamp() - $lastTime : "",
"elapsed_seconds_human" => $lastTime > 0 ? mkprettytime($now->getTimestamp() - $lastTime) : "",
"interval" => $interval,
"interval_human" => mkprettytime($interval),
], $locale);
}
}

View File

@@ -9,5 +9,5 @@ return [
'disable_user_parked' => 'Disable inactive user accounts, parked.',
'destroy_disabled_account' => 'Timed physical deletion of disabled accounts',
'alarm_email_subject' => '[:site_name] background cleanup task exception',
'alarm_email_body' => 'Current time: :now_time, level :level, Last run time was: :last_time, it has been more than: :elapsed_seconds seconds since it was run, the set run interval is: :interval seconds, please check!',
'alarm_email_body' => 'Current time: :now_time, level :level, Last run time was: :last_time, it has been more than: :elapsed_seconds seconds(:elapsed_seconds_human) since it was run, the set run interval is: :interval seconds(:interval_human), please check!',
];

View File

@@ -9,5 +9,5 @@ return [
'disable_user_parked' => '定时封禁已挂起的非活跃账号.',
'destroy_disabled_account' => '定时物理删除已封禁账号',
'alarm_email_subject' => '[:site_name]后台清理任务异常',
'alarm_email_body' => '当前时间::now_time, 级别 :level 上次运行时间是::last_time已经超过:elapsed_seconds 秒没有运行,设置的运行间隔是::interval 秒,请检查!',
'alarm_email_body' => '当前时间::now_time, 级别 :level 上次运行时间是::last_time已经超过:elapsed_seconds 秒:elapsed_seconds_human没有运行,设置的运行间隔是::interval 秒:interval_human,请检查!',
];

View File

@@ -9,5 +9,5 @@ return [
'disable_user_parked' => '定時封禁已掛起的非活躍賬號.',
'destroy_disabled_account' => '定時物理刪除已封禁賬號',
'alarm_email_subject' => '[:site_name]後臺清理任務異常',
'alarm_email_body' => '當前時間::now_time, 級別 :level 上次運行時間是::last_time已經超過:elapsed_seconds 秒沒有運行,設置的運行間隔是::interval 秒,請檢查!',
'alarm_email_body' => '當前時間::now_time, 級別 :level 上次運行時間是::last_time已經超過:elapsed_seconds 秒:elapsed_seconds_human沒有運行,設置的運行間隔是::interval 秒:interval_human,請檢查!',
];