Compare commits
11 Commits
02dfdd2a07
...
v0.0.3
| Author | SHA1 | Date | |
|---|---|---|---|
| ae8b60687a | |||
| 3fff8654fe | |||
| 9cfe9e2ab2 | |||
| fd799d6158 | |||
| 5f53207050 | |||
| 746628fdd8 | |||
| 9e50d69ef9 | |||
| ed7525ec0b | |||
| a171f4df32 | |||
| 799d29fd1b | |||
| f09434d66d |
@@ -10,7 +10,7 @@ env:
|
||||
DOTNET_VERSION: '8.0.x'
|
||||
DOCKER_IMAGE_NAME: watcher-server
|
||||
REGISTRY_URL: git.triggermeelmo.com
|
||||
DOCKER_PLATFORMS: 'linux/amd64,linux/arm64'
|
||||
DOCKER_PLATFORMS: 'linux/amd64'
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
@@ -22,6 +22,15 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
|
||||
- name: List files for debugging
|
||||
run: |
|
||||
pwd
|
||||
ls -la
|
||||
find . -name "*.csproj"
|
||||
find . -name "*.sln"
|
||||
|
||||
- name: Setup .NET SDK
|
||||
uses: actions/setup-dotnet@v3
|
||||
@@ -29,17 +38,7 @@ jobs:
|
||||
dotnet-version: ${{ env.DOTNET_VERSION }}
|
||||
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore
|
||||
|
||||
- name: Build
|
||||
run: dotnet build --configuration Release --no-restore
|
||||
|
||||
- name: Test
|
||||
run: dotnet test --no-build --verbosity normal
|
||||
continue-on-error: true
|
||||
|
||||
- name: Publish
|
||||
run: dotnet publish -c Release -o out
|
||||
run: dotnet restore watcher-monitoring.sln
|
||||
|
||||
set-tag:
|
||||
name: Set Tag Name
|
||||
@@ -116,9 +115,9 @@ jobs:
|
||||
- name: Build and Push Multi-Arch Docker Image
|
||||
run: |
|
||||
docker buildx build \
|
||||
--platform ${{ env.DOCKER_PLATFORMS }} \
|
||||
--platform linux/amd64 \
|
||||
--build-arg VERSION=${{ needs.set-tag.outputs.tag_name }} \
|
||||
-t ${{ env.REGISTRY_URL }}/watcher/${{ env.DOCKER_IMAGE_NAME }}:${{ needs.set-tag.outputs.tag_name }} \
|
||||
-t ${{ env.REGISTRY_URL }}/triggermeelmo/${{ env.DOCKER_IMAGE_NAME }}:${{ needs.set-tag.outputs.tag_name }} \
|
||||
--push .
|
||||
|
||||
tag:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
services:
|
||||
watcher:
|
||||
image: git.triggermeelmo.com/watcher/watcher-server:latest
|
||||
image: git.triggermeelmo.com/triggermeelmo/watcher-server:latest
|
||||
container_name: watcher
|
||||
|
||||
# Resource Management
|
||||
@@ -8,7 +8,6 @@ services:
|
||||
resources:
|
||||
limits:
|
||||
memory: 200M
|
||||
cpus: '0.5'
|
||||
|
||||
restart: unless-stopped
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.5.2.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "watcher-monitoring", "watcher-monitoring.csproj", "{54D763FB-AF94-1B76-AA8D-C59D18DEE03D}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "watcher-monitoring", "watcher-monitoring\watcher-monitoring.csproj", "{54D763FB-AF94-1B76-AA8D-C59D18DEE03D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -3,6 +3,8 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using watcher_monitoring.Models;
|
||||
|
||||
using watcher_monitoring.Data;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace watcher_monitoring.Controllers;
|
||||
|
||||
@@ -18,9 +20,11 @@ public class HomeController : Controller
|
||||
}
|
||||
|
||||
// Dashboard
|
||||
public IActionResult Index()
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var servers = new List<dynamic>
|
||||
List<Server> servers = await _dbContext.Servers.ToListAsync();
|
||||
|
||||
var servers1 = new List<dynamic>
|
||||
{
|
||||
new { Name = "Web Server 01", IPAddress = "192.168.1.10", IsOnline = true },
|
||||
new { Name = "Database Server", IPAddress = "192.168.1.20", IsOnline = true },
|
||||
|
||||
@@ -59,7 +59,19 @@ public class MonitoringController : Controller
|
||||
Server server = await _context.Servers.FindAsync(dto.Id);
|
||||
|
||||
// Add Hardware Configuration
|
||||
try
|
||||
{
|
||||
server.CpuType = dto.CpuType;
|
||||
server.CpuCores = dto.CpuCores;
|
||||
server.GpuType = dto.GpuType;
|
||||
server.RamSize = dto.RamSize;
|
||||
// Diskspace fehlt
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex.Message);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
86
watcher-monitoring/Migrations/20260107105629_serverhardwareadd.Designer.cs
generated
Normal file
86
watcher-monitoring/Migrations/20260107105629_serverhardwareadd.Designer.cs
generated
Normal file
@@ -0,0 +1,86 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using watcher_monitoring.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace watcher_monitoring.Migrations
|
||||
{
|
||||
[DbContext(typeof(WatcherDbContext))]
|
||||
[Migration("20260107105629_serverhardwareadd")]
|
||||
partial class serverhardwareadd
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
|
||||
|
||||
modelBuilder.Entity("watcher_monitoring.Models.Server", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("CpuCores")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("CpuType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("DiskSpace")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("GpuType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("IPAddress")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<double>("RamSize")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Servers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("watcher_monitoring.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.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");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace watcher_monitoring.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class serverhardwareadd : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CpuCores",
|
||||
table: "Servers",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "CpuType",
|
||||
table: "Servers",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "DiskSpace",
|
||||
table: "Servers",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "GpuType",
|
||||
table: "Servers",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<double>(
|
||||
name: "RamSize",
|
||||
table: "Servers",
|
||||
type: "REAL",
|
||||
nullable: false,
|
||||
defaultValue: 0.0);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CpuCores",
|
||||
table: "Servers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CpuType",
|
||||
table: "Servers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DiskSpace",
|
||||
table: "Servers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "GpuType",
|
||||
table: "Servers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "RamSize",
|
||||
table: "Servers");
|
||||
}
|
||||
}
|
||||
}
|
||||
98
watcher-monitoring/Migrations/20260107110229_servermetadata.Designer.cs
generated
Normal file
98
watcher-monitoring/Migrations/20260107110229_servermetadata.Designer.cs
generated
Normal file
@@ -0,0 +1,98 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using watcher_monitoring.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace watcher_monitoring.Migrations
|
||||
{
|
||||
[DbContext(typeof(WatcherDbContext))]
|
||||
[Migration("20260107110229_servermetadata")]
|
||||
partial class servermetadata
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
|
||||
|
||||
modelBuilder.Entity("watcher_monitoring.Models.Server", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("CpuCores")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("CpuType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("DiskSpace")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
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>("RamSize")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Servers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("watcher_monitoring.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.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");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace watcher_monitoring.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class servermetadata : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "CreatedAt",
|
||||
table: "Servers",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsOnline",
|
||||
table: "Servers",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsVerified",
|
||||
table: "Servers",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "LastSeen",
|
||||
table: "Servers",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CreatedAt",
|
||||
table: "Servers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsOnline",
|
||||
table: "Servers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsVerified",
|
||||
table: "Servers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "LastSeen",
|
||||
table: "Servers");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,14 +23,41 @@ namespace watcher_monitoring.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("CpuCores")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("CpuType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("DiskSpace")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
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>("RamSize")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Servers");
|
||||
|
||||
@@ -16,4 +16,20 @@ public class Server
|
||||
[Required]
|
||||
// TODO: [RegularExpression("^(((?!25?[6-9])[12]\d|[1-9])?\d\.?\b){4}$")]
|
||||
public required string IPAddress { get; set; }
|
||||
|
||||
// Hardware Infos
|
||||
public string? CpuType { get; set; } = string.Empty;
|
||||
public int CpuCores { get; set; } = 0;
|
||||
public string? GpuType { get; set; } = string.Empty;
|
||||
public double RamSize { get; set; } = 0;
|
||||
public string? DiskSpace { get; set; } = string.Empty;
|
||||
|
||||
// Metadata
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public bool IsOnline { get; set; } = false;
|
||||
|
||||
public DateTime LastSeen { get; set; }
|
||||
|
||||
public bool IsVerified { get; set; } = false;
|
||||
}
|
||||
@@ -7,4 +7,20 @@ public class HardwareDto
|
||||
{
|
||||
[Required]
|
||||
public required int Id;
|
||||
|
||||
[Required]
|
||||
public string? IpAddress { get; set; }
|
||||
|
||||
// Hardware Info
|
||||
[Required]
|
||||
public string? CpuType { get; set; }
|
||||
|
||||
[Required]
|
||||
public int CpuCores { get; set; }
|
||||
|
||||
[Required]
|
||||
public string? GpuType { get; set; }
|
||||
|
||||
[Required]
|
||||
public double RamSize { get; set; }
|
||||
}
|
||||
@@ -52,6 +52,31 @@ builder.Services.AddSwaggerGen(options =>
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Stelle sicher, dass das persistence-Verzeichnis existiert
|
||||
var persistenceDir = Path.Combine(Directory.GetCurrentDirectory(), "persistence");
|
||||
if (!Directory.Exists(persistenceDir))
|
||||
{
|
||||
Log.Information("Erstelle persistence-Verzeichnis: {PersistenceDir}", persistenceDir);
|
||||
Directory.CreateDirectory(persistenceDir);
|
||||
}
|
||||
|
||||
// Datenbank-Migration beim Start ausführen
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<WatcherDbContext>();
|
||||
try
|
||||
{
|
||||
Log.Information("Führe Datenbank-Migrationen aus...");
|
||||
dbContext.Database.Migrate();
|
||||
Log.Information("Datenbank-Migrationen erfolgreich angewendet");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Fehler beim Ausführen der Datenbank-Migrationen");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user