-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aec8aa8
commit 887dbc2
Showing
10 changed files
with
135 additions
and
18 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
web/Modules/Email/App/Filament/Pages/EmailHealthStatusPage.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Modules\Email\App\Filament\Pages; | ||
|
||
use Filament\Forms\Concerns\InteractsWithForms; | ||
use Filament\Forms\Contracts\HasForms; | ||
use Filament\Pages\Page; | ||
use Filament\Tables\Columns\TextColumn; | ||
use Filament\Tables\Concerns\InteractsWithTable; | ||
use Filament\Tables\Contracts\HasTable; | ||
use Filament\Tables\Table; | ||
use Modules\Email\App\Models\EmailHealthStatus; | ||
|
||
class EmailHealthStatusPage extends Page implements HasForms, HasTable | ||
{ | ||
|
||
use InteractsWithTable; | ||
use InteractsWithForms; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-heart'; | ||
protected static string $view = 'email::filament.pages.email-health-status'; | ||
protected static ?string $navigationGroup = 'Email'; | ||
protected static ?string $navigationLabel = 'Email Health Status'; | ||
|
||
public function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
TextColumn::make('service') | ||
->label('Service') | ||
->sortable(), | ||
TextColumn::make('status') | ||
->label('Status') | ||
->badge() | ||
->sortable(), | ||
]) | ||
->query(fn () => EmailHealthStatus::query()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Modules\Email\App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Modules\Email\App\Services\EmailHealthService; | ||
use Sushi\Sushi; | ||
|
||
class EmailHealthStatus extends Model | ||
{ | ||
use Sushi; | ||
|
||
protected $schema = [ | ||
'service' => 'string', | ||
'status' => 'string', | ||
]; | ||
|
||
public function getRows() | ||
{ | ||
$service = new EmailHealthService(); | ||
|
||
return [ | ||
[ | ||
'service' => 'Dovecot', | ||
'status' => $service->checkDovecotStatus(), | ||
], | ||
[ | ||
'service' => 'Postfix', | ||
'status' => $service->checkPostfixStatus(), | ||
], | ||
[ | ||
'service' => 'OpenDKIM', | ||
'status' => $service->checkOpenDkimStatus(), | ||
], | ||
[ | ||
'service' => 'Firewall', | ||
'status' => $service->checkFirewallStatus(), | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Modules\Email\App\Services; | ||
|
||
class EmailHealthService | ||
{ | ||
public function checkDovecotStatus(): string | ||
{ | ||
return $this->checkServiceStatus('dovecot'); | ||
} | ||
|
||
public function checkPostfixStatus(): string | ||
{ | ||
return $this->checkServiceStatus('postfix'); | ||
} | ||
|
||
public function checkOpenDkimStatus(): string | ||
{ | ||
return $this->checkServiceStatus('opendkim'); | ||
} | ||
|
||
public function checkFirewallStatus(): string | ||
{ | ||
return shell_exec('sudo ufw status'); | ||
} | ||
|
||
private function checkServiceStatus(string $serviceName): string | ||
{ | ||
$status = shell_exec("systemctl is-active $serviceName"); | ||
return trim($status) === 'active' ? 'Running' : 'Not Running'; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
web/Modules/Email/resources/views/filament/pages/email-health-status.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<x-filament-panels::page> | ||
<div> | ||
{{ $this->table }} | ||
</div> | ||
</x-filament-panels::page> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.