Compare commits
3 Commits
bugix/pipe
...
main
Author | SHA1 | Date | |
---|---|---|---|
52927bf64d | |||
7373ea16e0 | |||
9990b35787 |
@@ -1,143 +0,0 @@
|
|||||||
name: Gitea CI/CD
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
branches: [ "development", "main", "staging" ]
|
|
||||||
tags: [ "v*.*.*" ]
|
|
||||||
|
|
||||||
env:
|
|
||||||
DOTNET_VERSION: '8.0.x'
|
|
||||||
DOCKER_IMAGE_NAME: watcher
|
|
||||||
REGISTRY_URL: git.triggermeelmo.com
|
|
||||||
DOCKER_PLATFORMS: 'linux/amd64,linux/arm64'
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
dotnet-build-and-test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup .NET SDK
|
|
||||||
uses: actions/setup-dotnet@v3
|
|
||||||
with:
|
|
||||||
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
|
|
||||||
|
|
||||||
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 }}
|
|
||||||
should_tag: ${{ steps.set_tag.outputs.should_tag }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Determine next semantic version tag
|
|
||||||
id: set_tag
|
|
||||||
run: |
|
|
||||||
git fetch --tags
|
|
||||||
|
|
||||||
# Find latest tag matching vX.Y.Z
|
|
||||||
latest_tag=$(git tag --list 'v*.*.*' --sort=-v:refname | head -n 1)
|
|
||||||
if [[ -z "$latest_tag" ]]; then
|
|
||||||
major=0
|
|
||||||
minor=0
|
|
||||||
patch=0
|
|
||||||
else
|
|
||||||
version="${latest_tag#v}"
|
|
||||||
IFS='.' read -r major minor patch <<< "$version"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
|
|
||||||
major=$((major + 1))
|
|
||||||
minor=0
|
|
||||||
patch=0
|
|
||||||
new_tag="v${major}.${minor}.${patch}"
|
|
||||||
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
|
||||||
echo "should_tag=true" >> $GITHUB_OUTPUT
|
|
||||||
echo "Creating new major version tag: ${new_tag}"
|
|
||||||
|
|
||||||
elif [[ "${GITHUB_REF}" == "refs/heads/development" ]]; then
|
|
||||||
minor=$((minor + 1))
|
|
||||||
patch=0
|
|
||||||
new_tag="v${major}.${minor}.${patch}"
|
|
||||||
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
|
||||||
echo "should_tag=true" >> $GITHUB_OUTPUT
|
|
||||||
echo "Creating new minor version tag: ${new_tag}"
|
|
||||||
|
|
||||||
elif [[ "${GITHUB_REF}" == "refs/heads/staging" ]]; then
|
|
||||||
patch=$((patch + 1))
|
|
||||||
new_tag="v${major}.${minor}.${patch}"
|
|
||||||
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
|
||||||
echo "should_tag=true" >> $GITHUB_OUTPUT
|
|
||||||
echo "Creating new patch version tag: ${new_tag}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker-build-and-push:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: [dotnet-build-and-test, set-tag]
|
|
||||||
if: |
|
|
||||||
needs.set-tag.outputs.should_tag == 'true' &&
|
|
||||||
github.event_name != 'pull_request'
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v2
|
|
||||||
|
|
||||||
- name: Login to Gitea Container Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ${{ env.REGISTRY_URL}}
|
|
||||||
username: ${{ secrets.AUTOMATION_USERNAME }}
|
|
||||||
password: ${{ secrets.AUTOMATION_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Build and Push Multi-Arch Docker Image
|
|
||||||
run: |
|
|
||||||
docker buildx build \
|
|
||||||
--platform ${{ env.DOCKER_PLATFORMS }} \
|
|
||||||
-t ${{ env.REGISTRY_URL }}/watcher/${{ env.DOCKER_IMAGE_NAME }}:${{ needs.set-tag.outputs.tag_name }} \
|
|
||||||
--push .
|
|
||||||
|
|
||||||
tag:
|
|
||||||
name: Create Tag
|
|
||||||
needs: [docker-build-and-push]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up Git user
|
|
||||||
run: |
|
|
||||||
git config user.name "GitHub Actions"
|
|
||||||
git config user.email "actions@github.com"
|
|
||||||
|
|
||||||
- name: Create and push tag
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
|
||||||
echo "Creating new tag: ${{ needs.set-tag.outputs.tag_name }}"
|
|
||||||
git tag ${{ needs.set-tag.outputs.tag_name }}
|
|
||||||
git push origin ${{ needs.set-tag.outputs.tag_name }}
|
|
63
.gitea/workflows/development-build.yaml
Normal file
63
.gitea/workflows/development-build.yaml
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
name: Development Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- development
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOTNET_VERSION: '8.0.x'
|
||||||
|
DOCKER_IMAGE_NAME: 'watcher-server'
|
||||||
|
REGISTRY_URL: 'git.triggermeelmo.com/watcher'
|
||||||
|
DOCKER_PLATFORMS: 'linux/amd64,linux/arm64'
|
||||||
|
RUNNER_TOOL_CACHE: /toolcache # Runner Tool Cache
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup .NET SDK
|
||||||
|
uses: actions/setup-dotnet@v3
|
||||||
|
with:
|
||||||
|
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
|
||||||
|
|
||||||
|
docker-build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build-and-test
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Login to Gitea Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY_URL}}
|
||||||
|
username: ${{ secrets.AUTOMATION_USERNAME }}
|
||||||
|
password: ${{ secrets.AUTOMATION_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and Push Multi-Arch Docker Image
|
||||||
|
run: |
|
||||||
|
docker buildx build \
|
||||||
|
--platform ${{ env.DOCKER_PLATFORMS }} \
|
||||||
|
-t ${{ env.REGISTRY_URL }}/${{ env.DOCKER_IMAGE_NAME }}:development \
|
||||||
|
-t ${{ env.REGISTRY_URL }}/${{ env.DOCKER_IMAGE_NAME }}:${{ github.sha }} \
|
||||||
|
--push .
|
62
.gitea/workflows/release.yaml
Normal file
62
.gitea/workflows/release.yaml
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
name: Release Build and Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOTNET_VERSION: '8.0.x'
|
||||||
|
DOCKER_IMAGE_NAME: 'watcher-server'
|
||||||
|
REGISTRY_URL: 'git.triggermeelmo.com/watcher'
|
||||||
|
DOCKER_PLATFORMS: 'linux/amd64,linux/arm64'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup .NET SDK
|
||||||
|
uses: actions/setup-dotnet@v3
|
||||||
|
with:
|
||||||
|
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
|
||||||
|
|
||||||
|
docker-build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build-and-test
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Login to Gitea Container Registry
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: git.triggermeelmo.com
|
||||||
|
username: ${{ secrets.AUTOMATION_USERNAME }}
|
||||||
|
password: ${{ secrets.AUTOMATION_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and Push Multi-Arch Docker Image
|
||||||
|
run: |
|
||||||
|
docker buildx build \
|
||||||
|
--platform ${{ env.DOCKER_PLATFORMS }} \
|
||||||
|
-t ${{ env.REGISTRY_URL }}/${{ env.DOCKER_IMAGE_NAME }}:v0.1.1 \
|
||||||
|
-t ${{ env.REGISTRY_URL }}/${{ env.DOCKER_IMAGE_NAME }}:${{ github.sha }} \
|
||||||
|
--push .
|
@@ -1,28 +0,0 @@
|
|||||||
import json
|
|
||||||
import urllib.request
|
|
||||||
|
|
||||||
url = "http://localhost:5000/monitoring/service-discovery"
|
|
||||||
payload = {
|
|
||||||
"ServerId": 1,
|
|
||||||
"ContainerId": "aaaaaaaaaaaa",
|
|
||||||
"Name": "test-Name",
|
|
||||||
"Image": "test-Image"
|
|
||||||
}
|
|
||||||
|
|
||||||
data = json.dumps(payload).encode("utf-8")
|
|
||||||
req = urllib.request.Request(
|
|
||||||
url,
|
|
||||||
data=data,
|
|
||||||
headers={"Content-Type": "application/json"},
|
|
||||||
method="POST"
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
|
||||||
with urllib.request.urlopen(req) as response:
|
|
||||||
resp_data = response.read().decode("utf-8")
|
|
||||||
print("Status Code:", response.status)
|
|
||||||
print("Response:", resp_data)
|
|
||||||
except Exception as e:
|
|
||||||
print("Fehler beim Senden der Request:", e)
|
|
||||||
|
|
||||||
|
|
@@ -4,8 +4,8 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
// Local Namespaces
|
// Local Namespaces
|
||||||
using Watcher.Data;
|
using Watcher.Data;
|
||||||
|
using Watcher.Models;
|
||||||
using Watcher.ViewModels;
|
using Watcher.ViewModels;
|
||||||
using Watcher.Services;
|
|
||||||
|
|
||||||
namespace Watcher.Controllers
|
namespace Watcher.Controllers
|
||||||
{
|
{
|
||||||
@@ -18,16 +18,11 @@ namespace Watcher.Controllers
|
|||||||
// Logging einbinden
|
// Logging einbinden
|
||||||
private readonly ILogger<HomeController> _logger;
|
private readonly ILogger<HomeController> _logger;
|
||||||
|
|
||||||
// Daten der Backgroundchecks abrufen
|
|
||||||
private IDashboardStore _DashboardStore;
|
|
||||||
|
|
||||||
// HomeController Constructor
|
// HomeController Constructor
|
||||||
public HomeController(AppDbContext context, ILogger<HomeController> logger, IDashboardStore dashboardStore)
|
public HomeController(AppDbContext context, ILogger<HomeController> logger)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_DashboardStore = dashboardStore;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dashboard unter /home/index
|
// Dashboard unter /home/index
|
||||||
@@ -57,11 +52,9 @@ namespace Watcher.Controllers
|
|||||||
.ToListAsync(),
|
.ToListAsync(),
|
||||||
Containers = await _context.Containers
|
Containers = await _context.Containers
|
||||||
.OrderBy(s => s.Name)
|
.OrderBy(s => s.Name)
|
||||||
.ToListAsync(),
|
.ToListAsync()
|
||||||
NetworkStatus = _DashboardStore.NetworkStatus,
|
|
||||||
DatabaseStatus = _DashboardStore.DatabaseStatus
|
|
||||||
};
|
};
|
||||||
//ViewBag.NetworkConnection = _NetworkCheckStore.NetworkStatus;
|
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,18 +82,11 @@ namespace Watcher.Controllers
|
|||||||
.ToListAsync(),
|
.ToListAsync(),
|
||||||
Containers = await _context.Containers
|
Containers = await _context.Containers
|
||||||
.OrderBy(s => s.Name)
|
.OrderBy(s => s.Name)
|
||||||
.ToListAsync(),
|
.ToListAsync()
|
||||||
NetworkStatus = _DashboardStore.NetworkStatus,
|
|
||||||
DatabaseStatus = _DashboardStore.DatabaseStatus
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return PartialView("_DashboardStats", model);
|
return PartialView("_DashboardStats", model);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String ReturnNetworkStatus()
|
|
||||||
{
|
|
||||||
return "OK";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
using Microsoft.Data.Sqlite;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using Watcher.Data;
|
using Watcher.Data;
|
||||||
@@ -12,7 +11,7 @@ using Watcher.ViewModels;
|
|||||||
|
|
||||||
namespace Watcher.Controllers;
|
namespace Watcher.Controllers;
|
||||||
|
|
||||||
public class HardwareDto
|
public class RegistrationDto
|
||||||
{
|
{
|
||||||
// Server Identity
|
// Server Identity
|
||||||
[Required]
|
[Required]
|
||||||
@@ -78,13 +77,6 @@ public class MetricDto
|
|||||||
public double NET_Out { get; set; } // Bytes/s
|
public double NET_Out { get; set; } // Bytes/s
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ServiceDto
|
|
||||||
{
|
|
||||||
public int ServerId { get; set; } // Vom Watcher-Server zugewiesene ID des Hosts
|
|
||||||
public String? ContainerId { get; set; }
|
|
||||||
public String? Image { get; set; }
|
|
||||||
public String? Name { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("[controller]")]
|
[Route("[controller]")]
|
||||||
@@ -101,9 +93,9 @@ public class MonitoringController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Endpoint, an den der Agent seine Hardwareinformationen schickt
|
// Endpoint, an dem sich neue Agents registrieren
|
||||||
[HttpPost("hardware-info")]
|
[HttpPost("register-agent-by-id")]
|
||||||
public async Task<IActionResult> Register([FromBody] HardwareDto dto)
|
public async Task<IActionResult> Register([FromBody] RegistrationDto dto)
|
||||||
{
|
{
|
||||||
// Gültigkeit des Payloads prüfen
|
// Gültigkeit des Payloads prüfen
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
@@ -136,12 +128,13 @@ public class MonitoringController : Controller
|
|||||||
_logger.LogInformation("Agent für '{server}' erfolgreich registriert.", server.Name);
|
_logger.LogInformation("Agent für '{server}' erfolgreich registriert.", server.Name);
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogError("Kein Server für Registrierung gefunden");
|
_logger.LogError("Kein Server für Registrierung gefunden");
|
||||||
return NotFound("No Matching Server found.");
|
return NotFound("No Matching Server found.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Endpoint, an dem sich ein Agent initial registriert
|
[HttpGet("server-id-by-ip")]
|
||||||
[HttpGet("register")]
|
|
||||||
public async Task<IActionResult> GetServerIdByIp([FromQuery] string IpAddress)
|
public async Task<IActionResult> GetServerIdByIp([FromQuery] string IpAddress)
|
||||||
{
|
{
|
||||||
var server = await _context.Servers
|
var server = await _context.Servers
|
||||||
@@ -222,50 +215,6 @@ public class MonitoringController : Controller
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Endpoint, an dem Agents Ihre laufenden Services registrieren
|
|
||||||
[HttpPost("service-discovery")]
|
|
||||||
public async Task<IActionResult> ServiceDetection([FromBody] ServiceDto dto)
|
|
||||||
{
|
|
||||||
// Gültigkeit des Payloads prüfen
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
{
|
|
||||||
var errors = ModelState.Values
|
|
||||||
.SelectMany(v => v.Errors)
|
|
||||||
.Select(e => e.ErrorMessage)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
_logger.LogError("Ungültiger ServiceDetection-Payload.");
|
|
||||||
return BadRequest(new { error = "Ungültiger Payload", details = errors });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Metrics für Container, die zu ServerId gehören, löschen
|
|
||||||
|
|
||||||
// Container, die zu ServerId gehören löschen
|
|
||||||
|
|
||||||
// Container neu in Datenbank einlesen
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Container container = new Container
|
|
||||||
{
|
|
||||||
ServerId = dto.ServerId,
|
|
||||||
ContainerId = dto.ContainerId,
|
|
||||||
Image = dto.Name,
|
|
||||||
Name = dto.Name
|
|
||||||
};
|
|
||||||
|
|
||||||
_logger.LogInformation(container.Name + " added for Host " + container.ServerId);
|
|
||||||
|
|
||||||
_context.Containers.Add(container);
|
|
||||||
await _context.SaveChangesAsync();
|
|
||||||
}
|
|
||||||
catch (SqliteException e)
|
|
||||||
{
|
|
||||||
_logger.LogError("ServiceDiscovery failed: " + e.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Durchschnittliche Werte Berechnen
|
// Durchschnittliche Werte Berechnen
|
||||||
[HttpGet("median")]
|
[HttpGet("median")]
|
||||||
@@ -368,4 +317,6 @@ public class MonitoringController : Controller
|
|||||||
return metric_input;
|
return metric_input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@@ -1,355 +0,0 @@
|
|||||||
// <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("20251003135555_ContainerUpdate")]
|
|
||||||
partial class ContainerUpdate
|
|
||||||
{
|
|
||||||
/// <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");
|
|
||||||
|
|
||||||
b.Property<string>("Image")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<int?>("ImageId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<bool>("IsRunning")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<int>("ServerId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<int?>("TagId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ImageId");
|
|
||||||
|
|
||||||
b.HasIndex("TagId");
|
|
||||||
|
|
||||||
b.ToTable("Containers");
|
|
||||||
});
|
|
||||||
|
|
||||||
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<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")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("CpuType")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<double>("DISK_Temp_Critical")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("DISK_Temp_Warning")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("DiskSpace")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<double>("Disk_Usage_Critical")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("Disk_Usage_Warning")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("GPU_Load_Critical")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("GPU_Load_Warning")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("GPU_Temp_Critical")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("GPU_Temp_Warning")
|
|
||||||
.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>("RAM_Load_Critical")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("RAM_Load_Warning")
|
|
||||||
.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<string>("IdentityProvider")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<DateTime>("LastLogin")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("OIDC_Id")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Password")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Username")
|
|
||||||
.IsRequired()
|
|
||||||
.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.Tag", null)
|
|
||||||
.WithMany("Containers")
|
|
||||||
.HasForeignKey("TagId");
|
|
||||||
});
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,113 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Watcher.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class ContainerUpdate : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_Containers_Servers_HostServerId",
|
|
||||||
table: "Containers");
|
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "IX_Containers_HostServerId",
|
|
||||||
table: "Containers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "CreatedAt",
|
|
||||||
table: "Containers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "ExposedPort",
|
|
||||||
table: "Containers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Health",
|
|
||||||
table: "Containers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "HostServerId",
|
|
||||||
table: "Containers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Status",
|
|
||||||
table: "Containers");
|
|
||||||
|
|
||||||
migrationBuilder.RenameColumn(
|
|
||||||
name: "InternalPort",
|
|
||||||
table: "Containers",
|
|
||||||
newName: "ServerId");
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "ContainerId",
|
|
||||||
table: "Containers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "ContainerId",
|
|
||||||
table: "Containers");
|
|
||||||
|
|
||||||
migrationBuilder.RenameColumn(
|
|
||||||
name: "ServerId",
|
|
||||||
table: "Containers",
|
|
||||||
newName: "InternalPort");
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<DateTime>(
|
|
||||||
name: "CreatedAt",
|
|
||||||
table: "Containers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "ExposedPort",
|
|
||||||
table: "Containers",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "Health",
|
|
||||||
table: "Containers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: "");
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "HostServerId",
|
|
||||||
table: "Containers",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "Status",
|
|
||||||
table: "Containers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: "");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Containers_HostServerId",
|
|
||||||
table: "Containers",
|
|
||||||
column: "HostServerId");
|
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
|
||||||
name: "FK_Containers_Servers_HostServerId",
|
|
||||||
table: "Containers",
|
|
||||||
column: "HostServerId",
|
|
||||||
principalTable: "Servers",
|
|
||||||
principalColumn: "Id");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -23,29 +23,45 @@ namespace Watcher.Migrations
|
|||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<string>("ContainerId")
|
b.Property<DateTime>("CreatedAt")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("ExposedPort")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Health")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int?>("HostServerId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<string>("Image")
|
b.Property<string>("Image")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<int?>("ImageId")
|
b.Property<int?>("ImageId")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("InternalPort")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<bool>("IsRunning")
|
b.Property<bool>("IsRunning")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<int>("ServerId")
|
b.Property<string>("Status")
|
||||||
.HasColumnType("INTEGER");
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<int?>("TagId")
|
b.Property<int?>("TagId")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("HostServerId");
|
||||||
|
|
||||||
b.HasIndex("ImageId");
|
b.HasIndex("ImageId");
|
||||||
|
|
||||||
b.HasIndex("TagId");
|
b.HasIndex("TagId");
|
||||||
@@ -304,6 +320,10 @@ namespace Watcher.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Container", b =>
|
modelBuilder.Entity("Watcher.Models.Container", b =>
|
||||||
{
|
{
|
||||||
|
b.HasOne("Watcher.Models.Server", "HostServer")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("HostServerId");
|
||||||
|
|
||||||
b.HasOne("Watcher.Models.Image", null)
|
b.HasOne("Watcher.Models.Image", null)
|
||||||
.WithMany("Containers")
|
.WithMany("Containers")
|
||||||
.HasForeignKey("ImageId");
|
.HasForeignKey("ImageId");
|
||||||
@@ -311,6 +331,8 @@ namespace Watcher.Migrations
|
|||||||
b.HasOne("Watcher.Models.Tag", null)
|
b.HasOne("Watcher.Models.Tag", null)
|
||||||
.WithMany("Containers")
|
.WithMany("Containers")
|
||||||
.HasForeignKey("TagId");
|
.HasForeignKey("TagId");
|
||||||
|
|
||||||
|
b.Navigation("HostServer");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
||||||
|
@@ -4,11 +4,22 @@ public class Container
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public int ServerId { get; set; }
|
// Container Details
|
||||||
|
public string? Name { get; set; }
|
||||||
|
|
||||||
public String? ContainerId { get; set; }
|
public int ExposedPort { get; set; }
|
||||||
public String? Image { get; set; }
|
|
||||||
public String? Name { get; set; }
|
public int InternalPort { get; set; }
|
||||||
|
|
||||||
|
public string Status { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Health { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string? Image { get; set; }
|
||||||
|
|
||||||
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
public Boolean IsRunning { get; set; } = true;
|
public Boolean IsRunning { get; set; } = true;
|
||||||
|
|
||||||
|
public Server? HostServer { get; set; }
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@ using Serilog;
|
|||||||
|
|
||||||
using Watcher.Data;
|
using Watcher.Data;
|
||||||
using Watcher.Models;
|
using Watcher.Models;
|
||||||
using Watcher.Services;
|
|
||||||
//using Watcher.Services;
|
//using Watcher.Services;
|
||||||
//using Watcher.Workers;
|
//using Watcher.Workers;
|
||||||
|
|
||||||
@@ -16,7 +15,7 @@ var builder = WebApplication.CreateBuilder(args);
|
|||||||
// Serilog konfigurieren – nur Logs, die nicht von Microsoft stammen
|
// Serilog konfigurieren – nur Logs, die nicht von Microsoft stammen
|
||||||
Log.Logger = new LoggerConfiguration()
|
Log.Logger = new LoggerConfiguration()
|
||||||
.MinimumLevel.Information()
|
.MinimumLevel.Information()
|
||||||
.MinimumLevel.Override("Microsoft", Serilog.Events.LogEventLevel.Warning)
|
.MinimumLevel.Override("Microsoft", Serilog.Events.LogEventLevel.Warning) // <--
|
||||||
.Enrich.FromLogContext()
|
.Enrich.FromLogContext()
|
||||||
.WriteTo.File(
|
.WriteTo.File(
|
||||||
"logs/watcher-.log",
|
"logs/watcher-.log",
|
||||||
@@ -34,13 +33,6 @@ builder.Services.AddControllersWithViews();
|
|||||||
// HttpContentAccessor
|
// HttpContentAccessor
|
||||||
builder.Services.AddHttpContextAccessor();
|
builder.Services.AddHttpContextAccessor();
|
||||||
|
|
||||||
// Storage Singleton
|
|
||||||
builder.Services.AddSingleton<IDashboardStore, DashboardStore>();
|
|
||||||
|
|
||||||
// Background Services
|
|
||||||
builder.Services.AddHostedService<NetworkCheck>();
|
|
||||||
builder.Services.AddHostedService<DatabaseCheck>();
|
|
||||||
|
|
||||||
|
|
||||||
// ---------- Konfiguration ----------
|
// ---------- Konfiguration ----------
|
||||||
DotNetEnv.Env.Load();
|
DotNetEnv.Env.Load();
|
||||||
@@ -222,4 +214,4 @@ app.MapControllerRoute(
|
|||||||
pattern: "{controller=Home}/{action=Index}/{id?}"
|
pattern: "{controller=Home}/{action=Index}/{id?}"
|
||||||
);
|
);
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
@@ -1,8 +0,0 @@
|
|||||||
namespace Watcher.Services;
|
|
||||||
|
|
||||||
public class DashboardStore : IDashboardStore
|
|
||||||
{
|
|
||||||
public String? NetworkStatus { get; set; }
|
|
||||||
|
|
||||||
public String? DatabaseStatus { get; set; }
|
|
||||||
}
|
|
@@ -1,67 +0,0 @@
|
|||||||
using Microsoft.Data.Sqlite;
|
|
||||||
|
|
||||||
namespace Watcher.Services;
|
|
||||||
|
|
||||||
public class DatabaseCheck : BackgroundService
|
|
||||||
{
|
|
||||||
private readonly ILogger<DatabaseCheck> _logger;
|
|
||||||
|
|
||||||
private IDashboardStore _dashboardStore;
|
|
||||||
|
|
||||||
public DatabaseCheck(ILogger<DatabaseCheck> logger, IDashboardStore dashboardStore)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_dashboardStore = dashboardStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
|
||||||
{
|
|
||||||
var timer = new PeriodicTimer(TimeSpan.FromSeconds(30));
|
|
||||||
|
|
||||||
while (await timer.WaitForNextTickAsync(stoppingToken))
|
|
||||||
{
|
|
||||||
// Hintergrundprozess abwarten
|
|
||||||
await checkDatabaseIntegrity();
|
|
||||||
// 5 Sekdunden Offset
|
|
||||||
await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// String sqliteConnectionString als Argument übergeben
|
|
||||||
public Task checkDatabaseIntegrity()
|
|
||||||
{
|
|
||||||
using var conn = new SqliteConnection("Data Source=./persistence/watcher.db");
|
|
||||||
_logger.LogInformation("Sqlite Integrity-Check started...");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
|
|
||||||
using var command = conn.CreateCommand();
|
|
||||||
command.CommandText = """
|
|
||||||
SELECT integrity_check FROM pragma_integrity_check;
|
|
||||||
""";
|
|
||||||
|
|
||||||
using var reader = command.ExecuteReader();
|
|
||||||
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
string status = reader.GetString(0);
|
|
||||||
_dashboardStore.DatabaseStatus = status;
|
|
||||||
_logger.LogInformation("Sqlite DatabaseIntegrity: ${status}", status);
|
|
||||||
}
|
|
||||||
|
|
||||||
conn.Close();
|
|
||||||
}
|
|
||||||
catch (SqliteException e)
|
|
||||||
{
|
|
||||||
conn.Close();
|
|
||||||
_logger.LogError(e.Message);
|
|
||||||
|
|
||||||
// TODO: LogEvent erstellen
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Database Integrity-Check finished.");
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,7 +0,0 @@
|
|||||||
namespace Watcher.Services;
|
|
||||||
|
|
||||||
public interface IDashboardStore
|
|
||||||
{
|
|
||||||
String? NetworkStatus { get; set; }
|
|
||||||
String? DatabaseStatus { get; set; }
|
|
||||||
}
|
|
@@ -1,59 +0,0 @@
|
|||||||
using System.Net.NetworkInformation;
|
|
||||||
|
|
||||||
namespace Watcher.Services;
|
|
||||||
public class NetworkCheck : BackgroundService
|
|
||||||
{
|
|
||||||
private readonly ILogger<NetworkCheck> _logger;
|
|
||||||
|
|
||||||
private IDashboardStore _DashboardStore;
|
|
||||||
|
|
||||||
public NetworkCheck(ILogger<NetworkCheck> logger, IDashboardStore DashboardStore)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_DashboardStore = DashboardStore;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
|
||||||
{
|
|
||||||
var timer = new PeriodicTimer(TimeSpan.FromSeconds(30));
|
|
||||||
|
|
||||||
while (await timer.WaitForNextTickAsync(stoppingToken))
|
|
||||||
{
|
|
||||||
// Hintergrundprozess abwarten
|
|
||||||
await checkConnectionAsync();
|
|
||||||
|
|
||||||
// 5 Sekdunden Offset
|
|
||||||
await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task checkConnectionAsync()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Networkcheck started.");
|
|
||||||
|
|
||||||
string host = "8.8.8.8";
|
|
||||||
Ping p = new Ping();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
PingReply reply = p.Send(host, 3000);
|
|
||||||
if (reply.Status == IPStatus.Success)
|
|
||||||
{
|
|
||||||
_DashboardStore.NetworkStatus = "online";
|
|
||||||
_logger.LogInformation("Ping successfull. Watcher is online.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
_DashboardStore.NetworkStatus = "offline";
|
|
||||||
_logger.LogError("Ping failed. Watcher appears to have no network connection.");
|
|
||||||
|
|
||||||
// LogEvent erstellen
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Networkcheck finished.");
|
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -14,8 +14,5 @@ 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? DatabaseStatus { get; set; } = "?";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,21 +10,26 @@
|
|||||||
|
|
||||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
|
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||||
<div >
|
<div >
|
||||||
|
<!-- TODO: Später auf > 0 ändern! -->
|
||||||
<table class="ServiceList">
|
<table class="ServiceList">
|
||||||
|
<!-- foreach (var container in Model.Containers)-->
|
||||||
<tr>
|
<tr>
|
||||||
<th>Service</th>
|
<th>Service</th>
|
||||||
<th>HostServer</th>
|
<th>HostServer</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
|
<th>SSL/TLS</th>
|
||||||
|
<th>Proxy</th>
|
||||||
<th>Deployment</th>
|
<th>Deployment</th>
|
||||||
<th></th>
|
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
@foreach (Container container in Model.Containers)
|
@for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
<tr class="ServiceRow">
|
<tr class="ServiceRow">
|
||||||
<td>@container.Name</td>
|
<td>test</td>
|
||||||
<td><a class="ServiceEntry" href="/Server/Details/${containerId}">@container.ServerId</a></td>
|
<td><a class="ServiceEntry" href="/Server/Details/7">test</a></td>
|
||||||
<td>nicht automatisiert</td>
|
<td>Online</td>
|
||||||
|
<td>true</td>
|
||||||
|
<td>true</td>
|
||||||
<td>Docker</td>
|
<td>Docker</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
@using Microsoft.IdentityModel.Tokens
|
|
||||||
@model Watcher.ViewModels.DashboardViewModel
|
@model Watcher.ViewModels.DashboardViewModel
|
||||||
|
|
||||||
@{
|
@{
|
||||||
@@ -58,54 +57,18 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="fw-bold mb-3"><i class="bi bi-heart-pulse me-2 text-danger"></i>Systemstatus</h5>
|
<h5 class="fw-bold mb-3"><i class="bi bi-heart-pulse me-2 text-danger"></i>Systemstatus</h5>
|
||||||
|
|
||||||
@if (!Model.NetworkStatus.IsNullOrEmpty())
|
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||||
{
|
<span>Netzwerk</span>
|
||||||
@if (Model.NetworkStatus == "online")
|
<span class="badge bg-success">OK</span>
|
||||||
{
|
</div>
|
||||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
<div class="progress mb-3" style="height: 6px;">
|
||||||
<span>Netzwerk</span>
|
<div class="progress-bar bg-success w-100"></div>
|
||||||
<span class="badge bg-success">@Model.NetworkStatus</span>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="progress mb-3" style="height: 6px;">
|
|
||||||
<div class="progress-bar bg-success w-100"></div>
|
|
||||||
</div>
|
|
||||||
} else if (Model.NetworkStatus == "offline")
|
|
||||||
{
|
|
||||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
|
||||||
<span>Netzwerk</span>
|
|
||||||
<span class="badge bg-danger">@Model.NetworkStatus</span>
|
|
||||||
</div>
|
|
||||||
<div class="progress mb-3" style="height: 6px;">
|
|
||||||
<div class="progress-bar bg-danger w-100"></div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@if (!Model.DatabaseStatus.IsNullOrEmpty())
|
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||||
{
|
<span>Datenbank</span>
|
||||||
@if (Model.DatabaseStatus == "ok")
|
<span class="badge bg-success">OK</span>
|
||||||
{
|
</div>
|
||||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
|
||||||
<span>Datenbank</span>
|
|
||||||
<span class="badge bg-success">healthy</span>
|
|
||||||
</div>
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
|
||||||
<span>Datenbank</span>
|
|
||||||
<span class="badge bg-danger">unhealthy</span>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
|
||||||
<span>Datenbank</span>
|
|
||||||
|
|
||||||
<span class="badge bg-primary">Missing Data</span>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
<div class="progress mb-3" style="height: 6px;">
|
<div class="progress mb-3" style="height: 6px;">
|
||||||
<div class="progress-bar bg-success w-100"></div>
|
<div class="progress-bar bg-success w-100"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -134,39 +97,36 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Services -->
|
<!-- Services -->
|
||||||
<!-- TODO
|
|
||||||
<div class="col-12 col-lg-6">
|
<div class="col-12 col-lg-6">
|
||||||
<div class="card shadow rounded-3 p-4 h-100">
|
<div class="card shadow rounded-3 p-4 h-100">
|
||||||
<h2 class="h5 fw-semibold mb-3">Services</h2>
|
<h2 class="h5 fw-semibold mb-3">Services</h2>
|
||||||
<ul class="list-group list-group-flush serverlist">
|
<ul class="list-group list-group-flush serverlist">
|
||||||
@foreach (var container in Model.Containers)
|
@foreach (var service in Model.Containers)
|
||||||
{
|
{
|
||||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||||
<span>@container.Name</span>
|
<span>@service.Name</span>
|
||||||
<span class="badge @(container.Name == "Running" ? "bg-success" : "bg-warning")">
|
<span class="badge @(service.Status == "Running" ? "bg-success" : "bg-warning")">
|
||||||
@container.Name
|
@service.Status
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- Server Liste -->
|
<!-- Server Liste -->
|
||||||
<!-- TODO
|
|
||||||
<div class="col-12 col-lg-6">
|
<div class="col-12 col-lg-6">
|
||||||
<div class="card shadow rounded-3 p-4 h-100">
|
<div class="card shadow rounded-3 p-4 h-100">
|
||||||
<h2 class="h5 fw-semibold mb-3">Server</h2>
|
<h2 class="h5 fw-semibold mb-3">Server</h2>
|
||||||
<ul class="list-group list-group-flush">
|
<ul class="list-group list-group-flush">
|
||||||
@foreach (Server server in Model.Servers)
|
@foreach (var server in Model.Servers)
|
||||||
{
|
{
|
||||||
<li class="list-group-item d-flex justify-content-between align-items-center serverlist">
|
<li class="list-group-item d-flex justify-content-between align-items-center serverlist">
|
||||||
<span>@server.Name</span>
|
<span>@server.Name</span>
|
||||||
<span class="badge bg-info" )">
|
<span class="badge bg-info")">
|
||||||
CPU:
|
CPU: 30.45%
|
||||||
</span>
|
</span>
|
||||||
<span class="badge bg-info" )">
|
<span class="badge bg-info")">
|
||||||
RAM: 65.09%
|
RAM: 65.09%
|
||||||
</span>
|
</span>
|
||||||
<span class="badge @(server.IsOnline ? "bg-success" : "bg-danger")">
|
<span class="badge @(server.IsOnline ? "bg-success" : "bg-danger")">
|
||||||
@@ -176,7 +136,6 @@
|
|||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
-->
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
BIN
Watcher/persistence/watcher.db-shm
Normal file
BIN
Watcher/persistence/watcher.db-shm
Normal file
Binary file not shown.
0
Watcher/persistence/watcher.db-wal
Normal file
0
Watcher/persistence/watcher.db-wal
Normal file
Reference in New Issue
Block a user