19 Commits

Author SHA1 Message Date
05e5a209da logs eingefügt
All checks were successful
Gitea CI/CD / dotnet-build-and-test (push) Successful in 10m40s
Gitea CI/CD / Set Tag Name (push) Successful in 5s
Gitea CI/CD / docker-build-and-push (push) Successful in 12m32s
Gitea CI/CD / Create Tag (push) Successful in 5s
2026-01-08 14:54:26 +01:00
0b88292a85 Delete Calls for Containers and Servers 2026-01-08 12:48:26 +01:00
5bae9328d9 Added Containers to Database 2026-01-08 12:29:03 +01:00
3a872980da removed registration key 2026-01-08 12:15:02 +01:00
8cda82111d Server gets created at registration now 2026-01-08 12:13:49 +01:00
6e17dcb270 removed old sample data 2026-01-08 12:08:13 +01:00
a1f9a2008f Fixed RegistrationDto 2026-01-08 12:07:59 +01:00
31da3d14a3 Pipeline update for act runner cache and registration endpoint name change
All checks were successful
Gitea CI/CD / dotnet-build-and-test (push) Successful in 10m40s
Gitea CI/CD / Set Tag Name (push) Successful in 5s
Gitea CI/CD / docker-build-and-push (push) Successful in 13m9s
Gitea CI/CD / Create Tag (push) Successful in 5s
2026-01-08 08:58:57 +01:00
ae8b60687a docker build fails at db migrations
All checks were successful
Gitea CI/CD / dotnet-build-and-test (push) Successful in 42s
Gitea CI/CD / Set Tag Name (push) Successful in 4s
Gitea CI/CD / docker-build-and-push (push) Successful in 1m33s
Gitea CI/CD / Create Tag (push) Successful in 4s
2026-01-07 14:24:47 +01:00
3fff8654fe container registry url
All checks were successful
Gitea CI/CD / dotnet-build-and-test (push) Successful in 40s
Gitea CI/CD / Set Tag Name (push) Successful in 5s
Gitea CI/CD / docker-build-and-push (push) Successful in 1m53s
Gitea CI/CD / Create Tag (push) Successful in 5s
2026-01-07 13:55:51 +01:00
9cfe9e2ab2 changed docker registry url
Some checks failed
Gitea CI/CD / dotnet-build-and-test (push) Successful in 43s
Gitea CI/CD / Set Tag Name (push) Successful in 5s
Gitea CI/CD / docker-build-and-push (push) Failing after 16s
Gitea CI/CD / Create Tag (push) Has been skipped
2026-01-07 13:52:45 +01:00
fd799d6158 removed arm64 build
All checks were successful
Gitea CI/CD / dotnet-build-and-test (push) Successful in 41s
Gitea CI/CD / Set Tag Name (push) Successful in 7s
Gitea CI/CD / docker-build-and-push (push) Successful in 1m49s
Gitea CI/CD / Create Tag (push) Successful in 5s
2026-01-07 13:38:21 +01:00
5f53207050 Merge branch 'main' of https://git.triggermeelmo.com/triggermeelmo/Watcher into staging
Some checks failed
Gitea CI/CD / dotnet-build-and-test (push) Successful in 42s
Gitea CI/CD / Set Tag Name (push) Successful in 6s
Gitea CI/CD / Create Tag (push) Has been cancelled
Gitea CI/CD / docker-build-and-push (push) Has been cancelled
2026-01-07 13:18:00 +01:00
746628fdd8 Dockerfile an neue Dateistruktur angepasst
Some checks failed
Gitea CI/CD / dotnet-build-and-test (push) Successful in 39s
Gitea CI/CD / Set Tag Name (push) Successful in 5s
Gitea CI/CD / docker-build-and-push (push) Failing after 1m38s
Gitea CI/CD / Create Tag (push) Has been skipped
2026-01-07 13:09:08 +01:00
9e50d69ef9 p
Some checks failed
Gitea CI/CD / dotnet-build-and-test (push) Successful in 55s
Gitea CI/CD / Set Tag Name (push) Successful in 5s
Gitea CI/CD / docker-build-and-push (push) Failing after 47s
Gitea CI/CD / Create Tag (push) Has been skipped
2026-01-07 13:02:04 +01:00
ed7525ec0b pipeline test
Some checks failed
Gitea CI/CD / dotnet-build-and-test (push) Failing after 24s
Gitea CI/CD / Set Tag Name (push) Has been skipped
Gitea CI/CD / docker-build-and-push (push) Has been skipped
Gitea CI/CD / Create Tag (push) Has been skipped
2026-01-07 13:00:13 +01:00
a171f4df32 moved sln
Some checks failed
Gitea CI/CD / dotnet-build-and-test (push) Failing after 22s
Gitea CI/CD / Set Tag Name (push) Has been skipped
Gitea CI/CD / docker-build-and-push (push) Has been skipped
Gitea CI/CD / Create Tag (push) Has been skipped
2026-01-07 12:56:02 +01:00
799d29fd1b sln file moved
Some checks failed
Gitea CI/CD / dotnet-build-and-test (push) Failing after 23s
Gitea CI/CD / Set Tag Name (push) Has been skipped
Gitea CI/CD / docker-build-and-push (push) Has been skipped
Gitea CI/CD / Create Tag (push) Has been skipped
2026-01-07 12:54:28 +01:00
f09434d66d test
Some checks failed
Gitea CI/CD / dotnet-build-and-test (push) Failing after 38s
Gitea CI/CD / Set Tag Name (push) Has been skipped
Gitea CI/CD / docker-build-and-push (push) Has been skipped
Gitea CI/CD / Create Tag (push) Has been skipped
2026-01-07 12:47:23 +01:00
19 changed files with 781 additions and 36 deletions

