diff --git a/Watcher/Migrations/20250730172010_MeasurementWarnings.Designer.cs b/Watcher/Migrations/20250730172010_MeasurementWarnings.Designer.cs new file mode 100644 index 0000000..25baf51 --- /dev/null +++ b/Watcher/Migrations/20250730172010_MeasurementWarnings.Designer.cs @@ -0,0 +1,377 @@ +// +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("20250730172010_MeasurementWarnings")] + partial class MeasurementWarnings + { + /// + 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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("ExposedPort") + .HasColumnType("INTEGER"); + + b.Property("Health") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("HostServerId") + .HasColumnType("INTEGER"); + + b.Property("Image") + .HasColumnType("TEXT"); + + b.Property("ImageId") + .HasColumnType("INTEGER"); + + b.Property("InternalPort") + .HasColumnType("INTEGER"); + + b.Property("IsRunning") + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("TagId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("HostServerId"); + + b.HasIndex("ImageId"); + + b.HasIndex("TagId"); + + b.ToTable("Containers"); + }); + + modelBuilder.Entity("Watcher.Models.Image", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Tag") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Images"); + }); + + modelBuilder.Entity("Watcher.Models.LogEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ContainerId") + .HasColumnType("INTEGER"); + + b.Property("Level") + .HasColumnType("TEXT"); + + b.Property("Message") + .HasColumnType("TEXT"); + + b.Property("ServerId") + .HasColumnType("INTEGER"); + + b.Property("Timestamp") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ContainerId"); + + b.HasIndex("ServerId"); + + b.ToTable("LogEvents"); + }); + + modelBuilder.Entity("Watcher.Models.Metric", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CPU_Load") + .HasColumnType("REAL"); + + b.Property("CPU_Temp") + .HasColumnType("REAL"); + + b.Property("DISK_Size") + .HasColumnType("REAL"); + + b.Property("DISK_Temp") + .HasColumnType("REAL"); + + b.Property("DISK_Usage") + .HasColumnType("REAL"); + + b.Property("GPU_Load") + .HasColumnType("REAL"); + + b.Property("GPU_Temp") + .HasColumnType("REAL"); + + b.Property("GPU_Vram_Size") + .HasColumnType("REAL"); + + b.Property("GPU_Vram_Usage") + .HasColumnType("REAL"); + + b.Property("NET_In") + .HasColumnType("REAL"); + + b.Property("NET_Out") + .HasColumnType("REAL"); + + b.Property("RAM_Load") + .HasColumnType("REAL"); + + b.Property("RAM_Size") + .HasColumnType("REAL"); + + b.Property("ServerId") + .HasColumnType("INTEGER"); + + b.Property("Timestamp") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Metrics"); + }); + + modelBuilder.Entity("Watcher.Models.Server", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CPU_Load_Critical") + .HasColumnType("REAL"); + + b.Property("CPU_Load_Warning") + .HasColumnType("REAL"); + + b.Property("CPU_Temp_Critical") + .HasColumnType("REAL"); + + b.Property("CPU_Temp_Warning") + .HasColumnType("REAL"); + + b.Property("CpuCores") + .HasColumnType("INTEGER"); + + b.Property("CpuType") + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("DISK_Temp_Critical") + .HasColumnType("REAL"); + + b.Property("DISK_Temp_Warning") + .HasColumnType("REAL"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("DiskSpace") + .HasColumnType("TEXT"); + + b.Property("Disk_Usage_Critical") + .HasColumnType("REAL"); + + b.Property("Disk_Usage_Warning") + .HasColumnType("REAL"); + + b.Property("GPU_Load_Critical") + .HasColumnType("REAL"); + + b.Property("GPU_Load_Warning") + .HasColumnType("REAL"); + + b.Property("GPU_Temp_Critical") + .HasColumnType("REAL"); + + b.Property("GPU_Temp_Warning") + .HasColumnType("REAL"); + + b.Property("GpuType") + .HasColumnType("TEXT"); + + b.Property("IPAddress") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("IsOnline") + .HasColumnType("INTEGER"); + + b.Property("IsVerified") + .HasColumnType("INTEGER"); + + b.Property("LastSeen") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("RAM_Load_Critical") + .HasColumnType("REAL"); + + b.Property("RAM_Load_Warning") + .HasColumnType("REAL"); + + b.Property("RamSize") + .HasColumnType("REAL"); + + b.Property("TagId") + .HasColumnType("INTEGER"); + + b.Property("Type") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("TagId"); + + b.ToTable("Servers"); + }); + + modelBuilder.Entity("Watcher.Models.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Tags"); + }); + + modelBuilder.Entity("Watcher.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .HasColumnType("TEXT"); + + b.Property("IdentityProvider") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("LastLogin") + .HasColumnType("TEXT"); + + b.Property("OIDC_Id") + .HasColumnType("TEXT"); + + b.Property("Password") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Username") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("Watcher.Models.Container", b => + { + b.HasOne("Watcher.Models.Server", "HostServer") + .WithMany() + .HasForeignKey("HostServerId"); + + b.HasOne("Watcher.Models.Image", null) + .WithMany("Containers") + .HasForeignKey("ImageId"); + + b.HasOne("Watcher.Models.Tag", null) + .WithMany("Containers") + .HasForeignKey("TagId"); + + b.Navigation("HostServer"); + }); + + 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 + } + } +} diff --git a/Watcher/Migrations/20250730172010_MeasurementWarnings.cs b/Watcher/Migrations/20250730172010_MeasurementWarnings.cs new file mode 100644 index 0000000..f13e5c7 --- /dev/null +++ b/Watcher/Migrations/20250730172010_MeasurementWarnings.cs @@ -0,0 +1,172 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Watcher.Migrations +{ + /// + public partial class MeasurementWarnings : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "CPU_Load_Critical", + table: "Servers", + type: "REAL", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "CPU_Load_Warning", + table: "Servers", + type: "REAL", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "CPU_Temp_Critical", + table: "Servers", + type: "REAL", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "CPU_Temp_Warning", + table: "Servers", + type: "REAL", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "DISK_Temp_Critical", + table: "Servers", + type: "REAL", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "DISK_Temp_Warning", + table: "Servers", + type: "REAL", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "Disk_Usage_Critical", + table: "Servers", + type: "REAL", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "Disk_Usage_Warning", + table: "Servers", + type: "REAL", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "GPU_Load_Critical", + table: "Servers", + type: "REAL", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "GPU_Load_Warning", + table: "Servers", + type: "REAL", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "GPU_Temp_Critical", + table: "Servers", + type: "REAL", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "GPU_Temp_Warning", + table: "Servers", + type: "REAL", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "RAM_Load_Critical", + table: "Servers", + type: "REAL", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "RAM_Load_Warning", + table: "Servers", + type: "REAL", + nullable: false, + defaultValue: 0.0); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "CPU_Load_Critical", + table: "Servers"); + + migrationBuilder.DropColumn( + name: "CPU_Load_Warning", + table: "Servers"); + + migrationBuilder.DropColumn( + name: "CPU_Temp_Critical", + table: "Servers"); + + migrationBuilder.DropColumn( + name: "CPU_Temp_Warning", + table: "Servers"); + + migrationBuilder.DropColumn( + name: "DISK_Temp_Critical", + table: "Servers"); + + migrationBuilder.DropColumn( + name: "DISK_Temp_Warning", + table: "Servers"); + + migrationBuilder.DropColumn( + name: "Disk_Usage_Critical", + table: "Servers"); + + migrationBuilder.DropColumn( + name: "Disk_Usage_Warning", + table: "Servers"); + + migrationBuilder.DropColumn( + name: "GPU_Load_Critical", + table: "Servers"); + + migrationBuilder.DropColumn( + name: "GPU_Load_Warning", + table: "Servers"); + + migrationBuilder.DropColumn( + name: "GPU_Temp_Critical", + table: "Servers"); + + migrationBuilder.DropColumn( + name: "GPU_Temp_Warning", + table: "Servers"); + + migrationBuilder.DropColumn( + name: "RAM_Load_Critical", + table: "Servers"); + + migrationBuilder.DropColumn( + name: "RAM_Load_Warning", + table: "Servers"); + } + } +} diff --git a/Watcher/Migrations/AppDbContextModelSnapshot.cs b/Watcher/Migrations/AppDbContextModelSnapshot.cs index e22567b..7fee30d 100644 --- a/Watcher/Migrations/AppDbContextModelSnapshot.cs +++ b/Watcher/Migrations/AppDbContextModelSnapshot.cs @@ -178,6 +178,18 @@ namespace Watcher.Migrations .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); + b.Property("CPU_Load_Critical") + .HasColumnType("REAL"); + + b.Property("CPU_Load_Warning") + .HasColumnType("REAL"); + + b.Property("CPU_Temp_Critical") + .HasColumnType("REAL"); + + b.Property("CPU_Temp_Warning") + .HasColumnType("REAL"); + b.Property("CpuCores") .HasColumnType("INTEGER"); @@ -187,12 +199,36 @@ namespace Watcher.Migrations b.Property("CreatedAt") .HasColumnType("TEXT"); + b.Property("DISK_Temp_Critical") + .HasColumnType("REAL"); + + b.Property("DISK_Temp_Warning") + .HasColumnType("REAL"); + b.Property("Description") .HasColumnType("TEXT"); b.Property("DiskSpace") .HasColumnType("TEXT"); + b.Property("Disk_Usage_Critical") + .HasColumnType("REAL"); + + b.Property("Disk_Usage_Warning") + .HasColumnType("REAL"); + + b.Property("GPU_Load_Critical") + .HasColumnType("REAL"); + + b.Property("GPU_Load_Warning") + .HasColumnType("REAL"); + + b.Property("GPU_Temp_Critical") + .HasColumnType("REAL"); + + b.Property("GPU_Temp_Warning") + .HasColumnType("REAL"); + b.Property("GpuType") .HasColumnType("TEXT"); @@ -213,6 +249,12 @@ namespace Watcher.Migrations .IsRequired() .HasColumnType("TEXT"); + b.Property("RAM_Load_Critical") + .HasColumnType("REAL"); + + b.Property("RAM_Load_Warning") + .HasColumnType("REAL"); + b.Property("RamSize") .HasColumnType("REAL"); diff --git a/Watcher/Models/Server.cs b/Watcher/Models/Server.cs index a64335d..d29aa3c 100644 --- a/Watcher/Models/Server.cs +++ b/Watcher/Models/Server.cs @@ -27,6 +27,27 @@ public class Server public double RamSize { get; set; } = 0; public string? DiskSpace { get; set; } = string.Empty; + + // Hardware Measurment Warning/Crit Values + public double CPU_Load_Warning { get; set; } = 75.0; + public double CPU_Load_Critical { get; set; } = 90.0; + public double CPU_Temp_Warning { get; set; } = 80.0; + public double CPU_Temp_Critical { get; set; } = 90.0; + + public double RAM_Load_Warning { get; set; } = 85.0; + public double RAM_Load_Critical { get; set; } = 95.0; + + public double GPU_Load_Warning { get; set; } = 75.0; + public double GPU_Load_Critical { get; set; } = 90.0; + public double GPU_Temp_Warning { get; set; } = 70.0; + public double GPU_Temp_Critical { get; set; } = 80.0; + + public double Disk_Usage_Warning { get; set; } = 75.0; + public double Disk_Usage_Critical { get; set; } = 90.0; + public double DISK_Temp_Warning { get; set; } = 34.0; + public double DISK_Temp_Critical { get; set; } = 36.0; + + // Database public DateTime CreatedAt { get; set; } = DateTime.UtcNow; diff --git a/Watcher/ViewModels/AddContainerViewModel.cs b/Watcher/ViewModels/AddContainerViewModel.cs index 38c2017..93765ff 100644 --- a/Watcher/ViewModels/AddContainerViewModel.cs +++ b/Watcher/ViewModels/AddContainerViewModel.cs @@ -1,6 +1,7 @@ using Watcher.Models; namespace Watcher.ViewModels; + public class AddContainerViewModel { public string Name { get; set; } = string.Empty; @@ -10,4 +11,7 @@ public class AddContainerViewModel public string IPAddress { get; set; } = string.Empty; public string ServerName { get; set; } = string.Empty; // oder ID, je nach Relation public bool IsRunning { get; set; } = false; + + + } diff --git a/Watcher/ViewModels/EditServerViewModel.cs b/Watcher/ViewModels/EditServerViewModel.cs index cb7d27d..9345f6e 100644 --- a/Watcher/ViewModels/EditServerViewModel.cs +++ b/Watcher/ViewModels/EditServerViewModel.cs @@ -7,13 +7,32 @@ namespace Watcher.ViewModels public int Id { get; set; } [Required(ErrorMessage = "Name ist erforderlich")] - public string Name { get; set; } + public string? Name { get; set; } [Required(ErrorMessage = "IP-Adresse ist erforderlich")] [RegularExpression(@"^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$", ErrorMessage = "Ungültige IP-Adresse")] - public string IPAddress { get; set; } + public required string IPAddress { get; set; } [Required(ErrorMessage = "Typ ist erforderlich")] - public string Type { get; set; } + public string? Type { get; set; } + + // Hardware Measurment Warning/Crit Values + public double CPU_Load_Warning { get; set; } = 75.0; + public double CPU_Load_Critical { get; set; } = 90.0; + public double CPU_Temp_Warning { get; set; } = 80.0; + public double CPU_Temp_Critical { get; set; } = 90.0; + + public double RAM_Load_Warning { get; set; } = 85.0; + public double RAM_Load_Critical { get; set; } = 95.0; + + public double GPU_Load_Warning { get; set; } = 75.0; + public double GPU_Load_Critical { get; set; } = 90.0; + public double GPU_Temp_Warning { get; set; } = 70.0; + public double GPU_Temp_Critical { get; set; } = 80.0; + + public double Disk_Usage_Warning { get; set; } = 75.0; + public double Disk_Usage_Critical { get; set; } = 90.0; + public double DISK_Temp_Warning { get; set; } = 34.0; + public double DISK_Temp_Critical { get; set; } = 36.0; } } \ No newline at end of file diff --git a/Watcher/Views/Server/EditServer.cshtml b/Watcher/Views/Server/EditServer.cshtml index 4cef587..23b4a5d 100644 --- a/Watcher/Views/Server/EditServer.cshtml +++ b/Watcher/Views/Server/EditServer.cshtml @@ -4,30 +4,178 @@ ViewData["Title"] = "Server bearbeiten"; } -Server bearbeiten +Server bearbeiten @Html.AntiForgeryToken() - - - - + + + Allgemeine Informationen + + + + + + + + + + + + + + + + Typ + + VPS + VM + Standalone + + + - - - - + + + Grenzwerte festlegen + + + + + CPU-Grenzwerte + + + + Warnung bei Auslastung (%) + + + + + + + Kritische Auslastung (%) + + + + + + + + + Warnung bei Temperatur (°C) + + + + + + + Kritische Temperatur (°C) + + + + + + + + + RAM-Grenzwerte + + + + Warnung bei Auslastung (%) + + + + + + + Kritische Auslastung (%) + + + + + + + + + Festplatten-Grenzwerte + + + + Warnung bei Auslastung (%) + + + + + + + Kritische Auslastung (%) + + + + + + + + + Warnung bei Temperatur (°C) + + + + + + + Kritische Temperatur (°C) + + + + + + + + + GPU-Grenzwerte + + + + Warnung bei Auslastung (%) + + + + + + + Kritische Auslastung (%) + + + + + + + + + Warnung bei Temperatur (°C) + + + + + + + Kritische Temperatur (°C) + + + + + + + - - - - + + Speichern + Abbrechen - - Speichern - Abbrechen \ No newline at end of file diff --git a/Watcher/persistence/watcher.db-shm b/Watcher/persistence/watcher.db-shm new file mode 100644 index 0000000..8e09814 Binary files /dev/null and b/Watcher/persistence/watcher.db-shm differ diff --git a/Watcher/persistence/watcher.db-wal b/Watcher/persistence/watcher.db-wal new file mode 100644 index 0000000..bac8091 Binary files /dev/null and b/Watcher/persistence/watcher.db-wal differ