Newer
Older
use Illuminate\Support\Facades\Log;
class Server extends Model
{
protected $fillable = ["token"];
/**
* Last record from this server (used for caching).
* @var String
*/
private $last_record = null;
\App\Sensor\CPUtemperature::class,
$attributes["token"] = str_random(32);
parent::__construct($attributes);
}
["server_id" => $this->id],
["sort" => ["_id" => -1]]
);
if ($this->records_1day !== null) {
return $this->records_1day;
}
$this->records_1day = Mongo::get()->monitoring->records->find([
"server_id" => $this->id,
"time" => ['$gte' => $start]])
->toArray();
public function hasData() : bool
{
return $this->lastRecord() != null;
}
if (is_null($this->info)) {
$this->info = new ServerInfo($this->lastRecord());
}
*
* @return \App\Status
} catch (\Exception $ex) {
Log::error("Sensor $sensor_name failed : " . $ex->getTraceAsString());
}
$sensorsNOK[] = $sensor;
}
}
return $sensorsNOK;
}
$sensors = [];
foreach (self::$sensors as $sensor) {
$sensors[] = new SensorWrapper(new $sensor($this), $records);
return StatusChange::getLastChangesForServer($this->id, $count);