Fix high disk usage notification bug in
ServerStatusJob.php and HighDiskUsage.php
This commit is contained in:
parent
2fe429fe92
commit
81437e6822
@ -33,11 +33,13 @@ class ServerStatusJob implements ShouldQueue, ShouldBeEncrypted
|
||||
{
|
||||
ray("checking server status for {$this->server->id}");
|
||||
try {
|
||||
|
||||
$this->server->checkServerRediness();
|
||||
$disk_usage = $this->server->getDiskUsage();
|
||||
ray($this->server->settings->cleanup_after_percentage);
|
||||
if ($disk_usage >= $this->server->settings->cleanup_after_percentage) {
|
||||
if ($this->server->high_disk_usage_notification_sent) {
|
||||
ray('high disk usage notification already sent');
|
||||
return;
|
||||
}
|
||||
$this->server->high_disk_usage_notification_sent = true;
|
||||
$this->server->save();
|
||||
$this->server->team->notify(new HighDiskUsage($this->server, $disk_usage, $this->server->settings->cleanup_after_percentage));
|
||||
|
@ -18,9 +18,6 @@ class HighDiskUsage extends Notification implements ShouldQueue
|
||||
public $tries = 1;
|
||||
public function __construct(public Server $server, public int $disk_usage, public int $cleanup_after_percentage)
|
||||
{
|
||||
if ($this->server->high_disk_usage_notification_sent === false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function via(object $notifiable): array
|
||||
@ -56,13 +53,13 @@ class HighDiskUsage extends Notification implements ShouldQueue
|
||||
|
||||
public function toDiscord(): string
|
||||
{
|
||||
$message = "Coolify: Server '{$this->server->name}' high disk usage detected! \nDisk usage: {$this->disk_usage}";
|
||||
$message = "Coolify: Server '{$this->server->name}' high disk usage detected! \nDisk usage: {$this->disk_usage}. Please cleanup your disk to prevent data-loss. Here are some tips: https://coolify.io/docs/automated-cleanup.";
|
||||
return $message;
|
||||
}
|
||||
public function toTelegram(): array
|
||||
{
|
||||
return [
|
||||
"message" => "Coolify: Server '{$this->server->name}' high disk usage detected! \n Disk usage: {$this->disk_usage}"
|
||||
"message" => "Coolify: Server '{$this->server->name}' high disk usage detected! \n Disk usage: {$this->disk_usage}. Please cleanup your disk to prevent data-loss. Here are some tips: https://coolify.io/docs/automated-cleanup."
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
<x-emails.layout>
|
||||
|
||||
Your server ({{ $name }}) has high disk usage ({{ $disk_usage }}%).
|
||||
Your server ({{ $name }}) has high disk usage ({{ $disk_usage }}% used). Threshold is {{ $threshold }}%.
|
||||
|
||||
Threshold is {{ $threshold }}% (you can change it in the Server Settings menu).
|
||||
Please cleanup your disk to prevent data-loss. Here are some [tips](https://coolify.io/docs/automated-cleanup).
|
||||
|
||||
(You can change the threshold in the Server Settings menu.)
|
||||
|
||||
</x-emails.layout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user