CodeStyle, Compose verbesserungen, Docker Healthcheck
This commit is contained in:
16
Dockerfile
16
Dockerfile
@@ -18,19 +18,29 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0
|
|||||||
# Build-Argument für Version (wird zur Build-Zeit vom CI/CD gesetzt)
|
# Build-Argument für Version (wird zur Build-Zeit vom CI/CD gesetzt)
|
||||||
ARG VERSION=latest
|
ARG VERSION=latest
|
||||||
|
|
||||||
|
# Install curl for health checks
|
||||||
|
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Create non-root user
|
||||||
|
RUN groupadd -r watcher -g 1000 && useradd -r -g watcher -u 1000 watcher
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=build /app/publish .
|
COPY --from=build /app/publish .
|
||||||
|
|
||||||
# Stelle sicher, dass Verzeichnisse existieren
|
# Stelle sicher, dass Verzeichnisse existieren und Berechtigungen gesetzt sind
|
||||||
RUN mkdir -p /app/persistence /app/wwwroot/downloads/sqlite /app/logs
|
RUN mkdir -p /app/persistence /app/wwwroot/downloads/sqlite /app/logs && \
|
||||||
|
chown -R watcher:watcher /app
|
||||||
|
|
||||||
# Volumes
|
# Volumes
|
||||||
VOLUME ["/app/persistence", "/app/wwwroot/downloads/sqlite", "/app/logs"]
|
VOLUME ["/app/persistence", "/app/wwwroot/downloads/sqlite", "/app/logs"]
|
||||||
|
|
||||||
|
# Switch to non-root user
|
||||||
|
USER watcher
|
||||||
|
|
||||||
# Expose Port 5000
|
# Expose Port 5000
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
ENV ASPNETCORE_URLS=http://*:5000
|
ENV ASPNETCORE_URLS=http://*:5000
|
||||||
ENV ASPNETCORE_ENVIRONMENT=Development
|
ENV ASPNETCORE_ENVIRONMENT=Production
|
||||||
|
|
||||||
# Version als Environment Variable setzen
|
# Version als Environment Variable setzen
|
||||||
ENV WATCHER_VERSION=${VERSION}
|
ENV WATCHER_VERSION=${VERSION}
|
||||||
|
|||||||
@@ -19,18 +19,18 @@ namespace Watcher.Controllers
|
|||||||
private readonly ILogger<HomeController> _logger;
|
private readonly ILogger<HomeController> _logger;
|
||||||
|
|
||||||
// Daten der Backgroundchecks abrufen
|
// Daten der Backgroundchecks abrufen
|
||||||
private IDashboardStore _DashboardStore;
|
private IDashboardStore _dashboardStore;
|
||||||
|
|
||||||
// System Store für Konfigurationen
|
// System Store für Konfigurationen
|
||||||
private ISystemStore _SystemStore;
|
private ISystemStore _systemStore;
|
||||||
|
|
||||||
// HomeController Constructor
|
// HomeController Constructor
|
||||||
public HomeController(AppDbContext context, ILogger<HomeController> logger, IDashboardStore dashboardStore, ISystemStore systemStore)
|
public HomeController(AppDbContext context, ILogger<HomeController> logger, IDashboardStore dashboardStore, ISystemStore systemStore)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_DashboardStore = dashboardStore;
|
_dashboardStore = dashboardStore;
|
||||||
_SystemStore = systemStore;
|
_systemStore = systemStore;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,9 +62,9 @@ namespace Watcher.Controllers
|
|||||||
Containers = await _context.Containers
|
Containers = await _context.Containers
|
||||||
.OrderBy(s => s.Name)
|
.OrderBy(s => s.Name)
|
||||||
.ToListAsync(),
|
.ToListAsync(),
|
||||||
NetworkStatus = _DashboardStore.NetworkStatus,
|
NetworkStatus = _dashboardStore.NetworkStatus,
|
||||||
DatabaseStatus = _DashboardStore.DatabaseStatus,
|
DatabaseStatus = _dashboardStore.DatabaseStatus,
|
||||||
RefreshIntervalMilliseconds = _SystemStore.FrontendRefreshIntervalMilliseconds
|
RefreshIntervalMilliseconds = _systemStore.FrontendRefreshIntervalMilliseconds
|
||||||
};
|
};
|
||||||
//ViewBag.NetworkConnection = _NetworkCheckStore.NetworkStatus;
|
//ViewBag.NetworkConnection = _NetworkCheckStore.NetworkStatus;
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
@@ -95,14 +95,14 @@ namespace Watcher.Controllers
|
|||||||
Containers = await _context.Containers
|
Containers = await _context.Containers
|
||||||
.OrderBy(s => s.Name)
|
.OrderBy(s => s.Name)
|
||||||
.ToListAsync(),
|
.ToListAsync(),
|
||||||
NetworkStatus = _DashboardStore.NetworkStatus,
|
NetworkStatus = _dashboardStore.NetworkStatus,
|
||||||
DatabaseStatus = _DashboardStore.DatabaseStatus
|
DatabaseStatus = _dashboardStore.DatabaseStatus
|
||||||
};
|
};
|
||||||
|
|
||||||
return PartialView("_DashboardStats", model);
|
return PartialView("_DashboardStats", model);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String ReturnNetworkStatus()
|
public string ReturnNetworkStatus()
|
||||||
{
|
{
|
||||||
return "OK";
|
return "OK";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,28 +187,28 @@ public class MonitoringController : Controller
|
|||||||
if (server != null)
|
if (server != null)
|
||||||
{
|
{
|
||||||
// neues Metric-Objekt erstellen
|
// neues Metric-Objekt erstellen
|
||||||
var NewMetric = new Metric
|
var newMetric = new Metric
|
||||||
{
|
{
|
||||||
Timestamp = DateTime.UtcNow,
|
Timestamp = DateTime.UtcNow,
|
||||||
ServerId = dto.ServerId,
|
ServerId = dto.ServerId,
|
||||||
CPU_Load = sanitizeInput(dto.CPU_Load),
|
CPU_Load = SanitizeInput(dto.CPU_Load),
|
||||||
CPU_Temp = sanitizeInput(dto.CPU_Temp),
|
CPU_Temp = SanitizeInput(dto.CPU_Temp),
|
||||||
GPU_Load = sanitizeInput(dto.GPU_Load),
|
GPU_Load = SanitizeInput(dto.GPU_Load),
|
||||||
GPU_Temp = sanitizeInput(dto.GPU_Temp),
|
GPU_Temp = SanitizeInput(dto.GPU_Temp),
|
||||||
GPU_Vram_Size = calculateGigabyte(dto.GPU_Vram_Size),
|
GPU_Vram_Size = CalculateGigabyte(dto.GPU_Vram_Size),
|
||||||
GPU_Vram_Usage = sanitizeInput(dto.GPU_Vram_Load),
|
GPU_Vram_Usage = SanitizeInput(dto.GPU_Vram_Load),
|
||||||
RAM_Load = sanitizeInput(dto.RAM_Load),
|
RAM_Load = SanitizeInput(dto.RAM_Load),
|
||||||
RAM_Size = calculateGigabyte(dto.RAM_Size),
|
RAM_Size = CalculateGigabyte(dto.RAM_Size),
|
||||||
DISK_Size = calculateGigabyte(dto.DISK_Size),
|
DISK_Size = CalculateGigabyte(dto.DISK_Size),
|
||||||
DISK_Usage = calculateGigabyte(dto.DISK_Usage),
|
DISK_Usage = CalculateGigabyte(dto.DISK_Usage),
|
||||||
DISK_Temp = sanitizeInput(dto.DISK_Temp),
|
DISK_Temp = SanitizeInput(dto.DISK_Temp),
|
||||||
NET_In = calculateMegabit(dto.NET_In),
|
NET_In = CalculateMegabit(dto.NET_In),
|
||||||
NET_Out = calculateMegabit(dto.NET_Out)
|
NET_Out = CalculateMegabit(dto.NET_Out)
|
||||||
};
|
};
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Metric Objekt in Datenbank einfügen
|
// Metric Objekt in Datenbank einfügen
|
||||||
_context.Metrics.Add(NewMetric);
|
_context.Metrics.Add(newMetric);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
_logger.LogInformation("Monitoring-Daten für '{server}' empfangen", server.Name);
|
_logger.LogInformation("Monitoring-Daten für '{server}' empfangen", server.Name);
|
||||||
@@ -256,16 +256,16 @@ public class MonitoringController : Controller
|
|||||||
JsonSerializer.Deserialize<List<Container>>(dto.Containers.GetRawText())
|
JsonSerializer.Deserialize<List<Container>>(dto.Containers.GetRawText())
|
||||||
?? new List<Container>();
|
?? new List<Container>();
|
||||||
|
|
||||||
foreach (Container c in newContainers)
|
foreach (Container container in newContainers)
|
||||||
{
|
{
|
||||||
c.ServerId = dto.Server_id;
|
container.ServerId = dto.Server_id;
|
||||||
// Debug Logs
|
// Debug Logs
|
||||||
// TODO entfernen wenn fertig getestet
|
// TODO entfernen wenn fertig getestet
|
||||||
Console.WriteLine("---------");
|
Console.WriteLine("---------");
|
||||||
Console.WriteLine("ServerId: " + c.ServerId);
|
Console.WriteLine("ServerId: " + container.ServerId);
|
||||||
Console.WriteLine("ContainerId: " + c.ContainerId);
|
Console.WriteLine("ContainerId: " + container.ContainerId);
|
||||||
Console.WriteLine("Name: " + c.Name);
|
Console.WriteLine("Name: " + container.Name);
|
||||||
Console.WriteLine("Image: " + c.Image);
|
Console.WriteLine("Image: " + container.Image);
|
||||||
Console.WriteLine("---------");
|
Console.WriteLine("---------");
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -277,21 +277,21 @@ public class MonitoringController : Controller
|
|||||||
|
|
||||||
|
|
||||||
// Logik, um Container, die mit dem Payload kamen zu verarbeiten
|
// Logik, um Container, die mit dem Payload kamen zu verarbeiten
|
||||||
foreach (Container c in newContainers)
|
foreach (Container container in newContainers)
|
||||||
{
|
{
|
||||||
// Überprüfen, ob ein übergebener Container bereits für den Host registriert ist
|
// Überprüfen, ob ein übergebener Container bereits für den Host registriert ist
|
||||||
// Wichtig: Vergleich über ContainerId, nicht über Objektreferenz!
|
// Wichtig: Vergleich über ContainerId, nicht über Objektreferenz!
|
||||||
var existingContainer = existingContainers
|
var existingContainer = existingContainers
|
||||||
.FirstOrDefault(ec => ec.ContainerId == c.ContainerId);
|
.FirstOrDefault(ec => ec.ContainerId == container.ContainerId);
|
||||||
|
|
||||||
if (existingContainer != null)
|
if (existingContainer != null)
|
||||||
{
|
{
|
||||||
// Container existiert bereits, nur Daten aktualisieren falls sich etwas geändert hat
|
// Container existiert bereits, nur Daten aktualisieren falls sich etwas geändert hat
|
||||||
existingContainer.Name = c.Name;
|
existingContainer.Name = container.Name;
|
||||||
existingContainer.Image = c.Image;
|
existingContainer.Image = container.Image;
|
||||||
existingContainer.IsRunning = true;
|
existingContainer.IsRunning = true;
|
||||||
|
|
||||||
_logger.LogInformation("Container '{containerName}' (ID: {containerId}) already exists for Server {serverId}, updated.", c.Name, c.ContainerId, dto.Server_id);
|
_logger.LogInformation("Container '{containerName}' (ID: {containerId}) already exists for Server {serverId}, updated.", container.Name, container.ContainerId, dto.Server_id);
|
||||||
}
|
}
|
||||||
// Container auf einen Host/Server registrieren
|
// Container auf einen Host/Server registrieren
|
||||||
else
|
else
|
||||||
@@ -299,35 +299,35 @@ public class MonitoringController : Controller
|
|||||||
// Container in Datenbank einlesen
|
// Container in Datenbank einlesen
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_context.Containers.Add(c);
|
_context.Containers.Add(container);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
_logger.LogInformation("Container '{containerName}' (ID: {containerId}) added for Server {serverId}", c.Name, c.ContainerId, c.ServerId);
|
_logger.LogInformation("Container '{containerName}' (ID: {containerId}) added for Server {serverId}", container.Name, container.ContainerId, container.ServerId);
|
||||||
}
|
}
|
||||||
catch (SqliteException e)
|
catch (SqliteException e)
|
||||||
{
|
{
|
||||||
_logger.LogError("Error writing new Container '{containerName}' to Database: {error}", c.Name, e.Message);
|
_logger.LogError("Error writing new Container '{containerName}' to Database: {error}", container.Name, e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logik um abgeschaltene Container aus der Datenbank zu entfernen
|
// Logik um abgeschaltene Container aus der Datenbank zu entfernen
|
||||||
foreach (Container c in existingContainers)
|
foreach (Container existingContainer in existingContainers)
|
||||||
{
|
{
|
||||||
// Abfrage, ob bereits vorhandener Container im Payload vorhanden war
|
// Abfrage, ob bereits vorhandener Container im Payload vorhanden war
|
||||||
// Wichtig: Vergleich über ContainerId, nicht über Objektreferenz!
|
// Wichtig: Vergleich über ContainerId, nicht über Objektreferenz!
|
||||||
var stillRunning = newContainers
|
var stillRunning = newContainers
|
||||||
.Any(nc => nc.ContainerId == c.ContainerId);
|
.Any(nc => nc.ContainerId == existingContainer.ContainerId);
|
||||||
|
|
||||||
if (!stillRunning)
|
if (!stillRunning)
|
||||||
{
|
{
|
||||||
// Container entfernen
|
// Container entfernen
|
||||||
_context.Containers.Remove(c);
|
_context.Containers.Remove(existingContainer);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
// Metrics für den Container entfernen
|
// Metrics für den Container entfernen
|
||||||
//Todo
|
//Todo
|
||||||
|
|
||||||
_logger.LogInformation("Container '{containerName}' (DB-ID: {id}, ContainerID: {containerId}) on Server {serverId} was removed from the database.", c.Name, c.Id, c.ContainerId, c.ServerId);
|
_logger.LogInformation("Container '{containerName}' (DB-ID: {id}, ContainerID: {containerId}) on Server {serverId} was removed from the database.", existingContainer.Name, existingContainer.Id, existingContainer.ContainerId, existingContainer.ServerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,39 +454,39 @@ public class MonitoringController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Metric Input Byte zu Gigabyte umwandeln
|
// Metric Input Byte zu Gigabyte umwandeln
|
||||||
public static double calculateGigabyte(double metric_input)
|
public static double CalculateGigabyte(double metricInput)
|
||||||
{
|
{
|
||||||
// *10^-9 um auf Gigabyte zu kommen
|
// *10^-9 um auf Gigabyte zu kommen
|
||||||
double calculatedValue = metric_input * Math.Pow(10, -9);
|
double calculatedValue = metricInput * Math.Pow(10, -9);
|
||||||
|
|
||||||
// Auf 2 Nachkommastellen runden
|
// Auf 2 Nachkommastellen runden
|
||||||
double calculatedValue_s = sanitizeInput(calculatedValue);
|
double calculatedValueSanitized = SanitizeInput(calculatedValue);
|
||||||
|
|
||||||
return calculatedValue_s;
|
return calculatedValueSanitized;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Metric Input Byte/s zu Megabit/s umrechnen
|
// Metric Input Byte/s zu Megabit/s umrechnen
|
||||||
//TODO
|
//TODO
|
||||||
public static double calculateMegabit(double metric_input)
|
public static double CalculateMegabit(double metricInput)
|
||||||
{
|
{
|
||||||
// *10^-9 um auf Gigabyte zu kommen
|
// *10^-9 um auf Gigabyte zu kommen
|
||||||
double calculatedValue = metric_input * Math.Pow(10, -9);
|
double calculatedValue = metricInput * Math.Pow(10, -9);
|
||||||
|
|
||||||
// Auf 2 Nachkommastellen runden
|
// Auf 2 Nachkommastellen runden
|
||||||
double calculatedValue_s = sanitizeInput(calculatedValue);
|
double calculatedValueSanitized = SanitizeInput(calculatedValue);
|
||||||
|
|
||||||
return calculatedValue_s;
|
return calculatedValueSanitized;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Degree Input auf zwei Nachkommastellen runden
|
// Degree Input auf zwei Nachkommastellen runden
|
||||||
public static double sanitizeInput(double metric_input)
|
public static double SanitizeInput(double metricInput)
|
||||||
{
|
{
|
||||||
Math.Round(metric_input, 2);
|
Math.Round(metricInput, 2);
|
||||||
|
|
||||||
return metric_input;
|
return metricInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Container> ParseServiceDiscoveryInput(int server_id, List<Container> containers)
|
private List<Container> ParseServiceDiscoveryInput(int serverId, List<Container> containers)
|
||||||
{
|
{
|
||||||
List<Container> containerList = new List<Container>();
|
List<Container> containerList = new List<Container>();
|
||||||
|
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ public class ServerController : Controller
|
|||||||
[HttpGet("Overview")]
|
[HttpGet("Overview")]
|
||||||
public async Task<IActionResult> Overview()
|
public async Task<IActionResult> Overview()
|
||||||
{
|
{
|
||||||
var vm = new ServerOverviewViewModel
|
var viewModel = new ServerOverviewViewModel
|
||||||
{
|
{
|
||||||
Servers = await _context.Servers.OrderBy(s => s.Id).ToListAsync(),
|
Servers = await _context.Servers.OrderBy(s => s.Id).ToListAsync(),
|
||||||
RefreshIntervalMilliseconds = _systemStore.FrontendRefreshIntervalMilliseconds
|
RefreshIntervalMilliseconds = _systemStore.FrontendRefreshIntervalMilliseconds
|
||||||
};
|
};
|
||||||
|
|
||||||
return View(vm);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -47,17 +47,17 @@ public class ServerController : Controller
|
|||||||
// POST: Server/AddServer
|
// POST: Server/AddServer
|
||||||
[HttpPost("AddServer")]
|
[HttpPost("AddServer")]
|
||||||
[ValidateAntiForgeryToken]
|
[ValidateAntiForgeryToken]
|
||||||
public async Task<IActionResult> AddServer(AddServerViewModel vm)
|
public async Task<IActionResult> AddServer(AddServerViewModel viewModel)
|
||||||
{
|
{
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return View(vm);
|
return View(viewModel);
|
||||||
|
|
||||||
var server = new Server
|
var server = new Server
|
||||||
{
|
{
|
||||||
Name = vm.Name,
|
Name = viewModel.Name,
|
||||||
IPAddress = vm.IPAddress,
|
IPAddress = viewModel.IPAddress,
|
||||||
Type = vm.Type,
|
Type = viewModel.Type,
|
||||||
IsOnline = vm.IsOnline,
|
IsOnline = viewModel.IsOnline,
|
||||||
};
|
};
|
||||||
|
|
||||||
_context.Servers.Add(server);
|
_context.Servers.Add(server);
|
||||||
@@ -96,25 +96,39 @@ public class ServerController : Controller
|
|||||||
var server = await _context.Servers.FindAsync(id);
|
var server = await _context.Servers.FindAsync(id);
|
||||||
if (server == null) return NotFound();
|
if (server == null) return NotFound();
|
||||||
|
|
||||||
var vm = new EditServerViewModel
|
var viewModel = new EditServerViewModel
|
||||||
{
|
{
|
||||||
Name = server.Name,
|
Name = server.Name,
|
||||||
IPAddress = server.IPAddress,
|
IPAddress = server.IPAddress,
|
||||||
Type = server.Type
|
Type = server.Type,
|
||||||
|
CpuLoadWarning = server.CpuLoadWarning,
|
||||||
|
CpuLoadCritical = server.CpuLoadCritical,
|
||||||
|
CpuTempWarning = server.CpuTempWarning,
|
||||||
|
CpuTempCritical = server.CpuTempCritical,
|
||||||
|
RamLoadWarning = server.RamLoadWarning,
|
||||||
|
RamLoadCritical = server.RamLoadCritical,
|
||||||
|
GpuLoadWarning = server.GpuLoadWarning,
|
||||||
|
GpuLoadCritical = server.GpuLoadCritical,
|
||||||
|
GpuTempWarning = server.GpuTempWarning,
|
||||||
|
GpuTempCritical = server.GpuTempCritical,
|
||||||
|
DiskUsageWarning = server.DiskUsageWarning,
|
||||||
|
DiskUsageCritical = server.DiskUsageCritical,
|
||||||
|
DiskTempWarning = server.DiskTempWarning,
|
||||||
|
DiskTempCritical = server.DiskTempCritical
|
||||||
};
|
};
|
||||||
|
|
||||||
return View(vm);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// POST: Server/Edit/5
|
// POST: Server/Edit/5
|
||||||
[HttpPost("EditServer/{id}")]
|
[HttpPost("EditServer/{id}")]
|
||||||
[ValidateAntiForgeryToken]
|
[ValidateAntiForgeryToken]
|
||||||
public async Task<IActionResult> EditServer(int id, EditServerViewModel vm)
|
public async Task<IActionResult> EditServer(int id, EditServerViewModel viewModel)
|
||||||
{
|
{
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
{
|
{
|
||||||
return View(vm);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
var server = await _context.Servers.FindAsync(id);
|
var server = await _context.Servers.FindAsync(id);
|
||||||
@@ -123,9 +137,23 @@ public class ServerController : Controller
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
server.Name = vm.Name;
|
server.Name = viewModel.Name;
|
||||||
server.IPAddress = vm.IPAddress;
|
server.IPAddress = viewModel.IPAddress;
|
||||||
server.Type = vm.Type;
|
server.Type = viewModel.Type;
|
||||||
|
server.CpuLoadWarning = viewModel.CpuLoadWarning;
|
||||||
|
server.CpuLoadCritical = viewModel.CpuLoadCritical;
|
||||||
|
server.CpuTempWarning = viewModel.CpuTempWarning;
|
||||||
|
server.CpuTempCritical = viewModel.CpuTempCritical;
|
||||||
|
server.RamLoadWarning = viewModel.RamLoadWarning;
|
||||||
|
server.RamLoadCritical = viewModel.RamLoadCritical;
|
||||||
|
server.GpuLoadWarning = viewModel.GpuLoadWarning;
|
||||||
|
server.GpuLoadCritical = viewModel.GpuLoadCritical;
|
||||||
|
server.GpuTempWarning = viewModel.GpuTempWarning;
|
||||||
|
server.GpuTempCritical = viewModel.GpuTempCritical;
|
||||||
|
server.DiskUsageWarning = viewModel.DiskUsageWarning;
|
||||||
|
server.DiskUsageCritical = viewModel.DiskUsageCritical;
|
||||||
|
server.DiskTempWarning = viewModel.DiskTempWarning;
|
||||||
|
server.DiskTempCritical = viewModel.DiskTempCritical;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -137,7 +165,7 @@ public class ServerController : Controller
|
|||||||
{
|
{
|
||||||
_logger.LogError(ex, "Fehler beim Speichern des Servers");
|
_logger.LogError(ex, "Fehler beim Speichern des Servers");
|
||||||
ModelState.AddModelError("", "Fehler beim Speichern");
|
ModelState.AddModelError("", "Fehler beim Speichern");
|
||||||
return View(vm);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,28 +175,28 @@ public class ServerController : Controller
|
|||||||
public async Task<IActionResult> Details(int id)
|
public async Task<IActionResult> Details(int id)
|
||||||
{
|
{
|
||||||
|
|
||||||
var s = await _context.Servers.FindAsync(id);
|
var server = await _context.Servers.FindAsync(id);
|
||||||
if (s == null) return NotFound();
|
if (server == null) return NotFound();
|
||||||
|
|
||||||
var vm = new ServerDetailsViewModel
|
var viewModel = new ServerDetailsViewModel
|
||||||
{
|
{
|
||||||
Id = s.Id,
|
Id = server.Id,
|
||||||
Name = s.Name,
|
Name = server.Name,
|
||||||
IPAddress = s.IPAddress,
|
IPAddress = server.IPAddress,
|
||||||
Type = s.Type,
|
Type = server.Type,
|
||||||
Description = s.Description,
|
Description = server.Description,
|
||||||
CpuType = s.CpuType,
|
CpuType = server.CpuType,
|
||||||
CpuCores = s.CpuCores,
|
CpuCores = server.CpuCores,
|
||||||
GpuType = s.GpuType,
|
GpuType = server.GpuType,
|
||||||
RamSize = s.RamSize,
|
RamSize = server.RamSize,
|
||||||
CreatedAt = s.CreatedAt,
|
CreatedAt = server.CreatedAt,
|
||||||
IsOnline = s.IsOnline,
|
IsOnline = server.IsOnline,
|
||||||
LastSeen = s.LastSeen,
|
LastSeen = server.LastSeen,
|
||||||
IsVerified = s.IsVerified,
|
IsVerified = server.IsVerified,
|
||||||
RefreshIntervalMilliseconds = _systemStore.FrontendRefreshIntervalMilliseconds
|
RefreshIntervalMilliseconds = _systemStore.FrontendRefreshIntervalMilliseconds
|
||||||
};
|
};
|
||||||
|
|
||||||
return View(vm);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
392
Watcher/Migrations/20251116233330_RenameServerPropertiesToPascalCase.Designer.cs
generated
Normal file
392
Watcher/Migrations/20251116233330_RenameServerPropertiesToPascalCase.Designer.cs
generated
Normal file
@@ -0,0 +1,392 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Watcher.Data;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Watcher.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20251116233330_RenameServerPropertiesToPascalCase")]
|
||||||
|
partial class RenameServerPropertiesToPascalCase
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
|
||||||
|
|
||||||
|
modelBuilder.Entity("Watcher.Models.Container", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("ContainerId")
|
||||||
|
.HasColumnType("TEXT")
|
||||||
|
.HasAnnotation("Relational:JsonPropertyName", "id");
|
||||||
|
|
||||||
|
b.Property<string>("Image")
|
||||||
|
.HasColumnType("TEXT")
|
||||||
|
.HasAnnotation("Relational:JsonPropertyName", "image");
|
||||||
|
|
||||||
|
b.Property<int?>("ImageId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("IsRunning")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("TEXT")
|
||||||
|
.HasAnnotation("Relational:JsonPropertyName", "name");
|
||||||
|
|
||||||
|
b.Property<int>("ServerId")
|
||||||
|
.HasColumnType("INTEGER")
|
||||||
|
.HasAnnotation("Relational:JsonPropertyName", "Server_id");
|
||||||
|
|
||||||
|
b.Property<int?>("TagId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ImageId");
|
||||||
|
|
||||||
|
b.HasIndex("ServerId");
|
||||||
|
|
||||||
|
b.HasIndex("TagId");
|
||||||
|
|
||||||
|
b.ToTable("Containers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Watcher.Models.ContainerMetric", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<double>("CPU_Load")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("CPU_Temp")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<int?>("ContainerId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<double>("RAM_Load")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("RAM_Size")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Timestamp")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("ContainerMetrics");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Watcher.Models.Image", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Tag")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Images");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int?>("ContainerId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Level")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Message")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int?>("ServerId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Timestamp")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ContainerId");
|
||||||
|
|
||||||
|
b.HasIndex("ServerId");
|
||||||
|
|
||||||
|
b.ToTable("LogEvents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Watcher.Models.Metric", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<double>("CPU_Load")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("CPU_Temp")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("DISK_Size")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("DISK_Temp")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("DISK_Usage")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("GPU_Load")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("GPU_Temp")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("GPU_Vram_Size")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("GPU_Vram_Usage")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("NET_In")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("NET_Out")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("RAM_Load")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("RAM_Size")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<int?>("ServerId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Timestamp")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Metrics");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Watcher.Models.Server", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("CpuCores")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<double>("CpuLoadCritical")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("CpuLoadWarning")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("CpuTempCritical")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("CpuTempWarning")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<string>("CpuType")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("DiskSpace")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<double>("DiskTempCritical")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("DiskTempWarning")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("DiskUsageCritical")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("DiskUsageWarning")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("GpuLoadCritical")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("GpuLoadWarning")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("GpuTempCritical")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("GpuTempWarning")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<string>("GpuType")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("IPAddress")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("IsOnline")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("IsVerified")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<DateTime>("LastSeen")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<double>("RamLoadCritical")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("RamLoadWarning")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("RamSize")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<int?>("TagId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Type")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("TagId");
|
||||||
|
|
||||||
|
b.ToTable("Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Watcher.Models.Tag", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Tags");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Watcher.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("LastLogin")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Username")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Watcher.Models.Container", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Watcher.Models.Image", null)
|
||||||
|
.WithMany("Containers")
|
||||||
|
.HasForeignKey("ImageId");
|
||||||
|
|
||||||
|
b.HasOne("Watcher.Models.Server", "Server")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ServerId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Watcher.Models.Tag", null)
|
||||||
|
.WithMany("Containers")
|
||||||
|
.HasForeignKey("TagId");
|
||||||
|
|
||||||
|
b.Navigation("Server");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Watcher.Models.Container", "Container")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ContainerId");
|
||||||
|
|
||||||
|
b.HasOne("Watcher.Models.Server", "Server")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ServerId");
|
||||||
|
|
||||||
|
b.Navigation("Container");
|
||||||
|
|
||||||
|
b.Navigation("Server");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Watcher.Models.Server", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Watcher.Models.Tag", null)
|
||||||
|
.WithMany("Servers")
|
||||||
|
.HasForeignKey("TagId");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Watcher.Models.Image", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Containers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Watcher.Models.Tag", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Containers");
|
||||||
|
|
||||||
|
b.Navigation("Servers");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Watcher.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class RenameServerPropertiesToPascalCase : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "RAM_Load_Warning",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "RamLoadWarning");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "RAM_Load_Critical",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "RamLoadCritical");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "GPU_Temp_Warning",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "GpuTempWarning");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "GPU_Temp_Critical",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "GpuTempCritical");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "GPU_Load_Warning",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "GpuLoadWarning");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "GPU_Load_Critical",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "GpuLoadCritical");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "Disk_Usage_Warning",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "DiskUsageWarning");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "Disk_Usage_Critical",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "DiskUsageCritical");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "DISK_Temp_Warning",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "DiskTempWarning");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "DISK_Temp_Critical",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "DiskTempCritical");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "CPU_Temp_Warning",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "CpuTempWarning");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "CPU_Temp_Critical",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "CpuTempCritical");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "CPU_Load_Warning",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "CpuLoadWarning");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "CPU_Load_Critical",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "CpuLoadCritical");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "RamLoadWarning",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "RAM_Load_Warning");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "RamLoadCritical",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "RAM_Load_Critical");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "GpuTempWarning",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "GPU_Temp_Warning");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "GpuTempCritical",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "GPU_Temp_Critical");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "GpuLoadWarning",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "GPU_Load_Warning");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "GpuLoadCritical",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "GPU_Load_Critical");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "DiskUsageWarning",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "Disk_Usage_Warning");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "DiskUsageCritical",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "Disk_Usage_Critical");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "DiskTempWarning",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "DISK_Temp_Warning");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "DiskTempCritical",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "DISK_Temp_Critical");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "CpuTempWarning",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "CPU_Temp_Warning");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "CpuTempCritical",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "CPU_Temp_Critical");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "CpuLoadWarning",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "CPU_Load_Warning");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "CpuLoadCritical",
|
||||||
|
table: "Servers",
|
||||||
|
newName: "CPU_Load_Critical");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -197,55 +197,55 @@ namespace Watcher.Migrations
|
|||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<double>("CPU_Load_Critical")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("CPU_Load_Warning")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("CPU_Temp_Critical")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("CPU_Temp_Warning")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<int>("CpuCores")
|
b.Property<int>("CpuCores")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<double>("CpuLoadCritical")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("CpuLoadWarning")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("CpuTempCritical")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("CpuTempWarning")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
b.Property<string>("CpuType")
|
b.Property<string>("CpuType")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
b.Property<DateTime>("CreatedAt")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<double>("DISK_Temp_Critical")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("DISK_Temp_Warning")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("DiskSpace")
|
b.Property<string>("DiskSpace")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<double>("Disk_Usage_Critical")
|
b.Property<double>("DiskTempCritical")
|
||||||
.HasColumnType("REAL");
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
b.Property<double>("Disk_Usage_Warning")
|
b.Property<double>("DiskTempWarning")
|
||||||
.HasColumnType("REAL");
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
b.Property<double>("GPU_Load_Critical")
|
b.Property<double>("DiskUsageCritical")
|
||||||
.HasColumnType("REAL");
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
b.Property<double>("GPU_Load_Warning")
|
b.Property<double>("DiskUsageWarning")
|
||||||
.HasColumnType("REAL");
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
b.Property<double>("GPU_Temp_Critical")
|
b.Property<double>("GpuLoadCritical")
|
||||||
.HasColumnType("REAL");
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
b.Property<double>("GPU_Temp_Warning")
|
b.Property<double>("GpuLoadWarning")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("GpuTempCritical")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("GpuTempWarning")
|
||||||
.HasColumnType("REAL");
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
b.Property<string>("GpuType")
|
b.Property<string>("GpuType")
|
||||||
@@ -268,10 +268,10 @@ namespace Watcher.Migrations
|
|||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<double>("RAM_Load_Critical")
|
b.Property<double>("RamLoadCritical")
|
||||||
.HasColumnType("REAL");
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
b.Property<double>("RAM_Load_Warning")
|
b.Property<double>("RamLoadWarning")
|
||||||
.HasColumnType("REAL");
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
b.Property<double>("RamSize")
|
b.Property<double>("RamSize")
|
||||||
|
|||||||
@@ -13,15 +13,15 @@ public class Container
|
|||||||
public Server Server { get; set; } = null!;
|
public Server Server { get; set; } = null!;
|
||||||
|
|
||||||
[JsonPropertyName("id")]
|
[JsonPropertyName("id")]
|
||||||
public String? ContainerId { get; set; }
|
public string? ContainerId { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("image")]
|
[JsonPropertyName("image")]
|
||||||
public String? Image { get; set; }
|
public string? Image { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("name")]
|
[JsonPropertyName("name")]
|
||||||
public String? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
|
|
||||||
// keine Variable, die vom Agent übergeben wird. Ein container ist immer Running, die Variable dient nur für die Übersicht
|
// keine Variable, die vom Agent übergeben wird. Ein container ist immer Running, die Variable dient nur für die Übersicht
|
||||||
// auf dem Dashboard.
|
// auf dem Dashboard.
|
||||||
public Boolean IsRunning { get; set; } = true;
|
public bool IsRunning { get; set; } = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,32 +29,32 @@ public class Server
|
|||||||
|
|
||||||
|
|
||||||
// Hardware Measurment Warning/Crit Values
|
// Hardware Measurment Warning/Crit Values
|
||||||
public double CPU_Load_Warning { get; set; } = 75.0;
|
public double CpuLoadWarning { get; set; } = 75.0;
|
||||||
public double CPU_Load_Critical { get; set; } = 90.0;
|
public double CpuLoadCritical { get; set; } = 90.0;
|
||||||
public double CPU_Temp_Warning { get; set; } = 80.0;
|
public double CpuTempWarning { get; set; } = 80.0;
|
||||||
public double CPU_Temp_Critical { get; set; } = 90.0;
|
public double CpuTempCritical { get; set; } = 90.0;
|
||||||
|
|
||||||
public double RAM_Load_Warning { get; set; } = 85.0;
|
public double RamLoadWarning { get; set; } = 85.0;
|
||||||
public double RAM_Load_Critical { get; set; } = 95.0;
|
public double RamLoadCritical { get; set; } = 95.0;
|
||||||
|
|
||||||
public double GPU_Load_Warning { get; set; } = 75.0;
|
public double GpuLoadWarning { get; set; } = 75.0;
|
||||||
public double GPU_Load_Critical { get; set; } = 90.0;
|
public double GpuLoadCritical { get; set; } = 90.0;
|
||||||
public double GPU_Temp_Warning { get; set; } = 70.0;
|
public double GpuTempWarning { get; set; } = 70.0;
|
||||||
public double GPU_Temp_Critical { get; set; } = 80.0;
|
public double GpuTempCritical { get; set; } = 80.0;
|
||||||
|
|
||||||
public double Disk_Usage_Warning { get; set; } = 75.0;
|
public double DiskUsageWarning { get; set; } = 75.0;
|
||||||
public double Disk_Usage_Critical { get; set; } = 90.0;
|
public double DiskUsageCritical { get; set; } = 90.0;
|
||||||
public double DISK_Temp_Warning { get; set; } = 34.0;
|
public double DiskTempWarning { get; set; } = 34.0;
|
||||||
public double DISK_Temp_Critical { get; set; } = 36.0;
|
public double DiskTempCritical { get; set; } = 36.0;
|
||||||
|
|
||||||
|
|
||||||
// Database
|
// Database
|
||||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
public Boolean IsOnline { get; set; } = false;
|
public bool IsOnline { get; set; } = false;
|
||||||
|
|
||||||
public DateTime LastSeen { get; set; }
|
public DateTime LastSeen { get; set; }
|
||||||
|
|
||||||
public Boolean IsVerified { get; set; } = false;
|
public bool IsVerified { get; set; } = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ builder.Host.UseSerilog();
|
|||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddControllersWithViews();
|
builder.Services.AddControllersWithViews();
|
||||||
|
|
||||||
|
// Health Checks
|
||||||
|
builder.Services.AddHealthChecks()
|
||||||
|
.AddDbContextCheck<AppDbContext>("database");
|
||||||
|
|
||||||
// HttpContentAccessor
|
// HttpContentAccessor
|
||||||
builder.Services.AddHttpContextAccessor();
|
builder.Services.AddHttpContextAccessor();
|
||||||
|
|
||||||
@@ -159,6 +163,9 @@ app.UseSwaggerUI(options =>
|
|||||||
options.RoutePrefix = "api/v1/swagger";
|
options.RoutePrefix = "api/v1/swagger";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 🔹 Health Check Endpoint
|
||||||
|
app.MapHealthChecks("/health");
|
||||||
|
|
||||||
// 🔹 Authentifizierung & Autorisierung
|
// 🔹 Authentifizierung & Autorisierung
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ namespace Watcher.Services;
|
|||||||
|
|
||||||
public class DashboardStore : IDashboardStore
|
public class DashboardStore : IDashboardStore
|
||||||
{
|
{
|
||||||
public String? NetworkStatus { get; set; }
|
public string? NetworkStatus { get; set; }
|
||||||
|
|
||||||
public String? DatabaseStatus { get; set; }
|
public string? DatabaseStatus { get; set; }
|
||||||
}
|
}
|
||||||
@@ -21,14 +21,14 @@ public class DatabaseCheck : BackgroundService
|
|||||||
while (await timer.WaitForNextTickAsync(stoppingToken))
|
while (await timer.WaitForNextTickAsync(stoppingToken))
|
||||||
{
|
{
|
||||||
// Hintergrundprozess abwarten
|
// Hintergrundprozess abwarten
|
||||||
await checkDatabaseIntegrity();
|
await CheckDatabaseIntegrity();
|
||||||
// 5 Sekdunden Offset
|
// 5 Sekdunden Offset
|
||||||
await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken);
|
await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// String sqliteConnectionString als Argument übergeben
|
// String sqliteConnectionString als Argument übergeben
|
||||||
public Task checkDatabaseIntegrity()
|
public Task CheckDatabaseIntegrity()
|
||||||
{
|
{
|
||||||
using var conn = new SqliteConnection("Data Source=./persistence/watcher.db");
|
using var conn = new SqliteConnection("Data Source=./persistence/watcher.db");
|
||||||
_logger.LogInformation("Sqlite Integrity-Check started...");
|
_logger.LogInformation("Sqlite Integrity-Check started...");
|
||||||
|
|||||||
@@ -2,6 +2,6 @@ namespace Watcher.Services;
|
|||||||
|
|
||||||
public interface IDashboardStore
|
public interface IDashboardStore
|
||||||
{
|
{
|
||||||
String? NetworkStatus { get; set; }
|
string? NetworkStatus { get; set; }
|
||||||
String? DatabaseStatus { get; set; }
|
string? DatabaseStatus { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ namespace Watcher.Services;
|
|||||||
|
|
||||||
public interface ISystemStore
|
public interface ISystemStore
|
||||||
{
|
{
|
||||||
Boolean NewVersionAvailable { get; set; }
|
bool NewVersionAvailable { get; set; }
|
||||||
|
|
||||||
Double DatabaseSize { get; set; }
|
double DatabaseSize { get; set; }
|
||||||
|
|
||||||
int FrontendRefreshIntervalMilliseconds { get; set; }
|
int FrontendRefreshIntervalMilliseconds { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ public class NetworkCheck : BackgroundService
|
|||||||
{
|
{
|
||||||
private readonly ILogger<NetworkCheck> _logger;
|
private readonly ILogger<NetworkCheck> _logger;
|
||||||
|
|
||||||
private IDashboardStore _DashboardStore;
|
private IDashboardStore _dashboardStore;
|
||||||
|
|
||||||
public NetworkCheck(ILogger<NetworkCheck> logger, IDashboardStore DashboardStore)
|
public NetworkCheck(ILogger<NetworkCheck> logger, IDashboardStore dashboardStore)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_DashboardStore = DashboardStore;
|
_dashboardStore = dashboardStore;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,14 +21,14 @@ public class NetworkCheck : BackgroundService
|
|||||||
while (await timer.WaitForNextTickAsync(stoppingToken))
|
while (await timer.WaitForNextTickAsync(stoppingToken))
|
||||||
{
|
{
|
||||||
// Hintergrundprozess abwarten
|
// Hintergrundprozess abwarten
|
||||||
await checkConnectionAsync();
|
await CheckConnectionAsync();
|
||||||
|
|
||||||
// 5 Sekdunden Offset
|
// 5 Sekdunden Offset
|
||||||
await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken);
|
await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task checkConnectionAsync()
|
public Task CheckConnectionAsync()
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Networkcheck started.");
|
_logger.LogInformation("Networkcheck started.");
|
||||||
|
|
||||||
@@ -40,13 +40,13 @@ public class NetworkCheck : BackgroundService
|
|||||||
PingReply reply = p.Send(host, 3000);
|
PingReply reply = p.Send(host, 3000);
|
||||||
if (reply.Status == IPStatus.Success)
|
if (reply.Status == IPStatus.Success)
|
||||||
{
|
{
|
||||||
_DashboardStore.NetworkStatus = "online";
|
_dashboardStore.NetworkStatus = "online";
|
||||||
_logger.LogInformation("Ping successfull. Watcher is online.");
|
_logger.LogInformation("Ping successfull. Watcher is online.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
_DashboardStore.NetworkStatus = "offline";
|
_dashboardStore.NetworkStatus = "offline";
|
||||||
_logger.LogError("Ping failed. Watcher appears to have no network connection.");
|
_logger.LogError("Ping failed. Watcher appears to have no network connection.");
|
||||||
|
|
||||||
// LogEvent erstellen
|
// LogEvent erstellen
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ public class SystemManagement : BackgroundService
|
|||||||
{
|
{
|
||||||
private readonly ILogger<NetworkCheck> _logger;
|
private readonly ILogger<NetworkCheck> _logger;
|
||||||
|
|
||||||
private ISystemStore _SystemStore;
|
private ISystemStore _systemStore;
|
||||||
|
|
||||||
public SystemManagement(ILogger<NetworkCheck> logger, ISystemStore SystemStore)
|
public SystemManagement(ILogger<NetworkCheck> logger, ISystemStore systemStore)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_SystemStore = SystemStore;
|
_systemStore = systemStore;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,19 +23,19 @@ public class SystemManagement : BackgroundService
|
|||||||
while (await timer.WaitForNextTickAsync(stoppingToken))
|
while (await timer.WaitForNextTickAsync(stoppingToken))
|
||||||
{
|
{
|
||||||
// Hintergrundprozess abwarten
|
// Hintergrundprozess abwarten
|
||||||
await checkForNewDockerImageVersion();
|
await CheckForNewDockerImageVersion();
|
||||||
|
|
||||||
// 5 Sekdunden Offset
|
// 5 Sekdunden Offset
|
||||||
await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken);
|
await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task checkForNewDockerImageVersion()
|
public Task CheckForNewDockerImageVersion()
|
||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task createDailySqliteBackup()
|
public Task CreateDailySqliteBackup()
|
||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ namespace Watcher.Services;
|
|||||||
|
|
||||||
public class SystemStore: ISystemStore
|
public class SystemStore: ISystemStore
|
||||||
{
|
{
|
||||||
public Boolean NewVersionAvailable { get; set; }
|
public bool NewVersionAvailable { get; set; }
|
||||||
|
|
||||||
public Double DatabaseSize { get; set; }
|
public double DatabaseSize { get; set; }
|
||||||
|
|
||||||
public int FrontendRefreshIntervalMilliseconds { get; set; }
|
public int FrontendRefreshIntervalMilliseconds { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ namespace Watcher.ViewModels
|
|||||||
public List<LogEvent> RecentEvents { get; set; } = new();
|
public List<LogEvent> RecentEvents { get; set; } = new();
|
||||||
public List<Container> Containers { get; set; } = new();
|
public List<Container> Containers { get; set; } = new();
|
||||||
|
|
||||||
public String? NetworkStatus { get; set; } = "?";
|
public string? NetworkStatus { get; set; } = "?";
|
||||||
public String? DatabaseStatus { get; set; } = "?";
|
public string? DatabaseStatus { get; set; } = "?";
|
||||||
|
|
||||||
public int RefreshIntervalMilliseconds { get; set; } = 30000;
|
public int RefreshIntervalMilliseconds { get; set; } = 30000;
|
||||||
|
|
||||||
|
|||||||
@@ -17,22 +17,22 @@ namespace Watcher.ViewModels
|
|||||||
public required string Type { get; set; }
|
public required string Type { get; set; }
|
||||||
|
|
||||||
// Hardware Measurment Warning/Crit Values
|
// Hardware Measurment Warning/Crit Values
|
||||||
public double CPU_Load_Warning { get; set; } = 75.0;
|
public double CpuLoadWarning { get; set; } = 75.0;
|
||||||
public double CPU_Load_Critical { get; set; } = 90.0;
|
public double CpuLoadCritical { get; set; } = 90.0;
|
||||||
public double CPU_Temp_Warning { get; set; } = 80.0;
|
public double CpuTempWarning { get; set; } = 80.0;
|
||||||
public double CPU_Temp_Critical { get; set; } = 90.0;
|
public double CpuTempCritical { get; set; } = 90.0;
|
||||||
|
|
||||||
public double RAM_Load_Warning { get; set; } = 85.0;
|
public double RamLoadWarning { get; set; } = 85.0;
|
||||||
public double RAM_Load_Critical { get; set; } = 95.0;
|
public double RamLoadCritical { get; set; } = 95.0;
|
||||||
|
|
||||||
public double GPU_Load_Warning { get; set; } = 75.0;
|
public double GpuLoadWarning { get; set; } = 75.0;
|
||||||
public double GPU_Load_Critical { get; set; } = 90.0;
|
public double GpuLoadCritical { get; set; } = 90.0;
|
||||||
public double GPU_Temp_Warning { get; set; } = 70.0;
|
public double GpuTempWarning { get; set; } = 70.0;
|
||||||
public double GPU_Temp_Critical { get; set; } = 80.0;
|
public double GpuTempCritical { get; set; } = 80.0;
|
||||||
|
|
||||||
public double Disk_Usage_Warning { get; set; } = 75.0;
|
public double DiskUsageWarning { get; set; } = 75.0;
|
||||||
public double Disk_Usage_Critical { get; set; } = 90.0;
|
public double DiskUsageCritical { get; set; } = 90.0;
|
||||||
public double DISK_Temp_Warning { get; set; } = 34.0;
|
public double DiskTempWarning { get; set; } = 34.0;
|
||||||
public double DISK_Temp_Critical { get; set; } = 36.0;
|
public double DiskTempCritical { get; set; } = 36.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,11 +31,11 @@ public class ServerDetailsViewModel
|
|||||||
// Database
|
// Database
|
||||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
public Boolean IsOnline { get; set; } = false;
|
public bool IsOnline { get; set; } = false;
|
||||||
|
|
||||||
public DateTime LastSeen { get; set; }
|
public DateTime LastSeen { get; set; }
|
||||||
|
|
||||||
public Boolean IsVerified { get; set; } = false;
|
public bool IsVerified { get; set; } = false;
|
||||||
|
|
||||||
public int RefreshIntervalMilliseconds { get; set; } = 30000;
|
public int RefreshIntervalMilliseconds { get; set; } = 30000;
|
||||||
}
|
}
|
||||||
@@ -54,32 +54,32 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label asp-for="CPU_Load_Warning" class="form-label"><i class="bi bi-graph-up me-1"></i>Warnung bei Auslastung (%)</label>
|
<label asp-for="CpuLoadWarning" class="form-label"><i class="bi bi-graph-up me-1"></i>Warnung bei Auslastung (%)</label>
|
||||||
<input asp-for="CPU_Load_Warning" class="form-control" placeholder="z.B. 80" />
|
<input asp-for="CpuLoadWarning" class="form-control" placeholder="z.B. 80" />
|
||||||
<span asp-validation-for="CPU_Load_Warning" class="text-danger small"></span>
|
<span asp-validation-for="CpuLoadWarning" class="text-danger small"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label asp-for="CPU_Load_Critical" class="form-label"><i class="bi bi-graph-up me-1"></i>Kritische Auslastung (%)</label>
|
<label asp-for="CpuLoadCritical" class="form-label"><i class="bi bi-graph-up me-1"></i>Kritische Auslastung (%)</label>
|
||||||
<input asp-for="CPU_Load_Critical" class="form-control" placeholder="z.B. 95" />
|
<input asp-for="CpuLoadCritical" class="form-control" placeholder="z.B. 95" />
|
||||||
<span asp-validation-for="CPU_Load_Critical" class="text-danger small"></span>
|
<span asp-validation-for="CpuLoadCritical" class="text-danger small"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label asp-for="CPU_Temp_Warning" class="form-label"><i class="bi bi-thermometer-half me-1"></i>Warnung bei Temperatur (°C)</label>
|
<label asp-for="CpuTempWarning" class="form-label"><i class="bi bi-thermometer-half me-1"></i>Warnung bei Temperatur (°C)</label>
|
||||||
<input asp-for="CPU_Temp_Warning" class="form-control" placeholder="z.B. 75" />
|
<input asp-for="CpuTempWarning" class="form-control" placeholder="z.B. 75" />
|
||||||
<span asp-validation-for="CPU_Temp_Warning" class="text-danger small"></span>
|
<span asp-validation-for="CpuTempWarning" class="text-danger small"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label asp-for="CPU_Temp_Critical" class="form-label"><i class="bi bi-thermometer-high me-1"></i>Kritische Temperatur (°C)</label>
|
<label asp-for="CpuTempCritical" class="form-label"><i class="bi bi-thermometer-high me-1"></i>Kritische Temperatur (°C)</label>
|
||||||
<input asp-for="CPU_Temp_Critical" class="form-control" placeholder="z.B. 90" />
|
<input asp-for="CpuTempCritical" class="form-control" placeholder="z.B. 90" />
|
||||||
<span asp-validation-for="CPU_Temp_Critical" class="text-danger small"></span>
|
<span asp-validation-for="CpuTempCritical" class="text-danger small"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -90,16 +90,16 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label asp-for="RAM_Load_Warning" class="form-label"><i class="bi bi-graph-up me-1"></i>Warnung bei Auslastung (%)</label>
|
<label asp-for="RamLoadWarning" class="form-label"><i class="bi bi-graph-up me-1"></i>Warnung bei Auslastung (%)</label>
|
||||||
<input asp-for="RAM_Load_Warning" class="form-control" placeholder="z.B. 85" />
|
<input asp-for="RamLoadWarning" class="form-control" placeholder="z.B. 85" />
|
||||||
<span asp-validation-for="RAM_Load_Warning" class="text-danger small"></span>
|
<span asp-validation-for="RamLoadWarning" class="text-danger small"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label asp-for="RAM_Load_Critical" class="form-label"><i class="bi bi-graph-up me-1"></i>Kritische Auslastung (%)</label>
|
<label asp-for="RamLoadCritical" class="form-label"><i class="bi bi-graph-up me-1"></i>Kritische Auslastung (%)</label>
|
||||||
<input asp-for="RAM_Load_Critical" class="form-control" placeholder="z.B. 98" />
|
<input asp-for="RamLoadCritical" class="form-control" placeholder="z.B. 98" />
|
||||||
<span asp-validation-for="RAM_Load_Critical" class="text-danger small"></span>
|
<span asp-validation-for="RamLoadCritical" class="text-danger small"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -110,32 +110,32 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label asp-for="Disk_Usage_Warning" class="form-label"><i class="bi bi-disc-fill me-1"></i>Warnung bei Auslastung (%)</label>
|
<label asp-for="DiskUsageWarning" class="form-label"><i class="bi bi-disc-fill me-1"></i>Warnung bei Auslastung (%)</label>
|
||||||
<input asp-for="Disk_Usage_Warning" class="form-control" placeholder="z.B. 90" />
|
<input asp-for="DiskUsageWarning" class="form-control" placeholder="z.B. 90" />
|
||||||
<span asp-validation-for="Disk_Usage_Warning" class="text-danger small"></span>
|
<span asp-validation-for="DiskUsageWarning" class="text-danger small"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label asp-for="Disk_Usage_Critical" class="form-label"><i class="bi bi-disc-fill me-1"></i>Kritische Auslastung (%)</label>
|
<label asp-for="DiskUsageCritical" class="form-label"><i class="bi bi-disc-fill me-1"></i>Kritische Auslastung (%)</label>
|
||||||
<input asp-for="Disk_Usage_Critical" class="form-control" placeholder="z.B. 98" />
|
<input asp-for="DiskUsageCritical" class="form-control" placeholder="z.B. 98" />
|
||||||
<span asp-validation-for="Disk_Usage_Critical" class="text-danger small"></span>
|
<span asp-validation-for="DiskUsageCritical" class="text-danger small"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label asp-for="DISK_Temp_Warning" class="form-label"><i class="bi bi-thermometer-half me-1"></i>Warnung bei Temperatur (°C)</label>
|
<label asp-for="DiskTempWarning" class="form-label"><i class="bi bi-thermometer-half me-1"></i>Warnung bei Temperatur (°C)</label>
|
||||||
<input asp-for="DISK_Temp_Warning" class="form-control" placeholder="z.B. 45" />
|
<input asp-for="DiskTempWarning" class="form-control" placeholder="z.B. 45" />
|
||||||
<span asp-validation-for="DISK_Temp_Warning" class="text-danger small"></span>
|
<span asp-validation-for="DiskTempWarning" class="text-danger small"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label asp-for="DISK_Temp_Critical" class="form-label"><i class="bi bi-thermometer-high me-1"></i>Kritische Temperatur (°C)</label>
|
<label asp-for="DiskTempCritical" class="form-label"><i class="bi bi-thermometer-high me-1"></i>Kritische Temperatur (°C)</label>
|
||||||
<input asp-for="DISK_Temp_Critical" class="form-control" placeholder="z.B. 55" />
|
<input asp-for="DiskTempCritical" class="form-control" placeholder="z.B. 55" />
|
||||||
<span asp-validation-for="DISK_Temp_Critical" class="text-danger small"></span>
|
<span asp-validation-for="DiskTempCritical" class="text-danger small"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -146,32 +146,32 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label asp-for="GPU_Load_Warning" class="form-label"><i class="bi bi-graph-up me-1"></i>Warnung bei Auslastung (%)</label>
|
<label asp-for="GpuLoadWarning" class="form-label"><i class="bi bi-graph-up me-1"></i>Warnung bei Auslastung (%)</label>
|
||||||
<input asp-for="GPU_Load_Warning" class="form-control" placeholder="z.B. 80" />
|
<input asp-for="GpuLoadWarning" class="form-control" placeholder="z.B. 80" />
|
||||||
<span asp-validation-for="GPU_Load_Warning" class="text-danger small"></span>
|
<span asp-validation-for="GpuLoadWarning" class="text-danger small"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label asp-for="GPU_Load_Critical" class="form-label"><i class="bi bi-graph-up me-1"></i>Kritische Auslastung (%)</label>
|
<label asp-for="GpuLoadCritical" class="form-label"><i class="bi bi-graph-up me-1"></i>Kritische Auslastung (%)</label>
|
||||||
<input asp-for="GPU_Load_Critical" class="form-control" placeholder="z.B. 95" />
|
<input asp-for="GpuLoadCritical" class="form-control" placeholder="z.B. 95" />
|
||||||
<span asp-validation-for="GPU_Load_Critical" class="text-danger small"></span>
|
<span asp-validation-for="GpuLoadCritical" class="text-danger small"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label asp-for="GPU_Temp_Warning" class="form-label"><i class="bi bi-thermometer-half me-1"></i>Warnung bei Temperatur (°C)</label>
|
<label asp-for="GpuTempWarning" class="form-label"><i class="bi bi-thermometer-half me-1"></i>Warnung bei Temperatur (°C)</label>
|
||||||
<input asp-for="GPU_Temp_Warning" class="form-control" placeholder="z.B. 70" />
|
<input asp-for="GpuTempWarning" class="form-control" placeholder="z.B. 70" />
|
||||||
<span asp-validation-for="GPU_Temp_Warning" class="text-danger small"></span>
|
<span asp-validation-for="GpuTempWarning" class="text-danger small"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label asp-for="GPU_Temp_Critical" class="form-label"><i class="bi bi-thermometer-high me-1"></i>Kritische Temperatur (°C)</label>
|
<label asp-for="GpuTempCritical" class="form-label"><i class="bi bi-thermometer-high me-1"></i>Kritische Temperatur (°C)</label>
|
||||||
<input asp-for="GPU_Temp_Critical" class="form-control" placeholder="z.B. 85" />
|
<input asp-for="GpuTempCritical" class="form-control" placeholder="z.B. 85" />
|
||||||
<span asp-validation-for="GPU_Temp_Critical" class="text-danger small"></span>
|
<span asp-validation-for="GpuTempCritical" class="text-danger small"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.6" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="9.0.8" />
|
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="9.0.8" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="8.0.6" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.3.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.3.0" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
|
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
|
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
|
||||||
|
|||||||
@@ -2,27 +2,71 @@ services:
|
|||||||
watcher:
|
watcher:
|
||||||
image: git.triggermeelmo.com/watcher/watcher-server:${IMAGE_VERSION:-latest}
|
image: git.triggermeelmo.com/watcher/watcher-server:${IMAGE_VERSION:-latest}
|
||||||
container_name: watcher
|
container_name: watcher
|
||||||
|
|
||||||
|
# Resource Management
|
||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
memory: 200M
|
memory: 200M
|
||||||
|
cpus: '0.5'
|
||||||
|
reservations:
|
||||||
|
memory: 100M
|
||||||
|
cpus: '0.25'
|
||||||
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
|
# Security
|
||||||
|
user: "1000:1000"
|
||||||
|
|
||||||
|
# Health Check
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 40s
|
||||||
|
|
||||||
|
# Environment
|
||||||
environment:
|
environment:
|
||||||
|
# Timezone
|
||||||
|
- TZ=Europe/Berlin
|
||||||
|
|
||||||
# Application Version (wird aus Image-Tag übernommen)
|
# Application Version (wird aus Image-Tag übernommen)
|
||||||
- WATCHER_VERSION=${IMAGE_VERSION:-latest}
|
- WATCHER_VERSION=${IMAGE_VERSION:-latest}
|
||||||
|
|
||||||
|
# ASP.NET Core
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Production
|
||||||
|
- ASPNETCORE_URLS=http://+:5000
|
||||||
|
|
||||||
# Update Check
|
# Update Check
|
||||||
- UPDATE_CHECK_ENABLED=true
|
- UPDATE_CHECK_ENABLED=true
|
||||||
- UPDATE_CHECK_INTERVAL_HOURS=24
|
- UPDATE_CHECK_INTERVAL_HOURS=24
|
||||||
- UPDATE_CHECK_REPOSITORY_URL=https://git.triggermeelmo.com/api/v1/repos/Watcher/watcher/releases/latest
|
- UPDATE_CHECK_REPOSITORY_URL=https://git.triggermeelmo.com/api/v1/repos/Watcher/watcher/releases/latest
|
||||||
|
|
||||||
# Data Retention Policy
|
# Data Retention Policy
|
||||||
- METRIC_RETENTION_DAYS=30
|
- METRIC_RETENTION_DAYS=30
|
||||||
- METRIC_CLEANUP_INTERVAL_HOURS=24
|
- METRIC_CLEANUP_INTERVAL_HOURS=24
|
||||||
- METRIC_CLEANUP_ENABLED=true
|
- METRIC_CLEANUP_ENABLED=true
|
||||||
|
|
||||||
# Aktualisierungsrate Frontend
|
# Aktualisierungsrate Frontend
|
||||||
- FRONTEND_REFRESH_INTERVAL_SECONDS=30
|
- FRONTEND_REFRESH_INTERVAL_SECONDS=30
|
||||||
|
|
||||||
|
# Ports
|
||||||
ports:
|
ports:
|
||||||
- "5000:5000"
|
- "5000:5000"
|
||||||
|
|
||||||
|
# Volumes
|
||||||
volumes:
|
volumes:
|
||||||
- ./data/db:/app/persistence
|
- ./data/db:/app/persistence
|
||||||
- ./data/dumps:/app/wwwroot/downloads/sqlite
|
- ./data/dumps:/app/wwwroot/downloads/sqlite
|
||||||
- ./data/logs:/app/logs
|
- ./data/logs:/app/logs
|
||||||
|
|
||||||
|
# Labels (Traefik Integration)
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
- "traefik.http.routers.watcher.rule=Host(`watcher.example.com`)"
|
||||||
|
- "traefik.http.routers.watcher.entrypoints=websecure"
|
||||||
|
- "traefik.http.routers.watcher.tls.certresolver=letsencrypt"
|
||||||
|
- "traefik.http.services.watcher.loadbalancer.server.port=5000"
|
||||||
|
- "com.watcher.description=Server Monitoring Application"
|
||||||
|
- "com.watcher.version=${IMAGE_VERSION:-latest}"
|
||||||
|
|||||||
Reference in New Issue
Block a user