View File

@@ -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,17 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: false
# NuGet Cache
- name: Cache NuGet packages
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
@@ -29,22 +40,18 @@ jobs:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore dependencies
run: dotnet restore
run: dotnet restore watcher-monitoring.sln
- name: Build
run: dotnet build --configuration Release --no-restore
run: dotnet build watcher-monitoring.sln --configuration Release --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
run: dotnet test watcher-monitoring.sln --no-build --verbosity normal
continue-on-error: true
- name: Publish
run: dotnet publish -c Release -o out
set-tag:
name: Set Tag Name
needs: [dotnet-build-and-test]
#if: ${{ !failure() && !cancelled() && github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.set_tag.outputs.tag_name }}
@@ -106,6 +113,15 @@ jobs:
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
# Docker Layer Cache
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to Gitea Container Registry
uses: docker/login-action@v3
with:
@@ -113,13 +129,23 @@ jobs:
username: ${{ secrets.AUTOMATION_USERNAME }}
password: ${{ secrets.AUTOMATION_PASSWORD }}
- name: Build and Push Multi-Arch Docker Image
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ env.DOCKER_PLATFORMS }}
push: true
tags: ${{ env.REGISTRY_URL }}/triggermeelmo/${{ env.DOCKER_IMAGE_NAME }}:${{ needs.set-tag.outputs.tag_name }}
build-args: |
VERSION=${{ needs.set-tag.outputs.tag_name }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
# Workaround für Cache-Größe
- name: Move cache
run: |
docker buildx build \
--platform ${{ env.DOCKER_PLATFORMS }} \
--build-arg VERSION=${{ needs.set-tag.outputs.tag_name }} \
-t ${{ env.REGISTRY_URL }}/watcher/${{ env.DOCKER_IMAGE_NAME }}:${{ needs.set-tag.outputs.tag_name }} \
--push .
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
tag:
name: Create Tag

View File

@@ -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

View File

@@ -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

View File

@@ -1,2 +1,96 @@
// Get Methoden um Metrics abzugreifen
// Get Methden um Informationen über den Status des Servers einzuholen
// Get Methden um Informationen über den Status des Servers einzuholen
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using watcher_monitoring.Models;
using watcher_monitoring.Data;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
namespace watcher_monitoring.Controllers;
[ApiController]
[Route("[controller]")]
public class APIController : Controller
{
private readonly WatcherDbContext _context;
private readonly ILogger<APIController> _logger;
public APIController(WatcherDbContext context, ILogger<APIController> logger)
{
_context = context;
_logger = logger;
}
// Server Calls
[HttpGet("get-server")]
public async Task<IActionResult> Servers()
{
List<Server> servers = await _context.Servers.ToListAsync();
return Ok();
}
[HttpPost("add-server")]
public async Task<IActionResult> AddServer()
{
return Ok();
}
[HttpDelete("delete-server/{id}")]
public async Task<IActionResult> DeleteServer(int id)
{
var server = await _context.Servers.FindAsync(id);
if (server == null)
{
_logger.LogError("Server nicht gefunden");
return BadRequest();
}
_context.Servers.Remove(server);
await _context.SaveChangesAsync();
_logger.LogInformation("Server '{server}' erfolgreich gelöscht", server.Name);
return Ok();
}
[HttpPut("edit-server")]
public async Task<IActionResult> EditServer()
{
return Ok();
}
// Container Calls
[HttpGet("get-container")]
public async Task<IActionResult> Containers()
{
List<Container> containers = await _context.Containers.ToListAsync();
return Ok();
}
[HttpDelete("delete-container")]
public async Task<IActionResult> DeleteContainer(int id)
{
var container = await _context.Containers.FindAsync(id);
if (container == null)
{
_logger.LogError("Server nicht gefunden");
return BadRequest();
}
try
{
_context.Containers.Remove(container);
await _context.SaveChangesAsync();
_logger.LogInformation("Container '{container}' erfolgreich gelöscht", container.Id);
return Ok();
} catch (Exception ex)
{
_logger.LogError(ex.Message);
return BadRequest();
}
}
}

View File

@@ -3,31 +3,26 @@ using Microsoft.AspNetCore.Mvc;
using watcher_monitoring.Models;
using watcher_monitoring.Data;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
namespace watcher_monitoring.Controllers;
public class HomeController : Controller
{
private readonly WatcherDbContext _dbContext;
private readonly WatcherDbContext _context;
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger, WatcherDbContext dbContext)
{
_logger = logger;
_dbContext = dbContext;
_context = dbContext;
}
// Dashboard
public IActionResult Index()
public async Task<IActionResult> Index()
{
var servers = 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 },
new { Name = "API Gateway", IPAddress = "192.168.1.30", IsOnline = true },
new { Name = "Cache Server", IPAddress = "192.168.1.40", IsOnline = false },
new { Name = "Backup Server", IPAddress = "192.168.1.50", IsOnline = true }
};
List<Server> servers = await _context.Servers.ToListAsync();
ViewBag.TotalServers = servers.Count;
ViewBag.OnlineServers = servers.Count(s => s.IsOnline);

