Compare commits
25 Commits
0e9555e3f7
...
v0.1.14
| Author | SHA1 | Date | |
|---|---|---|---|
| 6f2a864db3 | |||
| cfb97536ca | |||
| 8e8bfaee45 | |||
| 42a40e8b2e | |||
| b8b0520eaa | |||
| df1c4ca4b4 | |||
| 33acb5ea3a | |||
| a6d992c874 | |||
| 8475083897 | |||
| f1287314f4 | |||
| e1684d4484 | |||
| f113147972 | |||
| 6354075a5c | |||
| 7c85e338fa | |||
| c01401eb07 | |||
| 7c06f7ee06 | |||
| 6eed3c764e | |||
| f207440ae6 | |||
| ef187f8750 | |||
| 570b5abfa0 | |||
| 8f938f999e | |||
| 2249d1a776 | |||
| 37de21f06b | |||
| b9d5ade0f1 | |||
| 921b4a9664 |
@@ -8,7 +8,7 @@ on:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
DOTNET_VERSION: '8.0.x'
|
DOTNET_VERSION: '8.0.x'
|
||||||
DOCKER_IMAGE_NAME: watcher
|
DOCKER_IMAGE_NAME: watcher-server
|
||||||
REGISTRY_URL: git.triggermeelmo.com
|
REGISTRY_URL: git.triggermeelmo.com
|
||||||
DOCKER_PLATFORMS: 'linux/amd64,linux/arm64'
|
DOCKER_PLATFORMS: 'linux/amd64,linux/arm64'
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ concurrency:
|
|||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-test:
|
dotnet-build-and-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -43,7 +43,7 @@ jobs:
|
|||||||
|
|
||||||
set-tag:
|
set-tag:
|
||||||
name: Set Tag Name
|
name: Set Tag Name
|
||||||
needs: [build-and-test]
|
needs: [dotnet-build-and-test]
|
||||||
#if: ${{ !failure() && !cancelled() && github.event_name != 'pull_request' }}
|
#if: ${{ !failure() && !cancelled() && github.event_name != 'pull_request' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
@@ -95,7 +95,7 @@ jobs:
|
|||||||
|
|
||||||
docker-build-and-push:
|
docker-build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build-and-test, set-tag]
|
needs: [dotnet-build-and-test, set-tag]
|
||||||
if: |
|
if: |
|
||||||
needs.set-tag.outputs.should_tag == 'true' &&
|
needs.set-tag.outputs.should_tag == 'true' &&
|
||||||
github.event_name != 'pull_request'
|
github.event_name != 'pull_request'
|
||||||
@@ -117,12 +117,16 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--platform ${{ env.DOCKER_PLATFORMS }} \
|
--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 }} \
|
-t ${{ env.REGISTRY_URL }}/watcher/${{ env.DOCKER_IMAGE_NAME }}:${{ needs.set-tag.outputs.tag_name }} \
|
||||||
--push .
|
--push .
|
||||||
|
|
||||||
tag:
|
tag:
|
||||||
name: Create Tag
|
name: Create Tag
|
||||||
needs: [docker-build-and-push, set-tag]
|
needs: [docker-build-and-push, set-tag]
|
||||||
|
if: |
|
||||||
|
needs.set-tag.outputs.should_tag == 'true' &&
|
||||||
|
github.event_name != 'pull_request'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ RUN dotnet publish -c Release -o /app/publish /p:UseAppHost=false
|
|||||||
|
|
||||||
# 2. Laufzeit-Phase: ASP.NET Core Runtime
|
# 2. Laufzeit-Phase: ASP.NET Core Runtime
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0
|
||||||
|
|
||||||
|
# Build-Argument für Version (wird zur Build-Zeit vom CI/CD gesetzt)
|
||||||
|
ARG VERSION=latest
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=build /app/publish .
|
COPY --from=build /app/publish .
|
||||||
|
|
||||||
@@ -28,5 +32,8 @@ EXPOSE 5000
|
|||||||
ENV ASPNETCORE_URLS=http://*:5000
|
ENV ASPNETCORE_URLS=http://*:5000
|
||||||
ENV ASPNETCORE_ENVIRONMENT=Development
|
ENV ASPNETCORE_ENVIRONMENT=Development
|
||||||
|
|
||||||
|
# Version als Environment Variable setzen
|
||||||
|
ENV WATCHER_VERSION=${VERSION}
|
||||||
|
|
||||||
# Anwendung starten
|
# Anwendung starten
|
||||||
ENTRYPOINT ["dotnet", "Watcher.dll"]
|
ENTRYPOINT ["dotnet", "Watcher.dll"]
|
||||||
|
|||||||
@@ -3,10 +3,39 @@ import urllib.request
|
|||||||
|
|
||||||
url = "http://localhost:5000/monitoring/service-discovery"
|
url = "http://localhost:5000/monitoring/service-discovery"
|
||||||
payload = {
|
payload = {
|
||||||
"ServerId": 1,
|
"Server_id": 2,
|
||||||
"ContainerId": "aaaaaaaaaaaa",
|
"Containers": [
|
||||||
"Name": "test-Name",
|
{
|
||||||
"Image": "test-Image"
|
"id": "3e74abf5ce30",
|
||||||
|
"image": "hello-world:latest",
|
||||||
|
"name": "serene_nightingale"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "83cd9d461690",
|
||||||
|
"image": "postgres:latest",
|
||||||
|
"name": "distracted_feistel"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "b296c2ed1213",
|
||||||
|
"image": "postgres:latest",
|
||||||
|
"name": "mystifying_jackson"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "69568181d576",
|
||||||
|
"image": "hello-world:latest",
|
||||||
|
"name": "romantic_driscoll"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "67c37a2b1791",
|
||||||
|
"image": "hello-world:latest",
|
||||||
|
"name": "asdf"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "8f39bae1e316",
|
||||||
|
"image": "hello-world:latest",
|
||||||
|
"name": "distracted_mirzakhani"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
data = json.dumps(payload).encode("utf-8")
|
data = json.dumps(payload).encode("utf-8")
|
||||||
|
|||||||
@@ -1,8 +1,19 @@
|
|||||||
|
# Application Version
|
||||||
|
# Bei lokalem Development wird "development" angezeigt, im Docker-Container die Image-Version
|
||||||
|
WATCHER_VERSION=development
|
||||||
|
|
||||||
# OIDC Einstellungen
|
# Update Check
|
||||||
AUTHENTICATION__USELOCAL=true
|
# Überprüft täglich, ob eine neue Version verfügbar ist
|
||||||
AUTHENTICATION__POCKETID__ENABLED=false
|
UPDATE_CHECK_ENABLED=true
|
||||||
AUTHENTICATION__POCKETID__AUTHORITY=https://id.domain.app
|
UPDATE_CHECK_INTERVAL_HOURS=24
|
||||||
AUTHENTICATION__POCKETID__CLIENTID=
|
UPDATE_CHECK_REPOSITORY_URL=https://git.triggermeelmo.com/api/v1/repos/Watcher/watcher/releases/latest
|
||||||
AUTHENTICATION__POCKETID__CLIENTSECRET=
|
|
||||||
AUTHENTICATION__POCKETID__CALLBACKPATH=/signin-oidc
|
# Data Retention Policy
|
||||||
|
# Wie lange sollen Metriken gespeichert werden (in Tagen)?
|
||||||
|
METRIC_RETENTION_DAYS=30
|
||||||
|
|
||||||
|
# Wie oft soll der Cleanup-Prozess laufen (in Stunden)?
|
||||||
|
METRIC_CLEANUP_INTERVAL_HOURS=24
|
||||||
|
|
||||||
|
# Soll der Cleanup-Service aktiviert sein?
|
||||||
|
METRIC_CLEANUP_ENABLED=true
|
||||||
|
|||||||
@@ -1,35 +1,20 @@
|
|||||||
using System.Net.Mail;
|
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Authentication;
|
using Microsoft.AspNetCore.Authentication;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Watcher.Data;
|
using Watcher.Data;
|
||||||
using Watcher.ViewModels;
|
using Watcher.ViewModels;
|
||||||
|
|
||||||
namespace Watcher.Controllers;
|
namespace Watcher.Controllers;
|
||||||
|
|
||||||
public class AppSettings
|
|
||||||
{
|
|
||||||
public Boolean oidc { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class AuthController : Controller
|
public class AuthController : Controller
|
||||||
{
|
{
|
||||||
private readonly AppDbContext _context;
|
private readonly AppDbContext _context;
|
||||||
private readonly AppSettings _settings;
|
|
||||||
|
|
||||||
// Logging einbinden
|
|
||||||
private readonly ILogger<AuthController> _logger;
|
private readonly ILogger<AuthController> _logger;
|
||||||
|
|
||||||
|
public AuthController(AppDbContext context, ILogger<AuthController> logger)
|
||||||
public AuthController(AppDbContext context, IOptions<AppSettings> options, ILogger<AuthController> logger)
|
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
_settings = options.Value;
|
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +28,6 @@ public class AuthController : Controller
|
|||||||
ReturnUrl = returnUrl
|
ReturnUrl = returnUrl
|
||||||
};
|
};
|
||||||
|
|
||||||
ViewBag.oidc = _settings.oidc;
|
|
||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,32 +72,15 @@ public class AuthController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Login mit OIDC-Provider
|
|
||||||
public IActionResult SignIn()
|
|
||||||
{
|
|
||||||
return Challenge(new AuthenticationProperties
|
|
||||||
{
|
|
||||||
RedirectUri = "/Home/Index"
|
|
||||||
}, "oidc");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Logout
|
// Logout
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ValidateAntiForgeryToken]
|
[ValidateAntiForgeryToken]
|
||||||
public async Task<IActionResult> Logout()
|
public async Task<IActionResult> Logout()
|
||||||
{
|
{
|
||||||
var props = new AuthenticationProperties
|
|
||||||
{
|
|
||||||
RedirectUri = Url.Action("Login", "Auth")
|
|
||||||
};
|
|
||||||
|
|
||||||
await HttpContext.SignOutAsync("Cookies");
|
await HttpContext.SignOutAsync("Cookies");
|
||||||
await HttpContext.SignOutAsync("oidc", props);
|
|
||||||
|
|
||||||
_logger.LogInformation("User abgemeldet");
|
_logger.LogInformation("User abgemeldet");
|
||||||
|
|
||||||
return Redirect("/"); // nur als Fallback
|
return RedirectToAction("Login", "Auth");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,17 +18,23 @@ public class ContainerController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> Overview()
|
public async Task<IActionResult> Overview()
|
||||||
{
|
{
|
||||||
var containers = await _context.Containers.ToListAsync();
|
// Container mit Server-Informationen laden und nach Server sortieren
|
||||||
|
var containers = await _context.Containers
|
||||||
|
.Include(c => c.Server)
|
||||||
|
.OrderBy(c => c.Server.Name)
|
||||||
|
.ThenBy(c => c.Name)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
var servers = await _context.Servers.ToListAsync();
|
var servers = await _context.Servers.ToListAsync();
|
||||||
|
|
||||||
var viewModel = new ContainerOverviewViewModel
|
var viewModel = new ContainerOverviewViewModel
|
||||||
{
|
{
|
||||||
Servers = servers,
|
Servers = servers,
|
||||||
Containers = containers
|
Containers = containers
|
||||||
};
|
};
|
||||||
|
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
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.CodeAnalysis.CSharp.Syntax;
|
||||||
using Microsoft.Data.Sqlite;
|
using Microsoft.Data.Sqlite;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
|
||||||
using Watcher.Data;
|
using Watcher.Data;
|
||||||
using Watcher.Models;
|
using Watcher.Models;
|
||||||
using Watcher.ViewModels;
|
using Watcher.ViewModels;
|
||||||
@@ -78,12 +81,15 @@ public class MetricDto
|
|||||||
public double NET_Out { get; set; } // Bytes/s
|
public double NET_Out { get; set; } // Bytes/s
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ServiceDto
|
public class DockerServiceDto
|
||||||
{
|
{
|
||||||
public int ServerId { get; set; } // Vom Watcher-Server zugewiesene ID des Hosts
|
public required int Server_id { get; set; } // Vom Watcher-Server zugewiesene ID des Hosts
|
||||||
public String? ContainerId { get; set; }
|
public required JsonElement Containers { get; set; }
|
||||||
public String? Image { get; set; }
|
}
|
||||||
public String? Name { get; set; }
|
|
||||||
|
public class DockerServiceMetricDto
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
@@ -224,7 +230,7 @@ public class MonitoringController : Controller
|
|||||||
|
|
||||||
// Endpoint, an dem Agents Ihre laufenden Services registrieren
|
// Endpoint, an dem Agents Ihre laufenden Services registrieren
|
||||||
[HttpPost("service-discovery")]
|
[HttpPost("service-discovery")]
|
||||||
public async Task<IActionResult> ServiceDetection([FromBody] ServiceDto dto)
|
public async Task<IActionResult> ServiceDetection([FromBody] DockerServiceDto dto)
|
||||||
{
|
{
|
||||||
// Gültigkeit des Payloads prüfen
|
// Gültigkeit des Payloads prüfen
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
@@ -234,33 +240,113 @@ public class MonitoringController : Controller
|
|||||||
.Select(e => e.ErrorMessage)
|
.Select(e => e.ErrorMessage)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
_logger.LogError("Ungültiger ServiceDetection-Payload.");
|
_logger.LogError("Invalid ServiceDetection-Payload.");
|
||||||
return BadRequest(new { error = "Ungültiger Payload", details = errors });
|
return BadRequest(new { error = "Invalid Payload", details = errors });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Metrics für Container, die zu ServerId gehören, löschen
|
List<Container> newContainers =
|
||||||
|
JsonSerializer.Deserialize<List<Container>>(dto.Containers.GetRawText())
|
||||||
|
?? new List<Container>();
|
||||||
|
|
||||||
// Container, die zu ServerId gehören löschen
|
foreach (Container c in newContainers)
|
||||||
|
{
|
||||||
|
c.ServerId = dto.Server_id;
|
||||||
|
// Debug Logs
|
||||||
|
// TODO entfernen wenn fertig getestet
|
||||||
|
Console.WriteLine("---------");
|
||||||
|
Console.WriteLine("ServerId: " + c.ServerId);
|
||||||
|
Console.WriteLine("ContainerId: " + c.ContainerId);
|
||||||
|
Console.WriteLine("Name: " + c.Name);
|
||||||
|
Console.WriteLine("Image: " + c.Image);
|
||||||
|
Console.WriteLine("---------");
|
||||||
|
|
||||||
// Container neu in Datenbank einlesen
|
}
|
||||||
|
|
||||||
|
// Liste aller Container, die bereits der übergebenen ServerId zugewiesen sind
|
||||||
|
List<Container> existingContainers = _context.Containers
|
||||||
|
.Where(c => c.ServerId == dto.Server_id)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
|
||||||
|
// Logik, um Container, die mit dem Payload kamen zu verarbeiten
|
||||||
|
foreach (Container c in newContainers)
|
||||||
|
{
|
||||||
|
// Überprüfen, ob ein übergebener Container bereits für den Host registriert ist
|
||||||
|
if (existingContainers.Contains(c))
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Container with id " + c.ContainerId + " already exists.");
|
||||||
|
}
|
||||||
|
// Container auf einen Host/Server registrieren
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Container in Datenbank einlesen
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_context.Containers.Add(c);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
_logger.LogInformation(c.Name + " added for Host " + c.ServerId);
|
||||||
|
}
|
||||||
|
catch (SqliteException e)
|
||||||
|
{
|
||||||
|
_logger.LogError("Error writing new Containers to Database: " + e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logik um abgeschaltene Container aus der Datenbank zu entfernen
|
||||||
|
foreach (Container c in existingContainers)
|
||||||
|
{
|
||||||
|
// Abfrage, ob bereits vorhandener Container im Payload vorhanden war
|
||||||
|
if (!newContainers.Contains(c))
|
||||||
|
{
|
||||||
|
// Container entfernen
|
||||||
|
_context.Containers.Remove(c);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
// Metrics für den Container entfernen
|
||||||
|
//Todo
|
||||||
|
|
||||||
|
_logger.LogInformation("Container " + c.Name + " (" + c.Id + ") on Host-Id " + c.ServerId + " was successfully removed from the database.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Endpoint, an den der Agent die Metrics der registrierten Container schickt
|
||||||
|
public async Task<IActionResult> ServiceMetrics([FromBody] DockerServiceMetricDto 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("Invalid ServiceDetection-Payload.");
|
||||||
|
return BadRequest(new { error = "Invalid Payload", details = errors });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Liste an Metrics aus der dto erstellen
|
||||||
|
List<ContainerMetric> metrics = new List<ContainerMetric>();
|
||||||
|
|
||||||
|
// Metrics in die Datenbank eintragen
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Container container = new Container
|
foreach (ContainerMetric m in metrics)
|
||||||
{
|
{
|
||||||
ServerId = dto.ServerId,
|
_context.ContainerMetrics.Add(m);
|
||||||
ContainerId = dto.ContainerId,
|
await _context.SaveChangesAsync();
|
||||||
Image = dto.Name,
|
// _logger.LogInformation(m. + " added for Host " + c.ServerId);
|
||||||
Name = dto.Name
|
return Ok();
|
||||||
};
|
}
|
||||||
|
|
||||||
_logger.LogInformation(container.Name + " added for Host " + container.ServerId);
|
|
||||||
|
|
||||||
_context.Containers.Add(container);
|
|
||||||
await _context.SaveChangesAsync();
|
|
||||||
}
|
}
|
||||||
catch (SqliteException e)
|
catch (SqliteException e)
|
||||||
{
|
{
|
||||||
_logger.LogError("ServiceDiscovery failed: " + e.Message);
|
_logger.LogError(e.Message);
|
||||||
|
return StatusCode(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
@@ -268,7 +354,6 @@ public class MonitoringController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Durchschnittliche Werte Berechnen
|
// Durchschnittliche Werte Berechnen
|
||||||
[HttpGet("median")]
|
|
||||||
public async Task<IActionResult> CalculateMedian(string Metric, int HoursToMonitor, int ServerId)
|
public async Task<IActionResult> CalculateMedian(string Metric, int HoursToMonitor, int ServerId)
|
||||||
{
|
{
|
||||||
// Aktuelle Zeit - X Stunden = letzter Wert, der berücksichtigt werden soll
|
// Aktuelle Zeit - X Stunden = letzter Wert, der berücksichtigt werden soll
|
||||||
@@ -368,4 +453,13 @@ public class MonitoringController : Controller
|
|||||||
return metric_input;
|
return metric_input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Container> ParseServiceDiscoveryInput(int server_id, List<Container> containers)
|
||||||
|
{
|
||||||
|
List<Container> containerList = new List<Container>();
|
||||||
|
|
||||||
|
// JSON-Objekt auslesen und Container-Objekte erstellen
|
||||||
|
|
||||||
|
|
||||||
|
return containerList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Watcher.Data;
|
using Watcher.Data;
|
||||||
|
using Watcher.Services;
|
||||||
using Watcher.ViewModels;
|
using Watcher.ViewModels;
|
||||||
|
|
||||||
namespace Watcher.Controllers;
|
namespace Watcher.Controllers;
|
||||||
@@ -11,11 +12,13 @@ public class SystemController : Controller
|
|||||||
{
|
{
|
||||||
private readonly AppDbContext _context;
|
private readonly AppDbContext _context;
|
||||||
private readonly ILogger<SystemController> _logger;
|
private readonly ILogger<SystemController> _logger;
|
||||||
|
private readonly IVersionService _versionService;
|
||||||
|
|
||||||
public SystemController(AppDbContext context, ILogger<SystemController> logger)
|
public SystemController(AppDbContext context, ILogger<SystemController> logger, IVersionService versionService)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
_versionService = versionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit-Form anzeigen
|
// Edit-Form anzeigen
|
||||||
@@ -23,10 +26,32 @@ public class SystemController : Controller
|
|||||||
//public async Task<IActionResult> Settings()
|
//public async Task<IActionResult> Settings()
|
||||||
public IActionResult Settings()
|
public IActionResult Settings()
|
||||||
{
|
{
|
||||||
ViewBag.DbProvider = "Microsoft.EntityFrameworkCore.Sqlite";
|
ViewBag.DbProvider = "SQLite";
|
||||||
ViewBag.mail = "test@mail.com";
|
ViewBag.mail = "test@mail.com";
|
||||||
ViewBag.IdentityProvider = "Local";
|
ViewBag.IdentityProvider = "Local";
|
||||||
ViewBag.ServerVersion = "v0.1.0";
|
ViewBag.ServerVersion = _versionService.GetVersion();
|
||||||
|
|
||||||
|
// Datenbankgröße ermitteln
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var dbPath = "./persistence/watcher.db";
|
||||||
|
if (System.IO.File.Exists(dbPath))
|
||||||
|
{
|
||||||
|
var fileInfo = new System.IO.FileInfo(dbPath);
|
||||||
|
var sizeInMiB = fileInfo.Length / (1024.0 * 1024.0);
|
||||||
|
ViewBag.DatabaseSize = $"{sizeInMiB:F2} MiB";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ViewBag.DatabaseSize = "Nicht gefunden";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Fehler beim Ermitteln der Datenbankgröße.");
|
||||||
|
ViewBag.DatabaseSize = "Fehler beim Laden";
|
||||||
|
}
|
||||||
|
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,14 +33,12 @@ public class UserController : Controller
|
|||||||
var username = user.Username;
|
var username = user.Username;
|
||||||
var mail = user.Email;
|
var mail = user.Email;
|
||||||
var Id = user.Id;
|
var Id = user.Id;
|
||||||
var IdProvider = user.IdentityProvider;
|
|
||||||
|
|
||||||
// Anzeigedaten an View übergeben
|
// Anzeigedaten an View übergeben
|
||||||
ViewBag.Claims = claims;
|
ViewBag.Claims = claims;
|
||||||
ViewBag.Name = username;
|
ViewBag.Name = username;
|
||||||
ViewBag.Mail = mail;
|
ViewBag.Mail = mail;
|
||||||
ViewBag.Id = Id;
|
ViewBag.Id = Id;
|
||||||
ViewBag.IdProvider = IdProvider;
|
|
||||||
|
|
||||||
|
|
||||||
return View();
|
return View();
|
||||||
|
|||||||
@@ -26,30 +26,19 @@ public class AppDbContext : DbContext
|
|||||||
|
|
||||||
public DbSet<Tag> Tags { get; set; }
|
public DbSet<Tag> Tags { get; set; }
|
||||||
|
|
||||||
|
public DbSet<ContainerMetric> ContainerMetrics { get; set; }
|
||||||
|
|
||||||
public DbSet<User> Users { get; set; }
|
public DbSet<User> Users { get; set; }
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
{
|
{
|
||||||
if (!optionsBuilder.IsConfigured)
|
if (!optionsBuilder.IsConfigured)
|
||||||
{
|
{
|
||||||
var provider = _configuration["Database:Provider"];
|
// Nur SQLite wird unterstützt
|
||||||
|
var connStr = _configuration.GetConnectionString("Sqlite")
|
||||||
if (provider == "MySql")
|
?? _configuration["Database:ConnectionStrings:Sqlite"]
|
||||||
{
|
?? "Data Source=./persistence/watcher.db";
|
||||||
var connStr = _configuration.GetConnectionString("MySql")
|
optionsBuilder.UseSqlite(connStr);
|
||||||
?? _configuration["Database:ConnectionStrings:MySql"];
|
|
||||||
optionsBuilder.UseMySql(connStr, ServerVersion.AutoDetect(connStr));
|
|
||||||
}
|
|
||||||
else if (provider == "Sqlite")
|
|
||||||
{
|
|
||||||
var connStr = _configuration.GetConnectionString("Sqlite")
|
|
||||||
?? _configuration["Database:ConnectionStrings:Sqlite"];
|
|
||||||
optionsBuilder.UseSqlite(connStr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception("Unsupported database provider configured.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,300 +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("20250617153602_InitialMigration")]
|
|
||||||
partial class InitialMigration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "8.0.6")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Container", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.HasColumnType("datetime(6)");
|
|
||||||
|
|
||||||
b.Property<string>("Hostname")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<int?>("ImageId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<bool>("IsRunning")
|
|
||||||
.HasColumnType("tinyint(1)");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<string>("Status")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<int?>("TagId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("Type")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ImageId");
|
|
||||||
|
|
||||||
b.HasIndex("TagId");
|
|
||||||
|
|
||||||
b.ToTable("Containers");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Image", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<string>("Tag")
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Images");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int?>("ContainerId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("Level")
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<string>("Message")
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<int?>("ServerId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<DateTime>("Timestamp")
|
|
||||||
.HasColumnType("datetime(6)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ContainerId");
|
|
||||||
|
|
||||||
b.HasIndex("ServerId");
|
|
||||||
|
|
||||||
b.ToTable("LogEvents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Metric", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int?>("ContainerId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int?>("ServerId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<DateTime>("Timestamp")
|
|
||||||
.HasColumnType("datetime(6)");
|
|
||||||
|
|
||||||
b.Property<string>("Type")
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<double>("Value")
|
|
||||||
.HasColumnType("double");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ContainerId");
|
|
||||||
|
|
||||||
b.HasIndex("ServerId");
|
|
||||||
|
|
||||||
b.ToTable("Metrics");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Server", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("CpuCores")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("CpuType")
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.HasColumnType("datetime(6)");
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<string>("GpuType")
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<string>("IPAddress")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<bool>("IsOnline")
|
|
||||||
.HasColumnType("tinyint(1)");
|
|
||||||
|
|
||||||
b.Property<DateTime>("LastSeen")
|
|
||||||
.HasColumnType("datetime(6)");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<double>("RamSize")
|
|
||||||
.HasColumnType("double");
|
|
||||||
|
|
||||||
b.Property<int?>("TagId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("Type")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("TagId");
|
|
||||||
|
|
||||||
b.ToTable("Servers");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Tag", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Tags");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.User", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("Email")
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<DateTime>("LastLogin")
|
|
||||||
.HasColumnType("datetime(6)");
|
|
||||||
|
|
||||||
b.Property<string>("PocketId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<string>("PreferredUsername")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Users");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Container", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Watcher.Models.Image", "Image")
|
|
||||||
.WithMany("Containers")
|
|
||||||
.HasForeignKey("ImageId");
|
|
||||||
|
|
||||||
b.HasOne("Watcher.Models.Tag", null)
|
|
||||||
.WithMany("Containers")
|
|
||||||
.HasForeignKey("TagId");
|
|
||||||
|
|
||||||
b.Navigation("Image");
|
|
||||||
});
|
|
||||||
|
|
||||||
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.Metric", 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,261 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Watcher.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class InitialMigration : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AlterDatabase()
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Images",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
||||||
Name = table.Column<string>(type: "longtext", nullable: true)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
Tag = table.Column<string>(type: "longtext", nullable: true)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4")
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Images", x => x.Id);
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Tags",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
||||||
Name = table.Column<string>(type: "longtext", nullable: true)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4")
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Tags", x => x.Id);
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Users",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
||||||
PocketId = table.Column<string>(type: "longtext", nullable: false)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
PreferredUsername = table.Column<string>(type: "longtext", nullable: false)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
Email = table.Column<string>(type: "longtext", nullable: true)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
LastLogin = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Users", x => x.Id);
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Containers",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
||||||
Name = table.Column<string>(type: "longtext", nullable: false)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
Status = table.Column<string>(type: "longtext", nullable: false)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
ImageId = table.Column<int>(type: "int", nullable: true),
|
|
||||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
||||||
Hostname = table.Column<string>(type: "longtext", nullable: false)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
Type = table.Column<string>(type: "longtext", nullable: false)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
IsRunning = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
||||||
TagId = table.Column<int>(type: "int", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Containers", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Containers_Images_ImageId",
|
|
||||||
column: x => x.ImageId,
|
|
||||||
principalTable: "Images",
|
|
||||||
principalColumn: "Id");
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Containers_Tags_TagId",
|
|
||||||
column: x => x.TagId,
|
|
||||||
principalTable: "Tags",
|
|
||||||
principalColumn: "Id");
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Servers",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
||||||
Name = table.Column<string>(type: "longtext", nullable: false)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
IPAddress = table.Column<string>(type: "longtext", nullable: false)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
||||||
Type = table.Column<string>(type: "longtext", nullable: false)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
IsOnline = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
||||||
LastSeen = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
||||||
Description = table.Column<string>(type: "longtext", nullable: true)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
CpuType = table.Column<string>(type: "longtext", nullable: true)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
CpuCores = table.Column<int>(type: "int", nullable: false),
|
|
||||||
GpuType = table.Column<string>(type: "longtext", nullable: true)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
RamSize = table.Column<double>(type: "double", nullable: false),
|
|
||||||
TagId = table.Column<int>(type: "int", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Servers", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Servers_Tags_TagId",
|
|
||||||
column: x => x.TagId,
|
|
||||||
principalTable: "Tags",
|
|
||||||
principalColumn: "Id");
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "LogEvents",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
||||||
Timestamp = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
||||||
Message = table.Column<string>(type: "longtext", nullable: true)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
Level = table.Column<string>(type: "longtext", nullable: true)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
ServerId = table.Column<int>(type: "int", nullable: true),
|
|
||||||
ContainerId = table.Column<int>(type: "int", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_LogEvents", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_LogEvents_Containers_ContainerId",
|
|
||||||
column: x => x.ContainerId,
|
|
||||||
principalTable: "Containers",
|
|
||||||
principalColumn: "Id");
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_LogEvents_Servers_ServerId",
|
|
||||||
column: x => x.ServerId,
|
|
||||||
principalTable: "Servers",
|
|
||||||
principalColumn: "Id");
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Metrics",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
||||||
Timestamp = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
||||||
Type = table.Column<string>(type: "longtext", nullable: true)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
Value = table.Column<double>(type: "double", nullable: false),
|
|
||||||
ServerId = table.Column<int>(type: "int", nullable: true),
|
|
||||||
ContainerId = table.Column<int>(type: "int", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Metrics", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Metrics_Containers_ContainerId",
|
|
||||||
column: x => x.ContainerId,
|
|
||||||
principalTable: "Containers",
|
|
||||||
principalColumn: "Id");
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Metrics_Servers_ServerId",
|
|
||||||
column: x => x.ServerId,
|
|
||||||
principalTable: "Servers",
|
|
||||||
principalColumn: "Id");
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Containers_ImageId",
|
|
||||||
table: "Containers",
|
|
||||||
column: "ImageId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Containers_TagId",
|
|
||||||
table: "Containers",
|
|
||||||
column: "TagId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_LogEvents_ContainerId",
|
|
||||||
table: "LogEvents",
|
|
||||||
column: "ContainerId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_LogEvents_ServerId",
|
|
||||||
table: "LogEvents",
|
|
||||||
column: "ServerId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Metrics_ContainerId",
|
|
||||||
table: "Metrics",
|
|
||||||
column: "ContainerId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Metrics_ServerId",
|
|
||||||
table: "Metrics",
|
|
||||||
column: "ServerId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Servers_TagId",
|
|
||||||
table: "Servers",
|
|
||||||
column: "TagId");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "LogEvents");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Metrics");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Users");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Containers");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Servers");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Images");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Tags");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,298 +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("20250617165126_ServerPrimaryKey")]
|
|
||||||
partial class ServerPrimaryKey
|
|
||||||
{
|
|
||||||
/// <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<DateTime>("CreatedAt")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Hostname")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<int?>("ImageId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<bool>("IsRunning")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Status")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<int?>("TagId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("Type")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
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<int?>("ContainerId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<int?>("ServerId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<DateTime>("Timestamp")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Type")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<double>("Value")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ContainerId");
|
|
||||||
|
|
||||||
b.HasIndex("ServerId");
|
|
||||||
|
|
||||||
b.ToTable("Metrics");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.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>("Description")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("GpuType")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("IPAddress")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<bool>("IsOnline")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<DateTime>("LastSeen")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<double>("RamSize")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<int?>("TagId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("Type")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("TagId");
|
|
||||||
|
|
||||||
b.ToTable("Servers");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Tag", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Tags");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.User", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("Email")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<DateTime>("LastLogin")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("PocketId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("PreferredUsername")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Users");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Container", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Watcher.Models.Image", "Image")
|
|
||||||
.WithMany("Containers")
|
|
||||||
.HasForeignKey("ImageId");
|
|
||||||
|
|
||||||
b.HasOne("Watcher.Models.Tag", null)
|
|
||||||
.WithMany("Containers")
|
|
||||||
.HasForeignKey("TagId");
|
|
||||||
|
|
||||||
b.Navigation("Image");
|
|
||||||
});
|
|
||||||
|
|
||||||
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.Metric", 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,785 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Watcher.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class ServerPrimaryKey : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "PreferredUsername",
|
|
||||||
table: "Users",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "PocketId",
|
|
||||||
table: "Users",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<DateTime>(
|
|
||||||
name: "LastLogin",
|
|
||||||
table: "Users",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(DateTime),
|
|
||||||
oldType: "datetime(6)");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Email",
|
|
||||||
table: "Users",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "Id",
|
|
||||||
table: "Users",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int")
|
|
||||||
.Annotation("Sqlite:Autoincrement", true)
|
|
||||||
.OldAnnotation("Sqlite:Autoincrement", true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Name",
|
|
||||||
table: "Tags",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "Id",
|
|
||||||
table: "Tags",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int")
|
|
||||||
.Annotation("Sqlite:Autoincrement", true)
|
|
||||||
.OldAnnotation("Sqlite:Autoincrement", true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Type",
|
|
||||||
table: "Servers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "TagId",
|
|
||||||
table: "Servers",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<double>(
|
|
||||||
name: "RamSize",
|
|
||||||
table: "Servers",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(double),
|
|
||||||
oldType: "double");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Name",
|
|
||||||
table: "Servers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<DateTime>(
|
|
||||||
name: "LastSeen",
|
|
||||||
table: "Servers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(DateTime),
|
|
||||||
oldType: "datetime(6)");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<bool>(
|
|
||||||
name: "IsOnline",
|
|
||||||
table: "Servers",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(bool),
|
|
||||||
oldType: "tinyint(1)");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "IPAddress",
|
|
||||||
table: "Servers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "GpuType",
|
|
||||||
table: "Servers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Description",
|
|
||||||
table: "Servers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<DateTime>(
|
|
||||||
name: "CreatedAt",
|
|
||||||
table: "Servers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(DateTime),
|
|
||||||
oldType: "datetime(6)");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "CpuType",
|
|
||||||
table: "Servers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "CpuCores",
|
|
||||||
table: "Servers",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "Id",
|
|
||||||
table: "Servers",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int")
|
|
||||||
.Annotation("Sqlite:Autoincrement", true)
|
|
||||||
.OldAnnotation("Sqlite:Autoincrement", true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<double>(
|
|
||||||
name: "Value",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(double),
|
|
||||||
oldType: "double");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Type",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<DateTime>(
|
|
||||||
name: "Timestamp",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(DateTime),
|
|
||||||
oldType: "datetime(6)");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "ServerId",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "ContainerId",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "Id",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int")
|
|
||||||
.Annotation("Sqlite:Autoincrement", true)
|
|
||||||
.OldAnnotation("Sqlite:Autoincrement", true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<DateTime>(
|
|
||||||
name: "Timestamp",
|
|
||||||
table: "LogEvents",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(DateTime),
|
|
||||||
oldType: "datetime(6)");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "ServerId",
|
|
||||||
table: "LogEvents",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Message",
|
|
||||||
table: "LogEvents",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Level",
|
|
||||||
table: "LogEvents",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "ContainerId",
|
|
||||||
table: "LogEvents",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "Id",
|
|
||||||
table: "LogEvents",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int")
|
|
||||||
.Annotation("Sqlite:Autoincrement", true)
|
|
||||||
.OldAnnotation("Sqlite:Autoincrement", true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Tag",
|
|
||||||
table: "Images",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Name",
|
|
||||||
table: "Images",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "Id",
|
|
||||||
table: "Images",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int")
|
|
||||||
.Annotation("Sqlite:Autoincrement", true)
|
|
||||||
.OldAnnotation("Sqlite:Autoincrement", true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Type",
|
|
||||||
table: "Containers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "TagId",
|
|
||||||
table: "Containers",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Status",
|
|
||||||
table: "Containers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Name",
|
|
||||||
table: "Containers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<bool>(
|
|
||||||
name: "IsRunning",
|
|
||||||
table: "Containers",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(bool),
|
|
||||||
oldType: "tinyint(1)");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "ImageId",
|
|
||||||
table: "Containers",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Hostname",
|
|
||||||
table: "Containers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<DateTime>(
|
|
||||||
name: "CreatedAt",
|
|
||||||
table: "Containers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(DateTime),
|
|
||||||
oldType: "datetime(6)");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "Id",
|
|
||||||
table: "Containers",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int")
|
|
||||||
.Annotation("Sqlite:Autoincrement", true)
|
|
||||||
.OldAnnotation("Sqlite:Autoincrement", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "PreferredUsername",
|
|
||||||
table: "Users",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "PocketId",
|
|
||||||
table: "Users",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<DateTime>(
|
|
||||||
name: "LastLogin",
|
|
||||||
table: "Users",
|
|
||||||
type: "datetime(6)",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(DateTime),
|
|
||||||
oldType: "TEXT");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Email",
|
|
||||||
table: "Users",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "Id",
|
|
||||||
table: "Users",
|
|
||||||
type: "int",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "INTEGER")
|
|
||||||
.Annotation("Sqlite:Autoincrement", true)
|
|
||||||
.OldAnnotation("Sqlite:Autoincrement", true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Name",
|
|
||||||
table: "Tags",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "Id",
|
|
||||||
table: "Tags",
|
|
||||||
type: "int",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "INTEGER")
|
|
||||||
.Annotation("Sqlite:Autoincrement", true)
|
|
||||||
.OldAnnotation("Sqlite:Autoincrement", true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Type",
|
|
||||||
table: "Servers",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "TagId",
|
|
||||||
table: "Servers",
|
|
||||||
type: "int",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "INTEGER",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<double>(
|
|
||||||
name: "RamSize",
|
|
||||||
table: "Servers",
|
|
||||||
type: "double",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(double),
|
|
||||||
oldType: "REAL");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Name",
|
|
||||||
table: "Servers",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<DateTime>(
|
|
||||||
name: "LastSeen",
|
|
||||||
table: "Servers",
|
|
||||||
type: "datetime(6)",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(DateTime),
|
|
||||||
oldType: "TEXT");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<bool>(
|
|
||||||
name: "IsOnline",
|
|
||||||
table: "Servers",
|
|
||||||
type: "tinyint(1)",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(bool),
|
|
||||||
oldType: "INTEGER");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "IPAddress",
|
|
||||||
table: "Servers",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "GpuType",
|
|
||||||
table: "Servers",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Description",
|
|
||||||
table: "Servers",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<DateTime>(
|
|
||||||
name: "CreatedAt",
|
|
||||||
table: "Servers",
|
|
||||||
type: "datetime(6)",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(DateTime),
|
|
||||||
oldType: "TEXT");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "CpuType",
|
|
||||||
table: "Servers",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "CpuCores",
|
|
||||||
table: "Servers",
|
|
||||||
type: "int",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "INTEGER");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "Id",
|
|
||||||
table: "Servers",
|
|
||||||
type: "int",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "INTEGER")
|
|
||||||
.Annotation("Sqlite:Autoincrement", true)
|
|
||||||
.OldAnnotation("Sqlite:Autoincrement", true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<double>(
|
|
||||||
name: "Value",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "double",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(double),
|
|
||||||
oldType: "REAL");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Type",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<DateTime>(
|
|
||||||
name: "Timestamp",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "datetime(6)",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(DateTime),
|
|
||||||
oldType: "TEXT");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "ServerId",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "int",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "INTEGER",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "ContainerId",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "int",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "INTEGER",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "Id",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "int",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "INTEGER")
|
|
||||||
.Annotation("Sqlite:Autoincrement", true)
|
|
||||||
.OldAnnotation("Sqlite:Autoincrement", true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<DateTime>(
|
|
||||||
name: "Timestamp",
|
|
||||||
table: "LogEvents",
|
|
||||||
type: "datetime(6)",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(DateTime),
|
|
||||||
oldType: "TEXT");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "ServerId",
|
|
||||||
table: "LogEvents",
|
|
||||||
type: "int",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "INTEGER",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Message",
|
|
||||||
table: "LogEvents",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Level",
|
|
||||||
table: "LogEvents",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "ContainerId",
|
|
||||||
table: "LogEvents",
|
|
||||||
type: "int",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "INTEGER",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "Id",
|
|
||||||
table: "LogEvents",
|
|
||||||
type: "int",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "INTEGER")
|
|
||||||
.Annotation("Sqlite:Autoincrement", true)
|
|
||||||
.OldAnnotation("Sqlite:Autoincrement", true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Tag",
|
|
||||||
table: "Images",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Name",
|
|
||||||
table: "Images",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "Id",
|
|
||||||
table: "Images",
|
|
||||||
type: "int",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "INTEGER")
|
|
||||||
.Annotation("Sqlite:Autoincrement", true)
|
|
||||||
.OldAnnotation("Sqlite:Autoincrement", true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Type",
|
|
||||||
table: "Containers",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "TagId",
|
|
||||||
table: "Containers",
|
|
||||||
type: "int",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "INTEGER",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Status",
|
|
||||||
table: "Containers",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Name",
|
|
||||||
table: "Containers",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<bool>(
|
|
||||||
name: "IsRunning",
|
|
||||||
table: "Containers",
|
|
||||||
type: "tinyint(1)",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(bool),
|
|
||||||
oldType: "INTEGER");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "ImageId",
|
|
||||||
table: "Containers",
|
|
||||||
type: "int",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "INTEGER",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Hostname",
|
|
||||||
table: "Containers",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<DateTime>(
|
|
||||||
name: "CreatedAt",
|
|
||||||
table: "Containers",
|
|
||||||
type: "datetime(6)",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(DateTime),
|
|
||||||
oldType: "TEXT");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "Id",
|
|
||||||
table: "Containers",
|
|
||||||
type: "int",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "INTEGER")
|
|
||||||
.Annotation("Sqlite:Autoincrement", true)
|
|
||||||
.OldAnnotation("Sqlite:Autoincrement", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,306 +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("20250617174242_UserPasswordAdded")]
|
|
||||||
partial class UserPasswordAdded
|
|
||||||
{
|
|
||||||
/// <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<DateTime>("CreatedAt")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Hostname")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<int?>("ImageId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<bool>("IsRunning")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Status")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<int?>("TagId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("Type")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
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<int?>("ContainerId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<int?>("ServerId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<DateTime>("Timestamp")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Type")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<double>("Value")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ContainerId");
|
|
||||||
|
|
||||||
b.HasIndex("ServerId");
|
|
||||||
|
|
||||||
b.ToTable("Metrics");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.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>("Description")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("GpuType")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("IPAddress")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<bool>("IsOnline")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<DateTime>("LastSeen")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
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>("Password")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("PocketId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("PreferredUsername")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Users");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Container", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Watcher.Models.Image", "Image")
|
|
||||||
.WithMany("Containers")
|
|
||||||
.HasForeignKey("ImageId");
|
|
||||||
|
|
||||||
b.HasOne("Watcher.Models.Tag", null)
|
|
||||||
.WithMany("Containers")
|
|
||||||
.HasForeignKey("TagId");
|
|
||||||
|
|
||||||
b.Navigation("Image");
|
|
||||||
});
|
|
||||||
|
|
||||||
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.Metric", 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,40 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Watcher.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class UserPasswordAdded : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "IdentityProvider",
|
|
||||||
table: "Users",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: "");
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "Password",
|
|
||||||
table: "Users",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: "");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "IdentityProvider",
|
|
||||||
table: "Users");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Password",
|
|
||||||
table: "Users");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,316 +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("20250621124832_DB-Update Issue#32")]
|
|
||||||
partial class DBUpdateIssue32
|
|
||||||
{
|
|
||||||
/// <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<DateTime>("CreatedAt")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Hostname")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<int?>("ImageId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<bool>("IsRunning")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Status")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<int?>("TagId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("Type")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
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<int>("CpuCores")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("CpuType")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("GpuType")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("IPAddress")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<bool>("IsOnline")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<DateTime>("LastSeen")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
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", "Image")
|
|
||||||
.WithMany("Containers")
|
|
||||||
.HasForeignKey("ImageId");
|
|
||||||
|
|
||||||
b.HasOne("Watcher.Models.Tag", null)
|
|
||||||
.WithMany("Containers")
|
|
||||||
.HasForeignKey("TagId");
|
|
||||||
|
|
||||||
b.Navigation("Image");
|
|
||||||
});
|
|
||||||
|
|
||||||
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,251 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Watcher.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class DBUpdateIssue32 : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_Metrics_Containers_ContainerId",
|
|
||||||
table: "Metrics");
|
|
||||||
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_Metrics_Servers_ServerId",
|
|
||||||
table: "Metrics");
|
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "IX_Metrics_ContainerId",
|
|
||||||
table: "Metrics");
|
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "IX_Metrics_ServerId",
|
|
||||||
table: "Metrics");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "PocketId",
|
|
||||||
table: "Users");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "ContainerId",
|
|
||||||
table: "Metrics");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Type",
|
|
||||||
table: "Metrics");
|
|
||||||
|
|
||||||
migrationBuilder.RenameColumn(
|
|
||||||
name: "PreferredUsername",
|
|
||||||
table: "Users",
|
|
||||||
newName: "Username");
|
|
||||||
|
|
||||||
migrationBuilder.RenameColumn(
|
|
||||||
name: "Value",
|
|
||||||
table: "Metrics",
|
|
||||||
newName: "RAM_Size");
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "OIDC_Id",
|
|
||||||
table: "Users",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "CPU_Load",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "CPU_Temp",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "DISK_Size",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "DISK_Temp",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "DISK_Usage",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "GPU_Load",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "GPU_Temp",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "GPU_Vram_Size",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "GPU_Vram_Usage",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "NET_In",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "NET_Out",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "RAM_Load",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "OIDC_Id",
|
|
||||||
table: "Users");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "CPU_Load",
|
|
||||||
table: "Metrics");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "CPU_Temp",
|
|
||||||
table: "Metrics");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "DISK_Size",
|
|
||||||
table: "Metrics");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "DISK_Temp",
|
|
||||||
table: "Metrics");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "DISK_Usage",
|
|
||||||
table: "Metrics");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "GPU_Load",
|
|
||||||
table: "Metrics");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "GPU_Temp",
|
|
||||||
table: "Metrics");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "GPU_Vram_Size",
|
|
||||||
table: "Metrics");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "GPU_Vram_Usage",
|
|
||||||
table: "Metrics");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "NET_In",
|
|
||||||
table: "Metrics");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "NET_Out",
|
|
||||||
table: "Metrics");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "RAM_Load",
|
|
||||||
table: "Metrics");
|
|
||||||
|
|
||||||
migrationBuilder.RenameColumn(
|
|
||||||
name: "Username",
|
|
||||||
table: "Users",
|
|
||||||
newName: "PreferredUsername");
|
|
||||||
|
|
||||||
migrationBuilder.RenameColumn(
|
|
||||||
name: "RAM_Size",
|
|
||||||
table: "Metrics",
|
|
||||||
newName: "Value");
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "PocketId",
|
|
||||||
table: "Users",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: "");
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "ContainerId",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "Type",
|
|
||||||
table: "Metrics",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Metrics_ContainerId",
|
|
||||||
table: "Metrics",
|
|
||||||
column: "ContainerId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Metrics_ServerId",
|
|
||||||
table: "Metrics",
|
|
||||||
column: "ServerId");
|
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
|
||||||
name: "FK_Metrics_Containers_ContainerId",
|
|
||||||
table: "Metrics",
|
|
||||||
column: "ContainerId",
|
|
||||||
principalTable: "Containers",
|
|
||||||
principalColumn: "Id");
|
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
|
||||||
name: "FK_Metrics_Servers_ServerId",
|
|
||||||
table: "Metrics",
|
|
||||||
column: "ServerId",
|
|
||||||
principalTable: "Servers",
|
|
||||||
principalColumn: "Id");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,319 +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("20250621125157_DB-Update Issue#32 IsVerified-Servers")]
|
|
||||||
partial class DBUpdateIssue32IsVerifiedServers
|
|
||||||
{
|
|
||||||
/// <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<DateTime>("CreatedAt")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Hostname")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<int?>("ImageId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<bool>("IsRunning")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Status")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<int?>("TagId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("Type")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
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<int>("CpuCores")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("CpuType")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.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.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", "Image")
|
|
||||||
.WithMany("Containers")
|
|
||||||
.HasForeignKey("ImageId");
|
|
||||||
|
|
||||||
b.HasOne("Watcher.Models.Tag", null)
|
|
||||||
.WithMany("Containers")
|
|
||||||
.HasForeignKey("TagId");
|
|
||||||
|
|
||||||
b.Navigation("Image");
|
|
||||||
});
|
|
||||||
|
|
||||||
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,29 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Watcher.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class DBUpdateIssue32IsVerifiedServers : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<bool>(
|
|
||||||
name: "IsVerified",
|
|
||||||
table: "Servers",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "IsVerified",
|
|
||||||
table: "Servers");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,332 +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("20250710090920_container-attribute")]
|
|
||||||
partial class containerattribute
|
|
||||||
{
|
|
||||||
/// <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<DateTime>("CreatedAt")
|
|
||||||
.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")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<int?>("ImageId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<int>("InternalPort")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<bool>("IsRunning")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Status")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<int?>("TagId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("HostServerId");
|
|
||||||
|
|
||||||
b.HasIndex("ImageId");
|
|
||||||
|
|
||||||
b.HasIndex("TagId");
|
|
||||||
|
|
||||||
b.ToTable("Containers");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Image", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Tag")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Images");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<int?>("ContainerId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("Level")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Message")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<int?>("ServerId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<DateTime>("Timestamp")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ContainerId");
|
|
||||||
|
|
||||||
b.HasIndex("ServerId");
|
|
||||||
|
|
||||||
b.ToTable("LogEvents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Metric", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<double>("CPU_Load")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("CPU_Temp")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("DISK_Size")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("DISK_Temp")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("DISK_Usage")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("GPU_Load")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("GPU_Temp")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("GPU_Vram_Size")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("GPU_Vram_Usage")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("NET_In")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("NET_Out")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("RAM_Load")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("RAM_Size")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<int?>("ServerId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<DateTime>("Timestamp")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Metrics");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Server", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<int>("CpuCores")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("CpuType")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.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.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.Server", "HostServer")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("HostServerId");
|
|
||||||
|
|
||||||
b.HasOne("Watcher.Models.Image", null)
|
|
||||||
.WithMany("Containers")
|
|
||||||
.HasForeignKey("ImageId");
|
|
||||||
|
|
||||||
b.HasOne("Watcher.Models.Tag", null)
|
|
||||||
.WithMany("Containers")
|
|
||||||
.HasForeignKey("TagId");
|
|
||||||
|
|
||||||
b.Navigation("HostServer");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Watcher.Models.Container", "Container")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("ContainerId");
|
|
||||||
|
|
||||||
b.HasOne("Watcher.Models.Server", "Server")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("ServerId");
|
|
||||||
|
|
||||||
b.Navigation("Container");
|
|
||||||
|
|
||||||
b.Navigation("Server");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Server", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Watcher.Models.Tag", null)
|
|
||||||
.WithMany("Servers")
|
|
||||||
.HasForeignKey("TagId");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Image", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Containers");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Tag", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Containers");
|
|
||||||
|
|
||||||
b.Navigation("Servers");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Watcher.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class containerattribute : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Hostname",
|
|
||||||
table: "Containers");
|
|
||||||
|
|
||||||
migrationBuilder.RenameColumn(
|
|
||||||
name: "Type",
|
|
||||||
table: "Containers",
|
|
||||||
newName: "Health");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Name",
|
|
||||||
table: "Containers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT");
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "ExposedPort",
|
|
||||||
table: "Containers",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "HostServerId",
|
|
||||||
table: "Containers",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "Image",
|
|
||||||
table: "Containers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "InternalPort",
|
|
||||||
table: "Containers",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_Containers_Servers_HostServerId",
|
|
||||||
table: "Containers");
|
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "IX_Containers_HostServerId",
|
|
||||||
table: "Containers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "ExposedPort",
|
|
||||||
table: "Containers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "HostServerId",
|
|
||||||
table: "Containers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Image",
|
|
||||||
table: "Containers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "InternalPort",
|
|
||||||
table: "Containers");
|
|
||||||
|
|
||||||
migrationBuilder.RenameColumn(
|
|
||||||
name: "Health",
|
|
||||||
table: "Containers",
|
|
||||||
newName: "Type");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Name",
|
|
||||||
table: "Containers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: "",
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "TEXT",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "Hostname",
|
|
||||||
table: "Containers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,335 +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("20250730113936_DiskSpace-ServerAttribute")]
|
|
||||||
partial class DiskSpaceServerAttribute
|
|
||||||
{
|
|
||||||
/// <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<DateTime>("CreatedAt")
|
|
||||||
.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")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<int?>("ImageId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<int>("InternalPort")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<bool>("IsRunning")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Status")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<int?>("TagId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("HostServerId");
|
|
||||||
|
|
||||||
b.HasIndex("ImageId");
|
|
||||||
|
|
||||||
b.HasIndex("TagId");
|
|
||||||
|
|
||||||
b.ToTable("Containers");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Image", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Tag")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Images");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<int?>("ContainerId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("Level")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Message")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<int?>("ServerId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<DateTime>("Timestamp")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ContainerId");
|
|
||||||
|
|
||||||
b.HasIndex("ServerId");
|
|
||||||
|
|
||||||
b.ToTable("LogEvents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Metric", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<double>("CPU_Load")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("CPU_Temp")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("DISK_Size")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("DISK_Temp")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("DISK_Usage")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("GPU_Load")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("GPU_Temp")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("GPU_Vram_Size")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("GPU_Vram_Usage")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("NET_In")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("NET_Out")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("RAM_Load")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("RAM_Size")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<int?>("ServerId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<DateTime>("Timestamp")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Metrics");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Server", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<int>("CpuCores")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("CpuType")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.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.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.Server", "HostServer")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("HostServerId");
|
|
||||||
|
|
||||||
b.HasOne("Watcher.Models.Image", null)
|
|
||||||
.WithMany("Containers")
|
|
||||||
.HasForeignKey("ImageId");
|
|
||||||
|
|
||||||
b.HasOne("Watcher.Models.Tag", null)
|
|
||||||
.WithMany("Containers")
|
|
||||||
.HasForeignKey("TagId");
|
|
||||||
|
|
||||||
b.Navigation("HostServer");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Watcher.Models.Container", "Container")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("ContainerId");
|
|
||||||
|
|
||||||
b.HasOne("Watcher.Models.Server", "Server")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("ServerId");
|
|
||||||
|
|
||||||
b.Navigation("Container");
|
|
||||||
|
|
||||||
b.Navigation("Server");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Server", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Watcher.Models.Tag", null)
|
|
||||||
.WithMany("Servers")
|
|
||||||
.HasForeignKey("TagId");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Image", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Containers");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Tag", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Containers");
|
|
||||||
|
|
||||||
b.Navigation("Servers");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Watcher.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class DiskSpaceServerAttribute : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "DiskSpace",
|
|
||||||
table: "Servers",
|
|
||||||
type: "TEXT",
|
|
||||||
nullable: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "DiskSpace",
|
|
||||||
table: "Servers");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,172 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Watcher.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class MeasurementWarnings : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "CPU_Load_Critical",
|
|
||||||
table: "Servers",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "CPU_Load_Warning",
|
|
||||||
table: "Servers",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "CPU_Temp_Critical",
|
|
||||||
table: "Servers",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "CPU_Temp_Warning",
|
|
||||||
table: "Servers",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "DISK_Temp_Critical",
|
|
||||||
table: "Servers",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "DISK_Temp_Warning",
|
|
||||||
table: "Servers",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "Disk_Usage_Critical",
|
|
||||||
table: "Servers",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "Disk_Usage_Warning",
|
|
||||||
table: "Servers",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "GPU_Load_Critical",
|
|
||||||
table: "Servers",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "GPU_Load_Warning",
|
|
||||||
table: "Servers",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "GPU_Temp_Critical",
|
|
||||||
table: "Servers",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "GPU_Temp_Warning",
|
|
||||||
table: "Servers",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "RAM_Load_Critical",
|
|
||||||
table: "Servers",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<double>(
|
|
||||||
name: "RAM_Load_Warning",
|
|
||||||
table: "Servers",
|
|
||||||
type: "REAL",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "CPU_Load_Critical",
|
|
||||||
table: "Servers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "CPU_Load_Warning",
|
|
||||||
table: "Servers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "CPU_Temp_Critical",
|
|
||||||
table: "Servers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "CPU_Temp_Warning",
|
|
||||||
table: "Servers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "DISK_Temp_Critical",
|
|
||||||
table: "Servers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "DISK_Temp_Warning",
|
|
||||||
table: "Servers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Disk_Usage_Critical",
|
|
||||||
table: "Servers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Disk_Usage_Warning",
|
|
||||||
table: "Servers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "GPU_Load_Critical",
|
|
||||||
table: "Servers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "GPU_Load_Warning",
|
|
||||||
table: "Servers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "GPU_Temp_Critical",
|
|
||||||
table: "Servers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "GPU_Temp_Warning",
|
|
||||||
table: "Servers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "RAM_Load_Critical",
|
|
||||||
table: "Servers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "RAM_Load_Warning",
|
|
||||||
table: "Servers");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,8 +11,8 @@ using Watcher.Data;
|
|||||||
namespace Watcher.Migrations
|
namespace Watcher.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(AppDbContext))]
|
[DbContext(typeof(AppDbContext))]
|
||||||
[Migration("20251003135555_ContainerUpdate")]
|
[Migration("20251105183329_InitialMigration")]
|
||||||
partial class ContainerUpdate
|
partial class InitialMigration
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@@ -27,10 +27,12 @@ namespace Watcher.Migrations
|
|||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<string>("ContainerId")
|
b.Property<string>("ContainerId")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT")
|
||||||
|
.HasAnnotation("Relational:JsonPropertyName", "id");
|
||||||
|
|
||||||
b.Property<string>("Image")
|
b.Property<string>("Image")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT")
|
||||||
|
.HasAnnotation("Relational:JsonPropertyName", "image");
|
||||||
|
|
||||||
b.Property<int?>("ImageId")
|
b.Property<int?>("ImageId")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
@@ -39,10 +41,12 @@ namespace Watcher.Migrations
|
|||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT")
|
||||||
|
.HasAnnotation("Relational:JsonPropertyName", "name");
|
||||||
|
|
||||||
b.Property<int>("ServerId")
|
b.Property<int>("ServerId")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER")
|
||||||
|
.HasAnnotation("Relational:JsonPropertyName", "Server_id");
|
||||||
|
|
||||||
b.Property<int?>("TagId")
|
b.Property<int?>("TagId")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
@@ -56,6 +60,35 @@ namespace Watcher.Migrations
|
|||||||
b.ToTable("Containers");
|
b.ToTable("Containers");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Watcher.Models.ContainerMetric", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<double>("CPU_Load")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("CPU_Temp")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<int?>("ContainerId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<double>("RAM_Load")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("RAM_Size")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Timestamp")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("ContainerMetrics");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Image", b =>
|
modelBuilder.Entity("Watcher.Models.Image", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@@ -282,22 +315,16 @@ namespace Watcher.Migrations
|
|||||||
b.Property<string>("Email")
|
b.Property<string>("Email")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("IdentityProvider")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<DateTime>("LastLogin")
|
b.Property<DateTime>("LastLogin")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("OIDC_Id")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Password")
|
b.Property<string>("Password")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("Username")
|
b.Property<string>("Username")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
257
Watcher/Migrations/20251105183329_InitialMigration.cs
Normal file
257
Watcher/Migrations/20251105183329_InitialMigration.cs
Normal file
@@ -0,0 +1,257 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Watcher.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class InitialMigration : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "ContainerMetrics",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
Timestamp = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||||
|
ContainerId = table.Column<int>(type: "INTEGER", nullable: true),
|
||||||
|
CPU_Load = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
CPU_Temp = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
RAM_Size = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
RAM_Load = table.Column<double>(type: "REAL", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_ContainerMetrics", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Images",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
Name = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
Tag = table.Column<string>(type: "TEXT", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Images", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Metrics",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
Timestamp = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||||
|
ServerId = table.Column<int>(type: "INTEGER", nullable: true),
|
||||||
|
CPU_Load = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
CPU_Temp = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
GPU_Load = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
GPU_Temp = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
GPU_Vram_Size = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
GPU_Vram_Usage = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
RAM_Size = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
RAM_Load = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
DISK_Size = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
DISK_Usage = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
DISK_Temp = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
NET_In = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
NET_Out = table.Column<double>(type: "REAL", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Metrics", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Tags",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
Name = table.Column<string>(type: "TEXT", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Tags", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Users",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
Username = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
|
||||||
|
Email = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
LastLogin = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||||
|
Password = table.Column<string>(type: "TEXT", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Users", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Containers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
ServerId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
ContainerId = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
Image = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
Name = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
IsRunning = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||||
|
ImageId = table.Column<int>(type: "INTEGER", nullable: true),
|
||||||
|
TagId = table.Column<int>(type: "INTEGER", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Containers", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Containers_Images_ImageId",
|
||||||
|
column: x => x.ImageId,
|
||||||
|
principalTable: "Images",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Containers_Tags_TagId",
|
||||||
|
column: x => x.TagId,
|
||||||
|
principalTable: "Tags",
|
||||||
|
principalColumn: "Id");
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Servers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
Name = table.Column<string>(type: "TEXT", nullable: false),
|
||||||
|
IPAddress = table.Column<string>(type: "TEXT", nullable: false),
|
||||||
|
Type = table.Column<string>(type: "TEXT", nullable: false),
|
||||||
|
Description = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
CpuType = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
CpuCores = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
GpuType = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
RamSize = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
DiskSpace = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
CPU_Load_Warning = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
CPU_Load_Critical = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
CPU_Temp_Warning = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
CPU_Temp_Critical = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
RAM_Load_Warning = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
RAM_Load_Critical = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
GPU_Load_Warning = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
GPU_Load_Critical = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
GPU_Temp_Warning = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
GPU_Temp_Critical = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
Disk_Usage_Warning = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
Disk_Usage_Critical = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
DISK_Temp_Warning = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
DISK_Temp_Critical = table.Column<double>(type: "REAL", nullable: false),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||||
|
IsOnline = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||||
|
LastSeen = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||||
|
IsVerified = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||||
|
TagId = table.Column<int>(type: "INTEGER", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Servers", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Servers_Tags_TagId",
|
||||||
|
column: x => x.TagId,
|
||||||
|
principalTable: "Tags",
|
||||||
|
principalColumn: "Id");
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "LogEvents",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
Timestamp = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||||
|
Message = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
Level = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
ServerId = table.Column<int>(type: "INTEGER", nullable: true),
|
||||||
|
ContainerId = table.Column<int>(type: "INTEGER", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_LogEvents", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_LogEvents_Containers_ContainerId",
|
||||||
|
column: x => x.ContainerId,
|
||||||
|
principalTable: "Containers",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_LogEvents_Servers_ServerId",
|
||||||
|
column: x => x.ServerId,
|
||||||
|
principalTable: "Servers",
|
||||||
|
principalColumn: "Id");
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Containers_ImageId",
|
||||||
|
table: "Containers",
|
||||||
|
column: "ImageId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Containers_TagId",
|
||||||
|
table: "Containers",
|
||||||
|
column: "TagId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_LogEvents_ContainerId",
|
||||||
|
table: "LogEvents",
|
||||||
|
column: "ContainerId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_LogEvents_ServerId",
|
||||||
|
table: "LogEvents",
|
||||||
|
column: "ServerId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Servers_TagId",
|
||||||
|
table: "Servers",
|
||||||
|
column: "TagId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "ContainerMetrics");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "LogEvents");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Metrics");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Users");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Containers");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Servers");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Images");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Tags");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,8 +11,8 @@ using Watcher.Data;
|
|||||||
namespace Watcher.Migrations
|
namespace Watcher.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(AppDbContext))]
|
[DbContext(typeof(AppDbContext))]
|
||||||
[Migration("20250730172010_MeasurementWarnings")]
|
[Migration("20251105201056_AddContainerServerNavigation")]
|
||||||
partial class MeasurementWarnings
|
partial class AddContainerServerNavigation
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@@ -26,52 +26,71 @@ namespace Watcher.Migrations
|
|||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
b.Property<string>("ContainerId")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT")
|
||||||
|
.HasAnnotation("Relational:JsonPropertyName", "id");
|
||||||
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")
|
||||||
|
.HasAnnotation("Relational:JsonPropertyName", "image");
|
||||||
|
|
||||||
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")
|
||||||
|
.HasAnnotation("Relational:JsonPropertyName", "name");
|
||||||
|
|
||||||
b.Property<string>("Status")
|
b.Property<int>("ServerId")
|
||||||
.IsRequired()
|
.HasColumnType("INTEGER")
|
||||||
.HasColumnType("TEXT");
|
.HasAnnotation("Relational:JsonPropertyName", "Server_id");
|
||||||
|
|
||||||
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("ServerId");
|
||||||
|
|
||||||
b.HasIndex("TagId");
|
b.HasIndex("TagId");
|
||||||
|
|
||||||
b.ToTable("Containers");
|
b.ToTable("Containers");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Watcher.Models.ContainerMetric", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<double>("CPU_Load")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("CPU_Temp")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<int?>("ContainerId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<double>("RAM_Load")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("RAM_Size")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Timestamp")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("ContainerMetrics");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Image", b =>
|
modelBuilder.Entity("Watcher.Models.Image", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@@ -298,22 +317,16 @@ namespace Watcher.Migrations
|
|||||||
b.Property<string>("Email")
|
b.Property<string>("Email")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("IdentityProvider")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<DateTime>("LastLogin")
|
b.Property<DateTime>("LastLogin")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("OIDC_Id")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Password")
|
b.Property<string>("Password")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("Username")
|
b.Property<string>("Username")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
@@ -323,19 +336,21 @@ 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");
|
||||||
|
|
||||||
|
b.HasOne("Watcher.Models.Server", "Server")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ServerId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("Watcher.Models.Tag", null)
|
b.HasOne("Watcher.Models.Tag", null)
|
||||||
.WithMany("Containers")
|
.WithMany("Containers")
|
||||||
.HasForeignKey("TagId");
|
.HasForeignKey("TagId");
|
||||||
|
|
||||||
b.Navigation("HostServer");
|
b.Navigation("Server");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Watcher.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddContainerServerNavigation : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Containers_ServerId",
|
||||||
|
table: "Containers",
|
||||||
|
column: "ServerId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Containers_Servers_ServerId",
|
||||||
|
table: "Containers",
|
||||||
|
column: "ServerId",
|
||||||
|
principalTable: "Servers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Containers_Servers_ServerId",
|
||||||
|
table: "Containers");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Containers_ServerId",
|
||||||
|
table: "Containers");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,10 +24,12 @@ namespace Watcher.Migrations
|
|||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<string>("ContainerId")
|
b.Property<string>("ContainerId")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT")
|
||||||
|
.HasAnnotation("Relational:JsonPropertyName", "id");
|
||||||
|
|
||||||
b.Property<string>("Image")
|
b.Property<string>("Image")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT")
|
||||||
|
.HasAnnotation("Relational:JsonPropertyName", "image");
|
||||||
|
|
||||||
b.Property<int?>("ImageId")
|
b.Property<int?>("ImageId")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
@@ -36,10 +38,12 @@ namespace Watcher.Migrations
|
|||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT")
|
||||||
|
.HasAnnotation("Relational:JsonPropertyName", "name");
|
||||||
|
|
||||||
b.Property<int>("ServerId")
|
b.Property<int>("ServerId")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER")
|
||||||
|
.HasAnnotation("Relational:JsonPropertyName", "Server_id");
|
||||||
|
|
||||||
b.Property<int?>("TagId")
|
b.Property<int?>("TagId")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
@@ -48,11 +52,42 @@ namespace Watcher.Migrations
|
|||||||
|
|
||||||
b.HasIndex("ImageId");
|
b.HasIndex("ImageId");
|
||||||
|
|
||||||
|
b.HasIndex("ServerId");
|
||||||
|
|
||||||
b.HasIndex("TagId");
|
b.HasIndex("TagId");
|
||||||
|
|
||||||
b.ToTable("Containers");
|
b.ToTable("Containers");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Watcher.Models.ContainerMetric", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<double>("CPU_Load")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("CPU_Temp")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<int?>("ContainerId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<double>("RAM_Load")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<double>("RAM_Size")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Timestamp")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("ContainerMetrics");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.Image", b =>
|
modelBuilder.Entity("Watcher.Models.Image", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@@ -279,22 +314,16 @@ namespace Watcher.Migrations
|
|||||||
b.Property<string>("Email")
|
b.Property<string>("Email")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("IdentityProvider")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<DateTime>("LastLogin")
|
b.Property<DateTime>("LastLogin")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("OIDC_Id")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Password")
|
b.Property<string>("Password")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("Username")
|
b.Property<string>("Username")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
@@ -308,9 +337,17 @@ namespace Watcher.Migrations
|
|||||||
.WithMany("Containers")
|
.WithMany("Containers")
|
||||||
.HasForeignKey("ImageId");
|
.HasForeignKey("ImageId");
|
||||||
|
|
||||||
|
b.HasOne("Watcher.Models.Server", "Server")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ServerId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("Watcher.Models.Tag", null)
|
b.HasOne("Watcher.Models.Tag", null)
|
||||||
.WithMany("Containers")
|
.WithMany("Containers")
|
||||||
.HasForeignKey("TagId");
|
.HasForeignKey("TagId");
|
||||||
|
|
||||||
|
b.Navigation("Server");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
||||||
|
|||||||
@@ -1,14 +1,27 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Watcher.Models;
|
namespace Watcher.Models;
|
||||||
|
|
||||||
public class Container
|
public class Container
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("Server_id")]
|
||||||
public int ServerId { get; set; }
|
public int ServerId { get; set; }
|
||||||
|
|
||||||
|
// Navigation Property
|
||||||
|
public Server Server { get; set; } = null!;
|
||||||
|
|
||||||
|
[JsonPropertyName("id")]
|
||||||
public String? ContainerId { get; set; }
|
public String? ContainerId { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("image")]
|
||||||
public String? Image { get; set; }
|
public String? Image { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("name")]
|
||||||
public String? Name { get; set; }
|
public String? Name { get; set; }
|
||||||
|
|
||||||
|
// keine Variable, die vom Agent übergeben wird. Ein container ist immer Running, die Variable dient nur für die Übersicht
|
||||||
|
// auf dem Dashboard.
|
||||||
public Boolean IsRunning { get; set; } = true;
|
public Boolean IsRunning { get; set; } = true;
|
||||||
}
|
}
|
||||||
|
|||||||
24
Watcher/Models/ContainerMetric.cs
Normal file
24
Watcher/Models/ContainerMetric.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
namespace Watcher.Models;
|
||||||
|
|
||||||
|
public class ContainerMetric
|
||||||
|
{
|
||||||
|
// Metric Metadata
|
||||||
|
public int Id { get; set; }
|
||||||
|
public DateTime Timestamp { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
// Zuordnung zu einem Container -- Foreign Key
|
||||||
|
public int? ContainerId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
// CPU-Daten
|
||||||
|
public double CPU_Load { get; set; } = 0.0; // %
|
||||||
|
|
||||||
|
public double CPU_Temp { get; set; } = 0.0; // deg C
|
||||||
|
|
||||||
|
// RAM-Daten
|
||||||
|
public double RAM_Size { get; set; } = 0.0; // GB
|
||||||
|
|
||||||
|
public double RAM_Load { get; set; } = 0.0; // %
|
||||||
|
|
||||||
|
}
|
||||||
@@ -7,16 +7,18 @@ public class User
|
|||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
public int Id { get; set; } // PK
|
public int Id { get; set; }
|
||||||
public string? OIDC_Id { get; set; } = null!;
|
|
||||||
public string Username { get; set; } = null!;
|
|
||||||
public string? Email { get; set; }
|
|
||||||
public DateTime LastLogin { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string IdentityProvider { get; set; } = "local";
|
[StringLength(50)]
|
||||||
|
public string Username { get; set; } = null!;
|
||||||
|
|
||||||
|
[EmailAddress]
|
||||||
|
public string? Email { get; set; }
|
||||||
|
|
||||||
|
public DateTime LastLogin { get; set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[DataType(DataType.Password)]
|
[DataType(DataType.Password)]
|
||||||
public String? Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.OpenApi.Models;
|
||||||
|
|
||||||
using Serilog;
|
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;
|
|
||||||
|
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
@@ -36,11 +34,21 @@ builder.Services.AddHttpContextAccessor();
|
|||||||
|
|
||||||
// Storage Singleton
|
// Storage Singleton
|
||||||
builder.Services.AddSingleton<IDashboardStore, DashboardStore>();
|
builder.Services.AddSingleton<IDashboardStore, DashboardStore>();
|
||||||
|
builder.Services.AddSingleton<ISystemStore, SystemStore>();
|
||||||
|
builder.Services.AddSingleton<IVersionService, VersionService>();
|
||||||
|
builder.Services.AddSingleton<IUpdateCheckStore, UpdateCheckStore>();
|
||||||
|
|
||||||
// Background Services
|
// Background Services
|
||||||
builder.Services.AddHostedService<NetworkCheck>();
|
builder.Services.AddHostedService<NetworkCheck>();
|
||||||
builder.Services.AddHostedService<DatabaseCheck>();
|
builder.Services.AddHostedService<DatabaseCheck>();
|
||||||
|
builder.Services.AddHostedService<MetricCleanupService>();
|
||||||
|
builder.Services.AddHostedService<UpdateCheckService>();
|
||||||
|
|
||||||
|
// Swagger API-Dokumentation
|
||||||
|
builder.Services.AddSwaggerGen(options =>
|
||||||
|
{
|
||||||
|
options.SwaggerDoc("v1", new OpenApiInfo { Title = "Watcher-Server API", Version = "v1" });
|
||||||
|
});
|
||||||
|
|
||||||
// ---------- Konfiguration ----------
|
// ---------- Konfiguration ----------
|
||||||
DotNetEnv.Env.Load();
|
DotNetEnv.Env.Load();
|
||||||
@@ -55,106 +63,25 @@ var configuration = builder.Configuration;
|
|||||||
|
|
||||||
|
|
||||||
// ---------- DB-Kontext ----------
|
// ---------- DB-Kontext ----------
|
||||||
var dbProvider = configuration["Database:Provider"] ?? "MySQL";
|
// Nur SQLite wird unterstützt
|
||||||
var connectionString = configuration["Database:ConnectionString"];
|
var sqliteConnectionString = configuration.GetConnectionString("Sqlite")
|
||||||
|
?? configuration["Database:ConnectionStrings:Sqlite"]
|
||||||
|
?? "Data Source=./persistence/watcher.db";
|
||||||
|
|
||||||
builder.Services.AddDbContext<AppDbContext>((serviceProvider, options) =>
|
builder.Services.AddDbContext<AppDbContext>((serviceProvider, options) =>
|
||||||
{
|
{
|
||||||
var config = serviceProvider.GetRequiredService<IConfiguration>();
|
options.UseSqlite(sqliteConnectionString);
|
||||||
var provider = dbProvider;
|
|
||||||
|
|
||||||
if (provider == "MySql")
|
|
||||||
{
|
|
||||||
var connStr = config.GetConnectionString("MySql") ?? config["Database:ConnectionStrings:MySql"];
|
|
||||||
options.UseMySql(connStr, ServerVersion.AutoDetect(connStr));
|
|
||||||
}
|
|
||||||
else if (provider == "Sqlite")
|
|
||||||
{
|
|
||||||
var connStr = config.GetConnectionString("Sqlite") ?? config["Database:ConnectionStrings:Sqlite"];
|
|
||||||
options.UseSqlite(connStr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception("Unsupported database provider configured.");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// ---------- Authentifizierung konfigurieren ----------
|
// ---------- Authentifizierung konfigurieren ----------
|
||||||
// PocketID nur konfigurieren, wenn aktiviert
|
// Nur Cookie-basierte lokale Authentifizierung
|
||||||
var pocketIdSection = builder.Configuration.GetSection("Authentication:PocketID");
|
builder.Services.AddAuthentication("Cookies")
|
||||||
var pocketIdEnabled = pocketIdSection.GetValue<bool>("Enabled");
|
.AddCookie("Cookies", options =>
|
||||||
|
|
||||||
|
|
||||||
var auth = builder.Services.AddAuthentication("Cookies");
|
|
||||||
auth.AddCookie("Cookies", options =>
|
|
||||||
{
|
|
||||||
options.LoginPath = "/Auth/Login";
|
|
||||||
options.AccessDeniedPath = "/Auth/AccessDenied";
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
builder.Services.AddAuthentication()
|
|
||||||
.AddOpenIdConnect("oidc", options =>
|
|
||||||
{
|
|
||||||
options.Authority = pocketIdSection["Authority"];
|
|
||||||
options.ClientId = pocketIdSection["ClientId"];
|
|
||||||
options.ClientSecret = pocketIdSection["ClientSecret"];
|
|
||||||
options.ResponseType = "code";
|
|
||||||
options.CallbackPath = pocketIdSection["CallbackPath"];
|
|
||||||
options.SaveTokens = true;
|
|
||||||
|
|
||||||
options.GetClaimsFromUserInfoEndpoint = true;
|
|
||||||
|
|
||||||
options.Scope.Clear();
|
|
||||||
options.Scope.Add("openid");
|
|
||||||
options.Scope.Add("profile");
|
|
||||||
options.Scope.Add("email");
|
|
||||||
|
|
||||||
options.Events = new OpenIdConnectEvents
|
|
||||||
{
|
{
|
||||||
OnTokenValidated = async ctx =>
|
options.LoginPath = "/Auth/Login";
|
||||||
{
|
options.AccessDeniedPath = "/Auth/AccessDenied";
|
||||||
var db = ctx.HttpContext.RequestServices.GetRequiredService<AppDbContext>();
|
});
|
||||||
|
|
||||||
var principal = ctx.Principal;
|
|
||||||
#pragma warning disable CS8602 // Dereference of a possibly null reference.
|
|
||||||
|
|
||||||
var pocketId = principal.FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier")?.Value;
|
|
||||||
#pragma warning restore CS8602 // Dereference of a possibly null reference.
|
|
||||||
|
|
||||||
var preferredUsername = principal.FindFirst("preferred_username")?.Value;
|
|
||||||
var email = principal.FindFirst("email")?.Value;
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(pocketId))
|
|
||||||
return;
|
|
||||||
|
|
||||||
var user = await db.Users.FirstOrDefaultAsync(u => u.OIDC_Id == pocketId);
|
|
||||||
|
|
||||||
if (user == null)
|
|
||||||
{
|
|
||||||
user = new User
|
|
||||||
{
|
|
||||||
OIDC_Id = pocketId,
|
|
||||||
Username = preferredUsername ?? "",
|
|
||||||
Email = email,
|
|
||||||
LastLogin = DateTime.UtcNow,
|
|
||||||
IdentityProvider = "oidc",
|
|
||||||
Password = string.Empty
|
|
||||||
};
|
|
||||||
db.Users.Add(user);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
user.LastLogin = DateTime.UtcNow;
|
|
||||||
user.Username = preferredUsername ?? user.Username;
|
|
||||||
user.Email = email ?? user.Email;
|
|
||||||
db.Users.Update(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
await db.SaveChangesAsync();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
@@ -168,7 +95,7 @@ using (var scope = app.Services.CreateScope())
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Standart-User in Datenbank schreiben
|
// Standard-Admin-User erstellen
|
||||||
using (var scope = app.Services.CreateScope())
|
using (var scope = app.Services.CreateScope())
|
||||||
{
|
{
|
||||||
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||||
@@ -177,21 +104,19 @@ using (var scope = app.Services.CreateScope())
|
|||||||
|
|
||||||
if (!db.Users.Any())
|
if (!db.Users.Any())
|
||||||
{
|
{
|
||||||
Console.WriteLine("No users found, creating default user...");
|
Console.WriteLine("No users found, creating default admin user...");
|
||||||
|
|
||||||
var defaultUser = new User
|
var defaultUser = new User
|
||||||
{
|
{
|
||||||
OIDC_Id = string.Empty,
|
|
||||||
Username = "admin",
|
Username = "admin",
|
||||||
Email = string.Empty,
|
Email = "admin@localhost",
|
||||||
LastLogin = DateTime.UtcNow,
|
LastLogin = DateTime.UtcNow,
|
||||||
IdentityProvider = "local",
|
|
||||||
Password = BCrypt.Net.BCrypt.HashPassword("changeme")
|
Password = BCrypt.Net.BCrypt.HashPassword("changeme")
|
||||||
};
|
};
|
||||||
db.Users.Add(defaultUser);
|
db.Users.Add(defaultUser);
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
|
|
||||||
Console.WriteLine("Default user created.");
|
Console.WriteLine("Default admin user created (username: admin, password: changeme)");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -204,22 +129,30 @@ using (var scope = app.Services.CreateScope())
|
|||||||
if (!app.Environment.IsDevelopment())
|
if (!app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseExceptionHandler("/Home/Error");
|
app.UseExceptionHandler("/Home/Error");
|
||||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
|
||||||
app.UseHsts();
|
app.UseHsts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
app.UseStaticFiles();
|
||||||
|
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
|
|
||||||
|
// 🔹 Swagger aktivieren
|
||||||
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI(options =>
|
||||||
|
{
|
||||||
|
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Watcher-Server API v1");
|
||||||
|
options.RoutePrefix = "api/v1/swagger";
|
||||||
|
});
|
||||||
|
|
||||||
|
// 🔹 Authentifizierung & Autorisierung
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
app.UseStaticFiles();
|
// 🔹 MVC-Routing
|
||||||
|
|
||||||
app.MapControllerRoute(
|
app.MapControllerRoute(
|
||||||
name: "default",
|
name: "default",
|
||||||
pattern: "{controller=Home}/{action=Index}/{id?}"
|
pattern: "{controller=Home}/{action=Index}/{id?}"
|
||||||
);
|
);
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|||||||
9
Watcher/Services/ISystemStore.cs
Normal file
9
Watcher/Services/ISystemStore.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Watcher.Services;
|
||||||
|
|
||||||
|
public interface ISystemStore
|
||||||
|
{
|
||||||
|
Boolean NewVersionAvailable { get; set; }
|
||||||
|
|
||||||
|
Double DatabaseSize { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
8
Watcher/Services/IUpdateCheckStore.cs
Normal file
8
Watcher/Services/IUpdateCheckStore.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace Watcher.Services;
|
||||||
|
|
||||||
|
public interface IUpdateCheckStore
|
||||||
|
{
|
||||||
|
bool IsUpdateAvailable { get; set; }
|
||||||
|
string? LatestVersion { get; set; }
|
||||||
|
DateTime LastChecked { get; set; }
|
||||||
|
}
|
||||||
6
Watcher/Services/IVersionService.cs
Normal file
6
Watcher/Services/IVersionService.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Watcher.Services;
|
||||||
|
|
||||||
|
public interface IVersionService
|
||||||
|
{
|
||||||
|
string GetVersion();
|
||||||
|
}
|
||||||
127
Watcher/Services/MetricCleanupService.cs
Normal file
127
Watcher/Services/MetricCleanupService.cs
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Watcher.Data;
|
||||||
|
|
||||||
|
namespace Watcher.Services;
|
||||||
|
|
||||||
|
public class MetricCleanupService : BackgroundService
|
||||||
|
{
|
||||||
|
private readonly ILogger<MetricCleanupService> _logger;
|
||||||
|
private readonly IServiceProvider _serviceProvider;
|
||||||
|
private readonly int _retentionDays;
|
||||||
|
private readonly int _checkIntervalHours;
|
||||||
|
private readonly bool _enabled;
|
||||||
|
|
||||||
|
public MetricCleanupService(
|
||||||
|
ILogger<MetricCleanupService> logger,
|
||||||
|
IServiceProvider serviceProvider,
|
||||||
|
IConfiguration configuration)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_serviceProvider = serviceProvider;
|
||||||
|
|
||||||
|
// Konfiguration aus Environment Variablen laden
|
||||||
|
_retentionDays = int.TryParse(
|
||||||
|
configuration["DataRetention:MetricRetentionDays"] ??
|
||||||
|
Environment.GetEnvironmentVariable("METRIC_RETENTION_DAYS"),
|
||||||
|
out var days) ? days : 30; // Default: 30 Tage
|
||||||
|
|
||||||
|
_checkIntervalHours = int.TryParse(
|
||||||
|
configuration["DataRetention:CleanupIntervalHours"] ??
|
||||||
|
Environment.GetEnvironmentVariable("METRIC_CLEANUP_INTERVAL_HOURS"),
|
||||||
|
out var hours) ? hours : 24; // Default: 24 Stunden
|
||||||
|
|
||||||
|
_enabled = bool.TryParse(
|
||||||
|
configuration["DataRetention:Enabled"] ??
|
||||||
|
Environment.GetEnvironmentVariable("METRIC_CLEANUP_ENABLED"),
|
||||||
|
out var enabled) ? enabled : true; // Default: aktiviert
|
||||||
|
|
||||||
|
_logger.LogInformation(
|
||||||
|
"MetricCleanupService konfiguriert: Enabled={Enabled}, RetentionDays={Days}, IntervalHours={Hours}",
|
||||||
|
_enabled, _retentionDays, _checkIntervalHours);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
|
{
|
||||||
|
if (!_enabled)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("MetricCleanupService ist deaktiviert.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Warte 1 Minute nach Start, bevor der erste Cleanup läuft
|
||||||
|
await Task.Delay(TimeSpan.FromMinutes(1), stoppingToken);
|
||||||
|
|
||||||
|
var timer = new PeriodicTimer(TimeSpan.FromHours(_checkIntervalHours));
|
||||||
|
|
||||||
|
while (await timer.WaitForNextTickAsync(stoppingToken))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await CleanupOldMetricsAsync();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Fehler beim Cleanup alter Metriken.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Offset nach Cleanup
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(10), stoppingToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task CleanupOldMetricsAsync()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Starte Metric Cleanup für Daten älter als {Days} Tage...", _retentionDays);
|
||||||
|
|
||||||
|
using var scope = _serviceProvider.CreateScope();
|
||||||
|
var context = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||||
|
|
||||||
|
var cutoffDate = DateTime.UtcNow.AddDays(-_retentionDays);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Anzahl der zu löschenden Einträge ermitteln
|
||||||
|
var countToDelete = await context.Metrics
|
||||||
|
.Where(m => m.Timestamp < cutoffDate)
|
||||||
|
.CountAsync();
|
||||||
|
|
||||||
|
if (countToDelete == 0)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Keine alten Metriken zum Löschen gefunden.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Lösche {Count} Metriken vor {Date}...", countToDelete, cutoffDate);
|
||||||
|
|
||||||
|
// Metriken löschen
|
||||||
|
var deletedCount = await context.Metrics
|
||||||
|
.Where(m => m.Timestamp < cutoffDate)
|
||||||
|
.ExecuteDeleteAsync();
|
||||||
|
|
||||||
|
_logger.LogInformation(
|
||||||
|
"Metric Cleanup abgeschlossen: {DeletedCount} Einträge gelöscht.",
|
||||||
|
deletedCount);
|
||||||
|
|
||||||
|
// Optional: ContainerMetrics auch bereinigen
|
||||||
|
var containerMetricsCount = await context.ContainerMetrics
|
||||||
|
.Where(cm => cm.Timestamp < cutoffDate)
|
||||||
|
.CountAsync();
|
||||||
|
|
||||||
|
if (containerMetricsCount > 0)
|
||||||
|
{
|
||||||
|
var deletedContainerMetrics = await context.ContainerMetrics
|
||||||
|
.Where(cm => cm.Timestamp < cutoffDate)
|
||||||
|
.ExecuteDeleteAsync();
|
||||||
|
|
||||||
|
_logger.LogInformation(
|
||||||
|
"ContainerMetrics Cleanup: {DeletedCount} Einträge gelöscht.",
|
||||||
|
deletedContainerMetrics);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Fehler beim Löschen alter Metriken aus der Datenbank.");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
42
Watcher/Services/SystemMangement.cs
Normal file
42
Watcher/Services/SystemMangement.cs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
using System.Net.Http;
|
||||||
|
|
||||||
|
namespace Watcher.Services;
|
||||||
|
|
||||||
|
public class SystemManagement : BackgroundService
|
||||||
|
{
|
||||||
|
private readonly ILogger<NetworkCheck> _logger;
|
||||||
|
|
||||||
|
private ISystemStore _SystemStore;
|
||||||
|
|
||||||
|
public SystemManagement(ILogger<NetworkCheck> logger, ISystemStore SystemStore)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_SystemStore = SystemStore;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
|
{
|
||||||
|
// Todo: Umstellen auf einmal alle 24h
|
||||||
|
var timer = new PeriodicTimer(TimeSpan.FromSeconds(30));
|
||||||
|
|
||||||
|
while (await timer.WaitForNextTickAsync(stoppingToken))
|
||||||
|
{
|
||||||
|
// Hintergrundprozess abwarten
|
||||||
|
await checkForNewDockerImageVersion();
|
||||||
|
|
||||||
|
// 5 Sekdunden Offset
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task checkForNewDockerImageVersion()
|
||||||
|
{
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task createDailySqliteBackup()
|
||||||
|
{
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
9
Watcher/Services/SystemStore.cs
Normal file
9
Watcher/Services/SystemStore.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Watcher.Services;
|
||||||
|
|
||||||
|
public class SystemStore: ISystemStore
|
||||||
|
{
|
||||||
|
public Boolean NewVersionAvailable { get; set; }
|
||||||
|
|
||||||
|
public Double DatabaseSize { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
159
Watcher/Services/UpdateCheckService.cs
Normal file
159
Watcher/Services/UpdateCheckService.cs
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace Watcher.Services;
|
||||||
|
|
||||||
|
public class UpdateCheckService : BackgroundService
|
||||||
|
{
|
||||||
|
private readonly ILogger<UpdateCheckService> _logger;
|
||||||
|
private readonly IUpdateCheckStore _updateCheckStore;
|
||||||
|
private readonly IVersionService _versionService;
|
||||||
|
private readonly string _repositoryUrl;
|
||||||
|
private readonly int _checkIntervalHours;
|
||||||
|
private readonly bool _enabled;
|
||||||
|
private readonly HttpClient _httpClient;
|
||||||
|
|
||||||
|
public UpdateCheckService(
|
||||||
|
ILogger<UpdateCheckService> logger,
|
||||||
|
IUpdateCheckStore updateCheckStore,
|
||||||
|
IVersionService versionService,
|
||||||
|
IConfiguration configuration)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_updateCheckStore = updateCheckStore;
|
||||||
|
_versionService = versionService;
|
||||||
|
_httpClient = new HttpClient();
|
||||||
|
|
||||||
|
// Konfiguration aus Environment Variablen laden
|
||||||
|
_repositoryUrl = configuration["UpdateCheck:RepositoryUrl"]
|
||||||
|
?? Environment.GetEnvironmentVariable("UPDATE_CHECK_REPOSITORY_URL")
|
||||||
|
?? "https://git.triggermeelmo.com/api/v1/repos/Watcher/watcher/releases/latest";
|
||||||
|
|
||||||
|
_checkIntervalHours = int.TryParse(
|
||||||
|
configuration["UpdateCheck:CheckIntervalHours"]
|
||||||
|
?? Environment.GetEnvironmentVariable("UPDATE_CHECK_INTERVAL_HOURS"),
|
||||||
|
out var hours) ? hours : 24; // Default: 24 Stunden
|
||||||
|
|
||||||
|
_enabled = bool.TryParse(
|
||||||
|
configuration["UpdateCheck:Enabled"]
|
||||||
|
?? Environment.GetEnvironmentVariable("UPDATE_CHECK_ENABLED"),
|
||||||
|
out var enabled) ? enabled : true; // Default: aktiviert
|
||||||
|
|
||||||
|
_logger.LogInformation(
|
||||||
|
"UpdateCheckService konfiguriert: Enabled={Enabled}, Repository={Repo}, IntervalHours={Hours}",
|
||||||
|
_enabled, _repositoryUrl, _checkIntervalHours);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
|
{
|
||||||
|
if (!_enabled)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("UpdateCheckService ist deaktiviert.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Warte 2 Minuten nach Start, bevor der erste Check läuft
|
||||||
|
await Task.Delay(TimeSpan.FromMinutes(2), stoppingToken);
|
||||||
|
|
||||||
|
var timer = new PeriodicTimer(TimeSpan.FromHours(_checkIntervalHours));
|
||||||
|
|
||||||
|
while (await timer.WaitForNextTickAsync(stoppingToken))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await CheckForUpdatesAsync();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Fehler beim Update-Check.");
|
||||||
|
}
|
||||||
|
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(10), stoppingToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task CheckForUpdatesAsync()
|
||||||
|
{
|
||||||
|
var currentVersion = _versionService.GetVersion();
|
||||||
|
|
||||||
|
_logger.LogInformation("Starte Update-Check. Aktuelle Version: {Version}", currentVersion);
|
||||||
|
|
||||||
|
// Bei "development" oder "latest" immer als aktuell markieren
|
||||||
|
if (currentVersion == "development" || currentVersion == "latest")
|
||||||
|
{
|
||||||
|
_updateCheckStore.IsUpdateAvailable = false;
|
||||||
|
_updateCheckStore.LatestVersion = currentVersion;
|
||||||
|
_updateCheckStore.LastChecked = DateTime.UtcNow;
|
||||||
|
_logger.LogInformation("Development/Latest Build - keine Update-Prüfung nötig.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Gitea API abfragen
|
||||||
|
var response = await _httpClient.GetAsync(_repositoryUrl);
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Gitea API Fehler: {StatusCode}", response.StatusCode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var jsonContent = await response.Content.ReadAsStringAsync();
|
||||||
|
var releaseInfo = JsonSerializer.Deserialize<GiteaReleaseResponse>(jsonContent);
|
||||||
|
|
||||||
|
if (releaseInfo?.TagName == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Keine Release-Information gefunden.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var latestVersion = releaseInfo.TagName;
|
||||||
|
_updateCheckStore.LatestVersion = latestVersion;
|
||||||
|
_updateCheckStore.LastChecked = DateTime.UtcNow;
|
||||||
|
|
||||||
|
// Versionsvergleich
|
||||||
|
var isNewer = CompareVersions(latestVersion, currentVersion);
|
||||||
|
_updateCheckStore.IsUpdateAvailable = isNewer;
|
||||||
|
|
||||||
|
if (isNewer)
|
||||||
|
{
|
||||||
|
_logger.LogInformation(
|
||||||
|
"Neue Version verfügbar: {Latest} (aktuell: {Current})",
|
||||||
|
latestVersion, currentVersion);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.LogInformation(
|
||||||
|
"System ist auf dem neuesten Stand: {Version}",
|
||||||
|
currentVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Fehler beim Abrufen der Release-Informationen von Gitea.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool CompareVersions(string latestVersion, string currentVersion)
|
||||||
|
{
|
||||||
|
// Entferne "v" Prefix falls vorhanden
|
||||||
|
latestVersion = latestVersion.TrimStart('v');
|
||||||
|
currentVersion = currentVersion.TrimStart('v');
|
||||||
|
|
||||||
|
// Versuche semantic versioning zu parsen
|
||||||
|
if (Version.TryParse(latestVersion, out var latest) &&
|
||||||
|
Version.TryParse(currentVersion, out var current))
|
||||||
|
{
|
||||||
|
return latest > current;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback: String-Vergleich
|
||||||
|
return string.Compare(latestVersion, currentVersion, StringComparison.Ordinal) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// DTO für Gitea API Response
|
||||||
|
private class GiteaReleaseResponse
|
||||||
|
{
|
||||||
|
public string? TagName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
8
Watcher/Services/UpdateCheckStore.cs
Normal file
8
Watcher/Services/UpdateCheckStore.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace Watcher.Services;
|
||||||
|
|
||||||
|
public class UpdateCheckStore : IUpdateCheckStore
|
||||||
|
{
|
||||||
|
public bool IsUpdateAvailable { get; set; } = false;
|
||||||
|
public string? LatestVersion { get; set; } = null;
|
||||||
|
public DateTime LastChecked { get; set; } = DateTime.MinValue;
|
||||||
|
}
|
||||||
19
Watcher/Services/VersionService.cs
Normal file
19
Watcher/Services/VersionService.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
namespace Watcher.Services;
|
||||||
|
|
||||||
|
public class VersionService : IVersionService
|
||||||
|
{
|
||||||
|
private readonly string _version;
|
||||||
|
|
||||||
|
public VersionService(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
// Priorität: Environment Variable > Configuration > Default
|
||||||
|
_version = Environment.GetEnvironmentVariable("WATCHER_VERSION")
|
||||||
|
?? configuration["Application:Version"]
|
||||||
|
?? "development";
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetVersion()
|
||||||
|
{
|
||||||
|
return _version;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,20 +12,21 @@
|
|||||||
<div >
|
<div >
|
||||||
<table class="ServiceList">
|
<table class="ServiceList">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Service</th>
|
<th>Container-ID</th>
|
||||||
<th>HostServer</th>
|
<th>Name</th>
|
||||||
<th>Status</th>
|
<th>Image</th>
|
||||||
<th>Deployment</th>
|
<th>Host</th>
|
||||||
<th></th>
|
<th>Aktionen</th>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
@foreach (Container container in Model.Containers)
|
@foreach (Container container in Model.Containers)
|
||||||
{
|
{
|
||||||
<tr class="ServiceRow">
|
<tr class="ServiceRow">
|
||||||
|
<td>@container.ContainerId</td>
|
||||||
<td>@container.Name</td>
|
<td>@container.Name</td>
|
||||||
<td><a class="ServiceEntry" href="/Server/Details/${containerId}">@container.ServerId</a></td>
|
<td>@container.Image</td>
|
||||||
<td>nicht automatisiert</td>
|
<td><a class="ServiceEntry" href="/Server/Details/@container.ServerId">@container.Server?.Name</a></td>
|
||||||
<td>Docker</td>
|
<td>nicht verfügbar</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
@using Microsoft.IdentityModel.Tokens
|
|
||||||
@model Watcher.ViewModels.DashboardViewModel
|
@model Watcher.ViewModels.DashboardViewModel
|
||||||
|
|
||||||
@{
|
@{
|
||||||
@@ -58,7 +57,7 @@
|
|||||||
<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())
|
@if (!string.IsNullOrEmpty(Model.NetworkStatus))
|
||||||
{
|
{
|
||||||
@if (Model.NetworkStatus == "online")
|
@if (Model.NetworkStatus == "online")
|
||||||
{
|
{
|
||||||
@@ -81,7 +80,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (!Model.DatabaseStatus.IsNullOrEmpty())
|
@if (!string.IsNullOrEmpty(Model.DatabaseStatus))
|
||||||
{
|
{
|
||||||
@if (Model.DatabaseStatus == "ok")
|
@if (Model.DatabaseStatus == "ok")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
@using Microsoft.AspNetCore.Authentication
|
@using Microsoft.AspNetCore.Authentication
|
||||||
@using Microsoft.AspNetCore.Authorization
|
@using Microsoft.AspNetCore.Authorization
|
||||||
@using Microsoft.AspNetCore.Http
|
@using Microsoft.AspNetCore.Http
|
||||||
|
@using Watcher.Services
|
||||||
@inject IHttpContextAccessor HttpContextAccessor
|
@inject IHttpContextAccessor HttpContextAccessor
|
||||||
|
@inject IVersionService VersionService
|
||||||
|
@inject IUpdateCheckStore UpdateCheckStore
|
||||||
|
|
||||||
@{
|
@{
|
||||||
var pictureUrl = User.FindFirst("picture")?.Value;
|
var pictureUrl = User.FindFirst("picture")?.Value;
|
||||||
@@ -98,7 +101,7 @@
|
|||||||
<div class="rounded-circle bg-secondary text-white px-2 py-1">
|
<div class="rounded-circle bg-secondary text-white px-2 py-1">
|
||||||
<i class="bi bi-person"></i>
|
<i class="bi bi-person"></i>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<strong>@User.Identity?.Name</strong><br />
|
<strong>@User.Identity?.Name</strong><br />
|
||||||
<small class="text-muted">Profil ansehen</small>
|
<small class="text-muted">Profil ansehen</small>
|
||||||
@@ -110,6 +113,19 @@
|
|||||||
{
|
{
|
||||||
<a class="nav-link p-0 text-primary" href="/Account/Login">Login</a>
|
<a class="nav-link p-0 text-primary" href="/Account/Login">Login</a>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<div class="mt-3 pt-3 border-top border-secondary text-center">
|
||||||
|
<small style="color: #adb5bd;">
|
||||||
|
@{
|
||||||
|
var statusColor = UpdateCheckStore.IsUpdateAvailable ? "#ffc107" : "#28a745";
|
||||||
|
var statusTitle = UpdateCheckStore.IsUpdateAvailable
|
||||||
|
? $"Update verfügbar: {UpdateCheckStore.LatestVersion}"
|
||||||
|
: "System ist aktuell";
|
||||||
|
}
|
||||||
|
<span style="display: inline-block; width: 8px; height: 8px; background-color: @statusColor; border-radius: 50%; margin-right: 8px;" title="@statusTitle"></span>
|
||||||
|
<i class="bi bi-box me-1"></i>Version: <strong style="color: #fff;">@VersionService.GetVersion()</strong>
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -29,10 +29,14 @@
|
|||||||
<hr class="my-4" />
|
<hr class="my-4" />
|
||||||
|
|
||||||
<h5>Datenbank-Engine: <strong>@(DbEngine ?? "nicht gefunden")</strong></h5>
|
<h5>Datenbank-Engine: <strong>@(DbEngine ?? "nicht gefunden")</strong></h5>
|
||||||
|
|
||||||
|
@if (ViewBag.DatabaseSize != null)
|
||||||
|
{
|
||||||
|
<h5>Datenbankgröße: <strong>@ViewBag.DatabaseSize</strong></h5>
|
||||||
|
}
|
||||||
|
|
||||||
<!-- Falls Sqlite verwendet wird können Backups erstellt werden -->
|
<!-- Falls Sqlite verwendet wird können Backups erstellt werden -->
|
||||||
@if (DbEngine == "Microsoft.EntityFrameworkCore.Sqlite")
|
@if (DbEngine == "SQLite" || DbEngine == "Microsoft.EntityFrameworkCore.Sqlite")
|
||||||
{
|
{
|
||||||
<div class="d-flex gap-2">
|
<div class="d-flex gap-2">
|
||||||
<form asp-action="CreateSqlDump" method="post" asp-controller="Database">
|
<form asp-action="CreateSqlDump" method="post" asp-controller="Database">
|
||||||
|
|||||||
@@ -7,22 +7,16 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- EF Core Design Tools -->
|
|
||||||
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
|
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
|
||||||
<PackageReference Include="DotNetEnv" Version="3.1.1" />
|
<PackageReference Include="DotNetEnv" Version="3.1.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.6" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="9.0.8" />
|
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="9.0.8" />
|
||||||
|
|
||||||
<!-- Pomelo MySQL EF Core Provider -->
|
|
||||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0" />
|
|
||||||
|
|
||||||
<!-- Auth via OpenID Connect + Cookies -->
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.3.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.3.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.6" />
|
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
|
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
|
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.6" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -9,22 +9,8 @@
|
|||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
|
|
||||||
"Database": {
|
"Database": {
|
||||||
"Provider": "Sqlite",
|
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"MySql": "server=0.0.0.0;port=3306;database=db;user=user;password=password;",
|
|
||||||
"Sqlite": "Data Source=./persistence/watcher.db"
|
"Sqlite": "Data Source=./persistence/watcher.db"
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
"Authentication": {
|
|
||||||
"UseLocal": true,
|
|
||||||
"PocketIDEnabled": false,
|
|
||||||
"PocketID": {
|
|
||||||
"Authority": "https://pocketid.triggermeelmo.com",
|
|
||||||
"ClientId": "629a5f42-ab02-4905-8311-cc7b64165cc0",
|
|
||||||
"ClientSecret": "QHUNaRyK2VVYdZVz1cQqv8FEf2qtL6QH",
|
|
||||||
"CallbackPath": "/signin-oidc",
|
|
||||||
"ResponseType": "code"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
watcher:
|
watcher:
|
||||||
image: git.triggermeelmo.com/watcher/watcher-server:v0.1.0
|
image: git.triggermeelmo.com/watcher/watcher-server:${IMAGE_VERSION:-latest}
|
||||||
container_name: watcher
|
container_name: watcher
|
||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
@@ -8,6 +8,17 @@ services:
|
|||||||
memory: 200M
|
memory: 200M
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
env_file: .env
|
env_file: .env
|
||||||
|
environment:
|
||||||
|
# Application Version (wird aus Image-Tag übernommen)
|
||||||
|
- WATCHER_VERSION=${IMAGE_VERSION:-latest}
|
||||||
|
# Update Check
|
||||||
|
- UPDATE_CHECK_ENABLED=true
|
||||||
|
- UPDATE_CHECK_INTERVAL_HOURS=24
|
||||||
|
- UPDATE_CHECK_REPOSITORY_URL=https://git.triggermeelmo.com/api/v1/repos/Watcher/watcher/releases/latest
|
||||||
|
# Data Retention Policy
|
||||||
|
- METRIC_RETENTION_DAYS=30
|
||||||
|
- METRIC_CLEANUP_INTERVAL_HOURS=24
|
||||||
|
- METRIC_CLEANUP_ENABLED=true
|
||||||
ports:
|
ports:
|
||||||
- "5000:5000"
|
- "5000:5000"
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
Reference in New Issue
Block a user