Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
db45872908 | |||
8e0dcc34e7 | |||
015cdcb202 | |||
2841752870 | |||
8ffb220634 | |||
120374ebe1 | |||
55aa9f546a | |||
0974c1d7dd | |||
0e72287c6b | |||
3918425ef9 | |||
ec13a51575 | |||
b8626cb8ea | |||
281e9c686b | |||
69dd73a079 | |||
2e9d41fe60 | |||
7e75f3e49e | |||
8e362f7271 | |||
52c4243efc | |||
6248fad147 |
132
.gitea/workflows/build.yaml
Normal file
132
.gitea/workflows/build.yaml
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
name: Gitea CI/CD
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches: [ "development", "main", "feature/*", "bugfix/*", "enhancement/*" ]
|
||||||
|
tags: [ "v*.*.*" ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "development", "main" ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOTNET_VERSION: '8.0.x'
|
||||||
|
DOCKER_IMAGE_NAME: watcher-server
|
||||||
|
REGISTRY_URL: git.triggermeelmo.com
|
||||||
|
DOCKER_PLATFORMS: 'linux/amd64,linux/arm64'
|
||||||
|
TAG: ${{ github.ref == 'refs/heads/main' && 'latest' || github.ref == 'refs/heads/development' && 'development' || github.ref_type == 'tag' && github.ref_name || 'pr' }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
RUNNER_TOOL_CACHE: /toolcache # Runner Tool Cache
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup .NET SDK
|
||||||
|
uses: actions/setup-dotnet@v3
|
||||||
|
with:
|
||||||
|
dotnet-version: ${{ env.DOTNET_VERSION }}
|
||||||
|
|
||||||
|
- name: Restore dependencies
|
||||||
|
run: dotnet restore
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: dotnet build --configuration Release --no-restore
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: dotnet test --no-build --verbosity normal
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Publish
|
||||||
|
run: dotnet publish -c Release -o out
|
||||||
|
|
||||||
|
set-tag:
|
||||||
|
name: Set Tag Name
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
RUNNER_TOOL_CACHE: /toolcache
|
||||||
|
outputs:
|
||||||
|
tag_name: ${{ steps.set_tag.outputs.tag_name }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Determine next semantic version tag
|
||||||
|
id: set_tag
|
||||||
|
run: |
|
||||||
|
git fetch --tags
|
||||||
|
|
||||||
|
# Find latest tag matching vX.Y.Z
|
||||||
|
latest_tag=$(git tag --list 'v*.*.*' --sort=-v:refname | head -n 1)
|
||||||
|
if [[ -z "$latest_tag" ]]; then
|
||||||
|
major=0
|
||||||
|
minor=0
|
||||||
|
patch=0
|
||||||
|
else
|
||||||
|
version="${latest_tag#v}"
|
||||||
|
IFS='.' read -r major minor patch <<< "$version"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
|
||||||
|
major=$((major + 1))
|
||||||
|
minor=0
|
||||||
|
patch=0
|
||||||
|
elif [[ "${GITHUB_REF}" == "refs/heads/development" ]]; then
|
||||||
|
minor=$((minor + 1))
|
||||||
|
patch=0
|
||||||
|
else
|
||||||
|
patch=$((patch + 1))
|
||||||
|
fi
|
||||||
|
|
||||||
|
new_tag="v${major}.${minor}.${patch}"
|
||||||
|
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
docker-build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
RUNNER_TOOL_CACHE: /toolcache # Runner Tool Cache
|
||||||
|
needs: [build-and-test, set-tag]
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Login to Gitea Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY_URL}}
|
||||||
|
username: ${{ secrets.AUTOMATION_USERNAME }}
|
||||||
|
password: ${{ secrets.AUTOMATION_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and Push Multi-Arch Docker Image
|
||||||
|
run: |
|
||||||
|
docker buildx build \
|
||||||
|
--platform ${{ env.DOCKER_PLATFORMS }} \
|
||||||
|
-t ${{ env.REGISTRY_URL }}/watcher/${{ env.DOCKER_IMAGE_NAME }}:${{ needs.set-tag.outputs.tag_name }} \
|
||||||
|
--push .
|
||||||
|
|
||||||
|
tag:
|
||||||
|
name: Create Tag
|
||||||
|
needs: [docker-build, build, set-tag]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
RUNNER_TOOL_CACHE: /toolcache
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Set up Git user
|
||||||
|
run: |
|
||||||
|
git config user.name "GitHub Actions"
|
||||||
|
git config user.email "actions@github.com"
|
||||||
|
|
||||||
|
- name: Create and push tag
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
git tag ${{ needs.set-tag.outputs.tag_name }}
|
||||||
|
git push origin ${{ needs.set-tag.outputs.tag_name }}
|
@@ -1,63 +0,0 @@
|
|||||||
name: Development Build
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- development
|
|
||||||
|
|
||||||
env:
|
|
||||||
DOTNET_VERSION: '8.0.x'
|
|
||||||
DOCKER_IMAGE_NAME: 'watcher-server'
|
|
||||||
REGISTRY_URL: 'git.triggermeelmo.com/watcher'
|
|
||||||
DOCKER_PLATFORMS: 'linux/amd64,linux/arm64'
|
|
||||||
RUNNER_TOOL_CACHE: /toolcache # Runner Tool Cache
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-and-test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Setup .NET SDK
|
|
||||||
uses: actions/setup-dotnet@v3
|
|
||||||
with:
|
|
||||||
dotnet-version: ${{ env.DOTNET_VERSION }}
|
|
||||||
|
|
||||||
- name: Restore dependencies
|
|
||||||
run: dotnet restore
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: dotnet build --configuration Release --no-restore
|
|
||||||
|
|
||||||
- name: Test
|
|
||||||
run: dotnet test --no-build --verbosity normal
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
- name: Publish
|
|
||||||
run: dotnet publish -c Release -o out
|
|
||||||
|
|
||||||
docker-build-and-push:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build-and-test
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Setup Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v2
|
|
||||||
|
|
||||||
- name: Login to Gitea Container Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ${{ env.REGISTRY_URL}}
|
|
||||||
username: ${{ secrets.AUTOMATION_USERNAME }}
|
|
||||||
password: ${{ secrets.AUTOMATION_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Build and Push Multi-Arch Docker Image
|
|
||||||
run: |
|
|
||||||
docker buildx build \
|
|
||||||
--platform ${{ env.DOCKER_PLATFORMS }} \
|
|
||||||
-t ${{ env.REGISTRY_URL }}/${{ env.DOCKER_IMAGE_NAME }}:development \
|
|
||||||
-t ${{ env.REGISTRY_URL }}/${{ env.DOCKER_IMAGE_NAME }}:${{ github.sha }} \
|
|
||||||
--push .
|
|
@@ -1,62 +0,0 @@
|
|||||||
name: Release Build and Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
env:
|
|
||||||
DOTNET_VERSION: '8.0.x'
|
|
||||||
DOCKER_IMAGE_NAME: 'watcher-server'
|
|
||||||
REGISTRY_URL: 'git.triggermeelmo.com/watcher'
|
|
||||||
DOCKER_PLATFORMS: 'linux/amd64,linux/arm64'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-and-test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Setup .NET SDK
|
|
||||||
uses: actions/setup-dotnet@v3
|
|
||||||
with:
|
|
||||||
dotnet-version: ${{ env.DOTNET_VERSION }}
|
|
||||||
|
|
||||||
- name: Restore dependencies
|
|
||||||
run: dotnet restore
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: dotnet build --configuration Release --no-restore
|
|
||||||
|
|
||||||
- name: Test
|
|
||||||
run: dotnet test --no-build --verbosity normal
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
- name: Publish
|
|
||||||
run: dotnet publish -c Release -o out
|
|
||||||
|
|
||||||
docker-build-and-push:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build-and-test
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Setup Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v2
|
|
||||||
|
|
||||||
- name: Login to Gitea Container Registry
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
registry: git.triggermeelmo.com
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Build and Push Multi-Arch Docker Image
|
|
||||||
run: |
|
|
||||||
docker buildx build \
|
|
||||||
--platform ${{ env.DOCKER_PLATFORMS }} \
|
|
||||||
-t ${{ env.REGISTRY_URL }}/${{ env.DOCKER_IMAGE_NAME }}:v0.1.0 \
|
|
||||||
-t ${{ env.REGISTRY_URL }}/${{ env.DOCKER_IMAGE_NAME }}:${{ github.sha }} \
|
|
||||||
--push .
|
|
@@ -4,8 +4,8 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
// Local Namespaces
|
// Local Namespaces
|
||||||
using Watcher.Data;
|
using Watcher.Data;
|
||||||
using Watcher.Models;
|
|
||||||
using Watcher.ViewModels;
|
using Watcher.ViewModels;
|
||||||
|
using Watcher.Services;
|
||||||
|
|
||||||
namespace Watcher.Controllers
|
namespace Watcher.Controllers
|
||||||
{
|
{
|
||||||
@@ -18,11 +18,16 @@ namespace Watcher.Controllers
|
|||||||
// Logging einbinden
|
// Logging einbinden
|
||||||
private readonly ILogger<HomeController> _logger;
|
private readonly ILogger<HomeController> _logger;
|
||||||
|
|
||||||
|
// Daten der Backgroundchecks abrufen
|
||||||
|
private IDashboardStore _DashboardStore;
|
||||||
|
|
||||||
// HomeController Constructor
|
// HomeController Constructor
|
||||||
public HomeController(AppDbContext context, ILogger<HomeController> logger)
|
public HomeController(AppDbContext context, ILogger<HomeController> logger, IDashboardStore dashboardStore)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
_DashboardStore = dashboardStore;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dashboard unter /home/index
|
// Dashboard unter /home/index
|
||||||
@@ -52,9 +57,11 @@ namespace Watcher.Controllers
|
|||||||
.ToListAsync(),
|
.ToListAsync(),
|
||||||
Containers = await _context.Containers
|
Containers = await _context.Containers
|
||||||
.OrderBy(s => s.Name)
|
.OrderBy(s => s.Name)
|
||||||
.ToListAsync()
|
.ToListAsync(),
|
||||||
|
NetworkStatus = _DashboardStore.NetworkStatus,
|
||||||
|
DatabaseStatus = _DashboardStore.DatabaseStatus
|
||||||
};
|
};
|
||||||
|
//ViewBag.NetworkConnection = _NetworkCheckStore.NetworkStatus;
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,11 +89,18 @@ namespace Watcher.Controllers
|
|||||||
.ToListAsync(),
|
.ToListAsync(),
|
||||||
Containers = await _context.Containers
|
Containers = await _context.Containers
|
||||||
.OrderBy(s => s.Name)
|
.OrderBy(s => s.Name)
|
||||||
.ToListAsync()
|
.ToListAsync(),
|
||||||
|
NetworkStatus = _DashboardStore.NetworkStatus,
|
||||||
|
DatabaseStatus = _DashboardStore.DatabaseStatus
|
||||||
};
|
};
|
||||||
|
|
||||||
return PartialView("_DashboardStats", model);
|
return PartialView("_DashboardStats", model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String ReturnNetworkStatus()
|
||||||
|
{
|
||||||
|
return "OK";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,7 @@ using Serilog;
|
|||||||
|
|
||||||
using Watcher.Data;
|
using Watcher.Data;
|
||||||
using Watcher.Models;
|
using Watcher.Models;
|
||||||
|
using Watcher.Services;
|
||||||
//using Watcher.Services;
|
//using Watcher.Services;
|
||||||
//using Watcher.Workers;
|
//using Watcher.Workers;
|
||||||
|
|
||||||
@@ -15,7 +16,7 @@ var builder = WebApplication.CreateBuilder(args);
|
|||||||
// Serilog konfigurieren – nur Logs, die nicht von Microsoft stammen
|
// Serilog konfigurieren – nur Logs, die nicht von Microsoft stammen
|
||||||
Log.Logger = new LoggerConfiguration()
|
Log.Logger = new LoggerConfiguration()
|
||||||
.MinimumLevel.Information()
|
.MinimumLevel.Information()
|
||||||
.MinimumLevel.Override("Microsoft", Serilog.Events.LogEventLevel.Warning) // <--
|
.MinimumLevel.Override("Microsoft", Serilog.Events.LogEventLevel.Warning)
|
||||||
.Enrich.FromLogContext()
|
.Enrich.FromLogContext()
|
||||||
.WriteTo.File(
|
.WriteTo.File(
|
||||||
"logs/watcher-.log",
|
"logs/watcher-.log",
|
||||||
@@ -33,6 +34,13 @@ builder.Services.AddControllersWithViews();
|
|||||||
// HttpContentAccessor
|
// HttpContentAccessor
|
||||||
builder.Services.AddHttpContextAccessor();
|
builder.Services.AddHttpContextAccessor();
|
||||||
|
|
||||||
|
// Storage Singleton
|
||||||
|
builder.Services.AddSingleton<IDashboardStore, DashboardStore>();
|
||||||
|
|
||||||
|
// Background Services
|
||||||
|
builder.Services.AddHostedService<NetworkCheck>();
|
||||||
|
builder.Services.AddHostedService<DatabaseCheck>();
|
||||||
|
|
||||||
|
|
||||||
// ---------- Konfiguration ----------
|
// ---------- Konfiguration ----------
|
||||||
DotNetEnv.Env.Load();
|
DotNetEnv.Env.Load();
|
||||||
@@ -214,4 +222,4 @@ app.MapControllerRoute(
|
|||||||
pattern: "{controller=Home}/{action=Index}/{id?}"
|
pattern: "{controller=Home}/{action=Index}/{id?}"
|
||||||
);
|
);
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
8
Watcher/Services/DashboardStore.cs
Normal file
8
Watcher/Services/DashboardStore.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace Watcher.Services;
|
||||||
|
|
||||||
|
public class DashboardStore : IDashboardStore
|
||||||
|
{
|
||||||
|
public String? NetworkStatus { get; set; }
|
||||||
|
|
||||||
|
public String? DatabaseStatus { get; set; }
|
||||||
|
}
|
67
Watcher/Services/DatabaseCheck.cs
Normal file
67
Watcher/Services/DatabaseCheck.cs
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
using Microsoft.Data.Sqlite;
|
||||||
|
|
||||||
|
namespace Watcher.Services;
|
||||||
|
|
||||||
|
public class DatabaseCheck : BackgroundService
|
||||||
|
{
|
||||||
|
private readonly ILogger<DatabaseCheck> _logger;
|
||||||
|
|
||||||
|
private IDashboardStore _dashboardStore;
|
||||||
|
|
||||||
|
public DatabaseCheck(ILogger<DatabaseCheck> logger, IDashboardStore dashboardStore)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_dashboardStore = dashboardStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
|
{
|
||||||
|
var timer = new PeriodicTimer(TimeSpan.FromSeconds(30));
|
||||||
|
|
||||||
|
while (await timer.WaitForNextTickAsync(stoppingToken))
|
||||||
|
{
|
||||||
|
// Hintergrundprozess abwarten
|
||||||
|
await checkDatabaseIntegrity();
|
||||||
|
// 5 Sekdunden Offset
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// String sqliteConnectionString als Argument übergeben
|
||||||
|
public Task checkDatabaseIntegrity()
|
||||||
|
{
|
||||||
|
using var conn = new SqliteConnection("Data Source=./persistence/watcher.db");
|
||||||
|
_logger.LogInformation("Sqlite Integrity-Check started...");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
using var command = conn.CreateCommand();
|
||||||
|
command.CommandText = """
|
||||||
|
SELECT integrity_check FROM pragma_integrity_check;
|
||||||
|
""";
|
||||||
|
|
||||||
|
using var reader = command.ExecuteReader();
|
||||||
|
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
string status = reader.GetString(0);
|
||||||
|
_dashboardStore.DatabaseStatus = status;
|
||||||
|
_logger.LogInformation("Sqlite DatabaseIntegrity: ${status}", status);
|
||||||
|
}
|
||||||
|
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
catch (SqliteException e)
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
_logger.LogError(e.Message);
|
||||||
|
|
||||||
|
// TODO: LogEvent erstellen
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Database Integrity-Check finished.");
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
7
Watcher/Services/IDashboardStore.cs
Normal file
7
Watcher/Services/IDashboardStore.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Watcher.Services;
|
||||||
|
|
||||||
|
public interface IDashboardStore
|
||||||
|
{
|
||||||
|
String? NetworkStatus { get; set; }
|
||||||
|
String? DatabaseStatus { get; set; }
|
||||||
|
}
|
59
Watcher/Services/NetworkCheck.cs
Normal file
59
Watcher/Services/NetworkCheck.cs
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
using System.Net.NetworkInformation;
|
||||||
|
|
||||||
|
namespace Watcher.Services;
|
||||||
|
public class NetworkCheck : BackgroundService
|
||||||
|
{
|
||||||
|
private readonly ILogger<NetworkCheck> _logger;
|
||||||
|
|
||||||
|
private IDashboardStore _DashboardStore;
|
||||||
|
|
||||||
|
public NetworkCheck(ILogger<NetworkCheck> logger, IDashboardStore DashboardStore)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_DashboardStore = DashboardStore;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
|
{
|
||||||
|
var timer = new PeriodicTimer(TimeSpan.FromSeconds(30));
|
||||||
|
|
||||||
|
while (await timer.WaitForNextTickAsync(stoppingToken))
|
||||||
|
{
|
||||||
|
// Hintergrundprozess abwarten
|
||||||
|
await checkConnectionAsync();
|
||||||
|
|
||||||
|
// 5 Sekdunden Offset
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task checkConnectionAsync()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Networkcheck started.");
|
||||||
|
|
||||||
|
string host = "8.8.8.8";
|
||||||
|
Ping p = new Ping();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PingReply reply = p.Send(host, 3000);
|
||||||
|
if (reply.Status == IPStatus.Success)
|
||||||
|
{
|
||||||
|
_DashboardStore.NetworkStatus = "online";
|
||||||
|
_logger.LogInformation("Ping successfull. Watcher is online.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
_DashboardStore.NetworkStatus = "offline";
|
||||||
|
_logger.LogError("Ping failed. Watcher appears to have no network connection.");
|
||||||
|
|
||||||
|
// LogEvent erstellen
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Networkcheck finished.");
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
@@ -14,5 +14,8 @@ namespace Watcher.ViewModels
|
|||||||
public List<LogEvent> RecentEvents { get; set; } = new();
|
public List<LogEvent> RecentEvents { get; set; } = new();
|
||||||
public List<Container> Containers { get; set; } = new();
|
public List<Container> Containers { get; set; } = new();
|
||||||
|
|
||||||
|
public String? NetworkStatus { get; set; } = "?";
|
||||||
|
public String? DatabaseStatus { get; set; } = "?";
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
@using Microsoft.IdentityModel.Tokens
|
||||||
@model Watcher.ViewModels.DashboardViewModel
|
@model Watcher.ViewModels.DashboardViewModel
|
||||||
|
|
||||||
@{
|
@{
|
||||||
@@ -57,18 +58,54 @@
|
|||||||
<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>
|
||||||
|
|
||||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
@if (!Model.NetworkStatus.IsNullOrEmpty())
|
||||||
<span>Netzwerk</span>
|
{
|
||||||
<span class="badge bg-success">OK</span>
|
@if (Model.NetworkStatus == "online")
|
||||||
</div>
|
{
|
||||||
<div class="progress mb-3" style="height: 6px;">
|
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||||
<div class="progress-bar bg-success w-100"></div>
|
<span>Netzwerk</span>
|
||||||
</div>
|
<span class="badge bg-success">@Model.NetworkStatus</span>
|
||||||
|
</div>
|
||||||
|
<div class="progress mb-3" style="height: 6px;">
|
||||||
|
<div class="progress-bar bg-success w-100"></div>
|
||||||
|
</div>
|
||||||
|
} else if (Model.NetworkStatus == "offline")
|
||||||
|
{
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||||
|
<span>Netzwerk</span>
|
||||||
|
<span class="badge bg-danger">@Model.NetworkStatus</span>
|
||||||
|
</div>
|
||||||
|
<div class="progress mb-3" style="height: 6px;">
|
||||||
|
<div class="progress-bar bg-danger w-100"></div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
@if (!Model.DatabaseStatus.IsNullOrEmpty())
|
||||||
<span>Datenbank</span>
|
{
|
||||||
<span class="badge bg-success">OK</span>
|
@if (Model.DatabaseStatus == "ok")
|
||||||
</div>
|
{
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||||
|
<span>Datenbank</span>
|
||||||
|
<span class="badge bg-success">healthy</span>
|
||||||
|
</div>
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||||
|
<span>Datenbank</span>
|
||||||
|
<span class="badge bg-danger">unhealthy</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||||
|
<span>Datenbank</span>
|
||||||
|
|
||||||
|
<span class="badge bg-primary">Missing Data</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
<div class="progress mb-3" style="height: 6px;">
|
<div class="progress mb-3" style="height: 6px;">
|
||||||
<div class="progress-bar bg-success w-100"></div>
|
<div class="progress-bar bg-success w-100"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -97,6 +134,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Services -->
|
<!-- Services -->
|
||||||
|
<!-- TODO
|
||||||
<div class="col-12 col-lg-6">
|
<div class="col-12 col-lg-6">
|
||||||
<div class="card shadow rounded-3 p-4 h-100">
|
<div class="card shadow rounded-3 p-4 h-100">
|
||||||
<h2 class="h5 fw-semibold mb-3">Services</h2>
|
<h2 class="h5 fw-semibold mb-3">Services</h2>
|
||||||
@@ -113,20 +151,22 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
-->
|
||||||
|
|
||||||
<!-- Server Liste -->
|
<!-- Server Liste -->
|
||||||
|
<!-- TODO
|
||||||
<div class="col-12 col-lg-6">
|
<div class="col-12 col-lg-6">
|
||||||
<div class="card shadow rounded-3 p-4 h-100">
|
<div class="card shadow rounded-3 p-4 h-100">
|
||||||
<h2 class="h5 fw-semibold mb-3">Server</h2>
|
<h2 class="h5 fw-semibold mb-3">Server</h2>
|
||||||
<ul class="list-group list-group-flush">
|
<ul class="list-group list-group-flush">
|
||||||
@foreach (var server in Model.Servers)
|
@foreach (Server server in Model.Servers)
|
||||||
{
|
{
|
||||||
<li class="list-group-item d-flex justify-content-between align-items-center serverlist">
|
<li class="list-group-item d-flex justify-content-between align-items-center serverlist">
|
||||||
<span>@server.Name</span>
|
<span>@server.Name</span>
|
||||||
<span class="badge bg-info")">
|
<span class="badge bg-info" )">
|
||||||
CPU: 30.45%
|
CPU:
|
||||||
</span>
|
</span>
|
||||||
<span class="badge bg-info")">
|
<span class="badge bg-info" )">
|
||||||
RAM: 65.09%
|
RAM: 65.09%
|
||||||
</span>
|
</span>
|
||||||
<span class="badge @(server.IsOnline ? "bg-success" : "bg-danger")">
|
<span class="badge @(server.IsOnline ? "bg-success" : "bg-danger")">
|
||||||
@@ -136,6 +176,7 @@
|
|||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
-->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
Binary file not shown.
Reference in New Issue
Block a user