@extends('layouts.app') @section('title', '編輯主機') @push('styles') @endpush @section('content')
{{-- 標頭 --}}

編輯主機 {{ $host->name }}

返回主機清單
@csrf @method('PUT') {{-- ─── 識別資訊 ─────────────────────────────── --}}
{{-- 關聯專案 + 主機類型 同一行 --}}
@error('project_id')
{{ $message }}
@enderror
{{-- 主機名稱 + 作業系統 + 狀態 同一行 --}}
@error('name')
{{ $message }}
@enderror
{{-- ─── 網路資訊 ─────────────────────────────── --}}
{{-- IP 位址 + Port + API 網址 同一行 --}}
@error('ip_address')
{{ $message }}
@enderror
@error('port')
{{ $message }}
@enderror
@error('api_url')
{{ $message }}
@enderror
{{-- ─── 認證資訊 ─────────────────────────────── --}}
@error('username')
{{ $message }}
@enderror
@error('password')
{{ $message }}
@enderror
{{-- 告警閾值(個別覆蓋) --}} @php $gCpu = \App\Models\SystemSetting::get('host_alert_cpu', 85); $gMem = \App\Models\SystemSetting::get('host_alert_mem', 85); $gDisk = \App\Models\SystemSetting::get('host_alert_disk', 80); $gCpuCrit = \App\Models\SystemSetting::get('host_alert_cpu_critical', 95); $gMemCrit = \App\Models\SystemSetting::get('host_alert_mem_critical', 95); $gDiskCrit = \App\Models\SystemSetting::get('host_alert_disk_critical', 90); @endphp
告警閾值 留空則沿用全域設定 修改全域設定
警告(中)
超過→推播
嚴重(高)
超過/多項/連3次→寄信
CPU
%
%
記憶體
%
%
磁碟
%
%
{{-- 告警通知信箱 --}}
例:ops@example.com, manager@example.com
{{-- 按鈕 --}}
取消
{{-- Agent Token --}}
監控 Agent 設定

在目標主機安裝 Agent 後,Agent 會每 5 分鐘自動推送系統報告到本平台。
適用於無法對外開放 API 的主機(DB、檔案伺服器、內部 IP 等)。

@if ($host->agent_token)
@if ($host->agent_last_report_at) 最後回報:{{ $host->agent_last_report_at->diffForHumans() }} @else 尚未收到任何回報 @endif
@php $installerUrl = url("/api/agent/installer/{$host->agent_token}"); $isWin = ($host->os_type ?? 'linux') === 'windows'; $installCmdVal = $isWin ? 'iex (New-Object Net.WebClient).DownloadString("' . $installerUrl . '")' : 'bash <(curl -fsSL "' . $installerUrl . '")'; $installNote = $isWin ? '以系統管理員開啟 PowerShell 執行(需 PowerShell 5.1+)' : '在目標主機以 root 執行此指令即可安裝並啟動 Agent'; @endphp
{!! $isWin ? '🪟 PS' : '🐧 SH' !!}
{{ $installNote }} @if($isWin)
若出現執行原則限制,請先執行: Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
@endif
@endif @if ($host->agent_token)
@csrf @method('PUT')
每行一個路徑,儲存後重新安裝 Agent 即生效
@endif
@csrf @if ($host->agent_token) 重新產生後舊 Token 立即失效,需重新安裝 Agent @endif
@endsection @push('scripts') @endpush