View File

@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc;
using watcher_monitoring.Payloads;
using watcher_monitoring.Data;
using watcher_monitoring.Models;
using Microsoft.AspNetCore.Authorization.Infrastructure;
namespace watcher_monitoring.Controllers;
@@ -20,8 +21,8 @@ public class MonitoringController : Controller
}
// Registration Endpoint for watcher-agent
[HttpPost("registration")]
public async Task<IActionResult> Registration([FromBody] RegistrationDto dto)
[HttpPost("register")]
public async Task<IActionResult> Register([FromBody] RegistrationDto dto)
{
// payload check
if (!ModelState.IsValid)
@@ -35,7 +36,22 @@ public class MonitoringController : Controller
return BadRequest(new { error = "Invalid registration payload", details = errors });
}
return Ok();
try {
Server server = new Server
{
Name = "test",
IPAddress = dto.IpAddress
};
_context.Servers.Add(server);
await _context.SaveChangesAsync();
return Ok();
} catch (Exception ex)
{
Console.WriteLine(ex.Message);
_logger.LogError(ex.Message);
return BadRequest();
}
}
// Hardware Configuration Endpoint for watcher-agent
@@ -56,10 +72,23 @@ public class MonitoringController : Controller
try
{
// Find Server in Database
Server server = await _context.Servers.FindAsync(dto.Id);
var 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
_logger.LogInformation("Harware configuration successfull for server {server}", server.Name);
}
catch (Exception ex)
{
_logger.LogError(ex.Message);
}
}
catch (Exception ex)
{
@@ -71,9 +100,24 @@ public class MonitoringController : Controller
}
// Server-Metrics endpoint for watcher-agent
[HttpPost("server-metrics/{id}")]
public async Task<IActionResult> ServerMetrics ([FromBody] HardwareDto dto)
{
return Ok();
}
// Service-Detection endpoint for watcher-agent
[HttpPost("container-detection")]
public async Task<IActionResult> ContainerDetection ([FromBody] HardwareDto dto)
{
return Ok();
}
// Service-Metrics endpoint for watcher-agent
// Container-Metrics endpoint for watcher-agent
[HttpPost("container-metrics/{id}")]
public async Task<IActionResult> ContainerMetrics ([FromBody] HardwareDto dto)
{
return Ok();
}
}

View File

@@ -19,4 +19,6 @@ public class WatcherDbContext : DbContext
public DbSet<Server> Servers { get; set; }
public DbSet<User> Users { get; set; }
public DbSet<Container> Containers { get; set; }
}

View 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
}
}
}

View File

@@ -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");
}
}
}

View 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
}
}
}

View File

@@ -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");
}
}
}

View File

@@ -0,0 +1,114 @@
// <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("20260108112653_containers-new")]
partial class containersnew
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
modelBuilder.Entity("watcher_monitoring.Models.Container", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("ContainerName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Containers");
});
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
}
}
}

View File

@@ -0,0 +1,34 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace watcher_monitoring.Migrations
{
/// <inheritdoc />
public partial class containersnew : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Containers",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
ContainerName = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Containers", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Containers");
}
}
}

View File

@@ -17,20 +17,63 @@ namespace watcher_monitoring.Migrations
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
modelBuilder.Entity("watcher_monitoring.Models.Container", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("ContainerName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Containers");
});
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");

View File

@@ -0,0 +1,16 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace watcher_monitoring.Models;
public class Container
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Required]
[StringLength(50)]
public required string ContainerName { get; set; } = null!;
}

View File

@@ -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;
}

View File

@@ -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; }
}

View File

@@ -1,7 +1,11 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.CompilerServices;
namespace watcher_monitoring.Payloads;
public class RegistrationDto
{
public required string IpAddress;
public required string Key;
[Required]
public required string IpAddress { get; set; }
}

View File

@@ -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())
{