init
Some checks failed
Gitea CI/CD / dotnet-build-and-test (push) Has been cancelled
Gitea CI/CD / Set Tag Name (push) Has been cancelled
Gitea CI/CD / docker-build-and-push (push) Has been cancelled
Gitea CI/CD / Create Tag (push) Has been cancelled

This commit is contained in:
2025-12-05 09:19:46 +01:00
commit e72bc48cc4
94 changed files with 75940 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
// Get Methoden um Metrics abzugreifen
// Get Methden um Informationen über den Status des Servers einzuholen

View File

@@ -0,0 +1,56 @@
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using watcher_monitoring.Models;
using watcher_monitoring.Data;
namespace watcher_monitoring.Controllers;
public class HomeController : Controller
{
private readonly WatcherDbContext _dbContext;
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger, WatcherDbContext dbContext)
{
_logger = logger;
_dbContext = dbContext;
}
// Dashboard
public IActionResult Index()
{
var servers = new List<dynamic>
{
new { Name = "Web Server 01", IPAddress = "192.168.1.10", IsOnline = true },
new { Name = "Database Server", IPAddress = "192.168.1.20", IsOnline = true },
new { Name = "API Gateway", IPAddress = "192.168.1.30", IsOnline = true },
new { Name = "Cache Server", IPAddress = "192.168.1.40", IsOnline = false },
new { Name = "Backup Server", IPAddress = "192.168.1.50", IsOnline = true }
};
ViewBag.TotalServers = servers.Count;
ViewBag.OnlineServers = servers.Count(s => s.IsOnline);
ViewBag.OfflineServers = servers.Count(s => !s.IsOnline);
ViewBag.ServiceCount = 8;
ViewBag.Servers = servers;
return View();
}
public IActionResult Privacy()
{
return View();
}
public IActionResult SystemInformation()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}

View File

@@ -0,0 +1,68 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using System.Text.Json;
using watcher_monitoring.Payloads;
using watcher_monitoring.Data;
namespace watcher_monitoring.Controllers;
[Route("[controller]")]
public class MonitoringController : Controller
{
private readonly WatcherDbContext _context;
private readonly ILogger<MonitoringController> _logger;
public MonitoringController(WatcherDbContext context, ILogger<MonitoringController> logger)
{
_context = context;
_logger = logger;
}
// Registration Endpoint for watcher-agent
[HttpPost("registration")]
public async Task<IActionResult> Registration([FromBody] RegistrationDto dto)
{
// payload check
if (!ModelState.IsValid)
{
var errors = ModelState.Values
.SelectMany(v => v.Errors)
.Select(e => e.ErrorMessage)
.ToList();
_logger.LogError("Invalid registration payload");
return BadRequest(new { error = "Invalid registration payload", details = errors });
}
return Ok();
}
// Hardware Configuration Endpoint for watcher-agent
[HttpPost("hardware-configuration")]
public async Task<IActionResult> HardwareConfiguration ([FromBody] HardwareDto dto)
{
// payload check
if (!ModelState.IsValid)
{
var errors = ModelState.Values
.SelectMany(v => v.Errors)
.Select(e => e.ErrorMessage)
.ToList();
_logger.LogError("Invalid hardware configuration");
return BadRequest(new { error = "Invalid Hardware Configuration Payload", details = errors });
}
return Ok();
}
// Server-Metrics endpoint for watcher-agent
// Service-Detection endpoint for watcher-agent
// Service-Metrics endpoint for watcher-agent
}

View File

@@ -0,0 +1 @@
// Mailer und ntfy Benachrichtigungen