|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace App\Models;
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
+use App\ApiSDK\PhyreApiSDK;
|
|
use App\Events\ModelPhyreServerCreated;
|
|
use App\Events\ModelPhyreServerCreated;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
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();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|