update
This commit is contained in:
parent
742dddb16a
commit
7a0e333e00
3 changed files with 24 additions and 4 deletions
|
@ -1,11 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace app\ApiSDK;
|
||||
namespace App\ApiSDK;
|
||||
|
||||
class PhyreApiSDK
|
||||
{
|
||||
public $ip;
|
||||
public $port;
|
||||
public $port = 8443;
|
||||
public $password;
|
||||
public $username;
|
||||
|
||||
|
@ -38,7 +37,7 @@ class PhyreApiSDK
|
|||
// ));
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,6 +77,10 @@ class PhyreServerResource extends Resource
|
|||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\Action::make('Refresh Status')
|
||||
->action(function ($record) {
|
||||
$record->healthCheck();
|
||||
}),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\ApiSDK\PhyreApiSDK;
|
||||
use App\Events\ModelPhyreServerCreated;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
@ -28,4 +29,20 @@ class PhyreServer extends Model
|
|||
|
||||
}
|
||||
|
||||
public function healthCheck()
|
||||
{
|
||||
try {
|
||||
$phyreApiSDK = new PhyreApiSDK($this->ip, 8443, $this->password, $this->username);
|
||||
$response = $phyreApiSDK->healthCheck();
|
||||
if (isset($response['status']) && $response['status'] == 'ok') {
|
||||
$this->status = 'Online';
|
||||
$this->save();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->status = 'Offline';
|
||||
$this->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue