<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * One persisted point of a server's resource history (cpu/mem/disk %, load), sampled once a minute
 * by clusev:sample-metrics. The live 15s view stays cache-backed; this table is the LONG history
 * the Server-Details graph plots over selectable ranges. Pruned to a retention window.
 */
class MetricSample extends Model
{
    public $timestamps = false;

    protected $guarded = [];

    protected $casts = [
        'cpu' => 'integer',
        'mem' => 'integer',
        'disk' => 'integer',
        'load' => 'float',
        'sampled_at' => 'datetime',
    ];

    public function server(): BelongsTo
    {
        return $this->belongsTo(Server::class);
    }
}
