489 lines
20 KiB
Plaintext
489 lines
20 KiB
Plaintext
@model Watcher.ViewModels.ServerDetailsViewModel
|
|
@{
|
|
ViewData["Title"] = "Serverübersicht";
|
|
}
|
|
|
|
<head>
|
|
<link rel="stylesheet" href="~/css/main.css" />
|
|
<link rel="stylesheet" href="~/css/server-detail.css" />
|
|
</head>
|
|
|
|
<div id="server-cards-container">
|
|
|
|
<div class="container mt-4">
|
|
<!-- Server Overview Card -->
|
|
<div class="card shadow-sm mb-4">
|
|
<div class="card-header d-flex justify-content-between align-items-center border-bottom">
|
|
<h5 class="mb-0">
|
|
<i class="bi bi-hdd-network me-2 text-primary"></i>@Model.Name
|
|
</h5>
|
|
<div class="d-flex gap-2 align-items-center">
|
|
<span class="badge @(Model.IsOnline ? "bg-success" : "bg-danger") px-3 py-2">
|
|
<i class="bi @(Model.IsOnline ? "bi-check-circle" : "bi-x-circle") me-1"></i>
|
|
@(Model.IsOnline ? "Online" : "Offline")
|
|
</span>
|
|
<a asp-action="EditServer" asp-route-id="@Model.Id" class="btn btn-sm btn-outline-primary">
|
|
<i class="bi bi-pencil"></i> Bearbeiten
|
|
</a>
|
|
<form asp-action="Delete" asp-route-id="@Model.Id" method="post" class="d-inline m-0"
|
|
onsubmit="return confirm('Diesen Server wirklich löschen?');">
|
|
<button type="submit" class="btn btn-sm btn-outline-danger">
|
|
<i class="bi bi-trash"></i> Löschen
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
<div class="row g-4">
|
|
<!-- System Information -->
|
|
<div class="col-12 col-md-6 col-lg-3">
|
|
<h6 class="text-muted mb-3 pb-2 border-bottom">
|
|
<i class="bi bi-info-circle me-2"></i>System
|
|
</h6>
|
|
<div class="info-list">
|
|
<div class="info-item">
|
|
<span class="info-label">
|
|
<i class="bi bi-globe text-primary me-1"></i>IP-Adresse
|
|
</span>
|
|
<span class="info-value">@Model.IPAddress</span>
|
|
</div>
|
|
<div class="info-item">
|
|
<span class="info-label">
|
|
<i class="bi bi-pc-display text-primary me-1"></i>Typ
|
|
</span>
|
|
<span class="info-value">@Model.Type</span>
|
|
</div>
|
|
<div class="info-item">
|
|
<span class="info-label">
|
|
<i class="bi bi-calendar-check text-primary me-1"></i>Erstellt
|
|
</span>
|
|
<span class="info-value">@Model.CreatedAt.ToLocalTime().ToString("dd.MM.yyyy")</span>
|
|
</div>
|
|
<div class="info-item">
|
|
<span class="info-label">
|
|
<i class="bi bi-clock text-primary me-1"></i>Last Seen
|
|
</span>
|
|
<span class="info-value">
|
|
@{
|
|
var timeSinceLastSeen = DateTime.UtcNow - Model.LastSeen;
|
|
if (timeSinceLastSeen.TotalMinutes < 1)
|
|
{
|
|
<span class="text-success">Gerade eben</span>
|
|
}
|
|
else if (timeSinceLastSeen.TotalMinutes < 60)
|
|
{
|
|
<span>vor @((int)timeSinceLastSeen.TotalMinutes) Min</span>
|
|
}
|
|
else if (timeSinceLastSeen.TotalHours < 24)
|
|
{
|
|
<span>vor @((int)timeSinceLastSeen.TotalHours) Std</span>
|
|
}
|
|
else
|
|
{
|
|
<span>@Model.LastSeen.ToLocalTime().ToString("dd.MM.yyyy HH:mm")</span>
|
|
}
|
|
}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Hardware - CPU & GPU -->
|
|
<div class="col-12 col-md-6 col-lg-3">
|
|
<h6 class="text-muted mb-3 pb-2 border-bottom">
|
|
<i class="bi bi-cpu me-2"></i>Prozessor & Grafik
|
|
</h6>
|
|
<div class="info-list">
|
|
<div class="info-item">
|
|
<span class="info-label">
|
|
<i class="bi bi-cpu text-info me-1"></i>CPU
|
|
</span>
|
|
<span class="info-value">
|
|
@if (!string.IsNullOrWhiteSpace(Model.CpuType))
|
|
{
|
|
@Model.CpuType
|
|
}
|
|
else
|
|
{
|
|
<span class="text-muted">Unbekannt</span>
|
|
}
|
|
</span>
|
|
</div>
|
|
<div class="info-item">
|
|
<span class="info-label">
|
|
<i class="bi bi-grid text-info me-1"></i>CPU-Kerne
|
|
</span>
|
|
<span class="info-value">
|
|
@if (Model.CpuCores > 0)
|
|
{
|
|
@Model.CpuCores
|
|
<span class="text-muted">Cores</span>
|
|
}
|
|
else
|
|
{
|
|
<span class="text-muted">Unbekannt</span>
|
|
}
|
|
</span>
|
|
</div>
|
|
<div class="info-item">
|
|
<span class="info-label">
|
|
<i class="bi bi-gpu-card text-info me-1"></i>GPU
|
|
</span>
|
|
<span class="info-value">
|
|
@if (!string.IsNullOrWhiteSpace(Model.GpuType))
|
|
{
|
|
@Model.GpuType
|
|
}
|
|
else
|
|
{
|
|
<span class="text-muted">Keine / Unbekannt</span>
|
|
}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Hardware - Memory -->
|
|
<div class="col-12 col-md-6 col-lg-3">
|
|
<h6 class="text-muted mb-3 pb-2 border-bottom">
|
|
<i class="bi bi-memory me-2"></i>Speicher
|
|
</h6>
|
|
<div class="info-list">
|
|
<div class="info-item">
|
|
<span class="info-label">
|
|
<i class="bi bi-memory text-success me-1"></i>RAM
|
|
</span>
|
|
<span class="info-value">
|
|
@if (Model.RamSize > 0)
|
|
{
|
|
var ramGB = Model.RamSize / (1024.0 * 1024.0 * 1024.0);
|
|
@($"{ramGB:F1} GB")
|
|
}
|
|
else
|
|
{
|
|
<span class="text-muted">Unbekannt</span>
|
|
}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Description -->
|
|
@if (!string.IsNullOrWhiteSpace(Model.Description))
|
|
{
|
|
<div class="col-12 col-lg-3">
|
|
<h6 class="text-muted mb-3 pb-2 border-bottom">
|
|
<i class="bi bi-card-text me-2"></i>Beschreibung
|
|
</h6>
|
|
<p class="text-muted small mb-0">@Model.Description</p>
|
|
</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mt-4">
|
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
|
<h6 class="mb-0"><i class="bi bi-graph-up me-1"></i>Metriken</h6>
|
|
<div class="btn-group btn-group-sm" role="group">
|
|
<button type="button" class="btn btn-outline-primary active" data-range="1">1 Stunde</button>
|
|
<button type="button" class="btn btn-outline-primary" data-range="24">24 Stunden</button>
|
|
<button type="button" class="btn btn-outline-primary" data-range="48">48 Stunden</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mt-4">
|
|
<h6><i class="bi bi-graph-up me-1"></i>CPU Last</h6>
|
|
<div class="graphcontainer p-4 text-center text-muted">
|
|
<canvas class="graph" id="cpuUsageChart"></canvas>
|
|
</div>
|
|
</div>
|
|
<div class="mt-4">
|
|
<h6><i class="bi bi-graph-up me-1"></i>RAM Last</h6>
|
|
<div class="graphcontainer p-4 text-center text-muted">
|
|
<canvas class="graph" id="ramUsageChart"></canvas>
|
|
</div>
|
|
</div>
|
|
<div class="mt-4">
|
|
<h6><i class="bi bi-graph-up me-1"></i>GPU Last</h6>
|
|
<div class="graphcontainer p-4 text-center text-text">
|
|
<canvas class="graph" id="gpuUsageChart"></canvas>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
@section Scripts {
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
<script>
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
const ctx_cpu = document.getElementById('cpuUsageChart').getContext('2d');
|
|
const ctx_ram = document.getElementById('ramUsageChart').getContext('2d');
|
|
const ctx_gpu = document.getElementById('gpuUsageChart').getContext('2d');
|
|
|
|
const cpuChart = new Chart(ctx_cpu, {
|
|
type: 'line',
|
|
data: {
|
|
labels: [],
|
|
datasets: [{
|
|
label: 'CPU Last (%)',
|
|
data: [],
|
|
borderColor: 'rgba(13, 202, 240, 1)',
|
|
backgroundColor: 'rgba(13, 202, 240, 0.2)',
|
|
borderWidth: 2,
|
|
fill: true,
|
|
tension: 0.4,
|
|
pointRadius: 0,
|
|
pointHoverRadius: 4
|
|
}]
|
|
},
|
|
options: {
|
|
responsive: true,
|
|
maintainAspectRatio: false,
|
|
scales: {
|
|
y: {
|
|
beginAtZero: true,
|
|
max: 100,
|
|
title: {
|
|
display: true,
|
|
text: 'Auslastung in %'
|
|
},
|
|
grid: {
|
|
color: 'rgba(255, 255, 255, 0.1)'
|
|
}
|
|
},
|
|
x: {
|
|
title: {
|
|
display: false,
|
|
text: 'Zeit'
|
|
},
|
|
grid: {
|
|
color: 'rgba(255, 255, 255, 0.1)'
|
|
},
|
|
ticks: {
|
|
maxTicksLimit: 12,
|
|
autoSkip: true
|
|
}
|
|
}
|
|
},
|
|
plugins: {
|
|
legend: {
|
|
display: false
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
const ramChart = new Chart(ctx_ram, {
|
|
type: 'line',
|
|
data: {
|
|
labels: [],
|
|
datasets: [{
|
|
label: 'RAM Last (%)',
|
|
data: [],
|
|
borderColor: 'rgba(25, 135, 84, 1)',
|
|
backgroundColor: 'rgba(25, 135, 84, 0.2)',
|
|
borderWidth: 2,
|
|
fill: true,
|
|
tension: 0.4,
|
|
pointRadius: 0,
|
|
pointHoverRadius: 4
|
|
}]
|
|
},
|
|
options: {
|
|
responsive: true,
|
|
maintainAspectRatio: false,
|
|
scales: {
|
|
y: {
|
|
beginAtZero: true,
|
|
max: 100,
|
|
title: {
|
|
display: true,
|
|
text: 'Auslastung in %'
|
|
},
|
|
grid: {
|
|
color: 'rgba(255, 255, 255, 0.1)'
|
|
}
|
|
},
|
|
x: {
|
|
title: {
|
|
display: false,
|
|
text: 'Zeit'
|
|
},
|
|
grid: {
|
|
color: 'rgba(255, 255, 255, 0.1)'
|
|
},
|
|
ticks: {
|
|
maxTicksLimit: 12,
|
|
autoSkip: true
|
|
}
|
|
}
|
|
},
|
|
plugins: {
|
|
legend: {
|
|
display: false
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
const gpuChart = new Chart(ctx_gpu, {
|
|
type: 'line',
|
|
data: {
|
|
labels: [],
|
|
datasets: [{
|
|
label: 'GPU Last (%)',
|
|
data: [],
|
|
borderColor: 'rgba(220, 53, 69, 1)',
|
|
backgroundColor: 'rgba(220, 53, 69, 0.2)',
|
|
borderWidth: 2,
|
|
fill: true,
|
|
tension: 0.4,
|
|
pointRadius: 0,
|
|
pointHoverRadius: 4
|
|
}]
|
|
},
|
|
options: {
|
|
responsive: true,
|
|
maintainAspectRatio: false,
|
|
scales: {
|
|
y: {
|
|
beginAtZero: true,
|
|
max: 100,
|
|
title: {
|
|
display: true,
|
|
text: 'Auslastung in %'
|
|
},
|
|
grid: {
|
|
color: 'rgba(255, 255, 255, 0.1)'
|
|
}
|
|
},
|
|
x: {
|
|
title: {
|
|
display: false,
|
|
text: 'Zeit'
|
|
},
|
|
grid: {
|
|
color: 'rgba(255, 255, 255, 0.1)'
|
|
},
|
|
ticks: {
|
|
maxTicksLimit: 12,
|
|
autoSkip: true
|
|
}
|
|
}
|
|
},
|
|
plugins: {
|
|
legend: {
|
|
display: false
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
let currentHours = 1; // Standard: 1 Stunde
|
|
|
|
async function loadCpuData() {
|
|
try {
|
|
const response = await fetch(`/monitoring/cpu-usage?serverId=@Model.Id&hours=${currentHours}`);
|
|
if (!response.ok) {
|
|
throw new Error(`HTTP-Fehler: ${response.status}`);
|
|
}
|
|
|
|
const data = await response.json();
|
|
|
|
if (!Array.isArray(data) || data.length === 0) {
|
|
console.warn('Keine CPU-Daten empfangen.');
|
|
return;
|
|
}
|
|
|
|
cpuChart.data.labels = data.map(d => d.label ?? '');
|
|
cpuChart.data.datasets[0].data = data.map(d => Number(d.data));
|
|
|
|
cpuChart.update();
|
|
} catch (err) {
|
|
console.error('Fehler beim Laden der CPU-Daten:', err);
|
|
}
|
|
}
|
|
|
|
async function loadRamData() {
|
|
try {
|
|
const response = await fetch(`/monitoring/ram-usage?serverId=@Model.Id&hours=${currentHours}`);
|
|
if (!response.ok) {
|
|
throw new Error(`HTTP-Fehler: ${response.status}`);
|
|
}
|
|
|
|
const data = await response.json();
|
|
|
|
if (!Array.isArray(data) || data.length === 0) {
|
|
console.warn('Keine RAM-Daten empfangen.');
|
|
return;
|
|
}
|
|
|
|
ramChart.data.labels = data.map(d => d.label ?? '');
|
|
ramChart.data.datasets[0].data = data.map(d => Number(d.data));
|
|
|
|
ramChart.update();
|
|
} catch (err) {
|
|
console.error('Fehler beim Laden der RAM-Daten:', err);
|
|
}
|
|
}
|
|
|
|
async function loadGpuData() {
|
|
try {
|
|
const response = await fetch(`/monitoring/gpu-usage?serverId=@Model.Id&hours=${currentHours}`);
|
|
if (!response.ok) {
|
|
throw new Error(`HTTP-Fehler: ${response.status}`);
|
|
}
|
|
|
|
const data = await response.json();
|
|
|
|
if (!Array.isArray(data) || data.length === 0) {
|
|
console.warn('Keine GPU-Daten empfangen.');
|
|
return;
|
|
}
|
|
|
|
gpuChart.data.labels = data.map(d => d.label ?? '');
|
|
gpuChart.data.datasets[0].data = data.map(d => Number(d.data));
|
|
|
|
gpuChart.update();
|
|
} catch (err) {
|
|
console.error('Fehler beim Laden der GPU-Daten:', err);
|
|
}
|
|
}
|
|
|
|
// Button-Handler für Zeitbereich-Wechsel
|
|
document.querySelectorAll('[data-range]').forEach(button => {
|
|
button.addEventListener('click', function() {
|
|
// Alle Buttons deaktivieren
|
|
document.querySelectorAll('[data-range]').forEach(btn => {
|
|
btn.classList.remove('active');
|
|
});
|
|
|
|
// Aktuellen Button aktivieren
|
|
this.classList.add('active');
|
|
|
|
// Zeitbereich aktualisieren
|
|
currentHours = parseInt(this.getAttribute('data-range'));
|
|
|
|
// Daten neu laden
|
|
loadCpuData();
|
|
loadRamData();
|
|
loadGpuData();
|
|
});
|
|
});
|
|
|
|
// Initiales Laden
|
|
loadCpuData();
|
|
loadRamData();
|
|
loadGpuData();
|
|
|
|
// Alle 30 Sekunden aktualisieren
|
|
setInterval(loadCpuData, 30000);
|
|
setInterval(loadRamData, 30000);
|
|
setInterval(loadGpuData, 30000);
|
|
});
|
|
</script>
|
|
} |