init
This commit is contained in:
2
watcher-monitoring/Controllers/ApiController.cs
Normal file
2
watcher-monitoring/Controllers/ApiController.cs
Normal file
@@ -0,0 +1,2 @@
|
||||
// Get Methoden um Metrics abzugreifen
|
||||
// Get Methden um Informationen über den Status des Servers einzuholen
|
||||
56
watcher-monitoring/Controllers/HomeController.cs
Normal file
56
watcher-monitoring/Controllers/HomeController.cs
Normal 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 });
|
||||
}
|
||||
}
|
||||
68
watcher-monitoring/Controllers/MonitoringController.cs
Normal file
68
watcher-monitoring/Controllers/MonitoringController.cs
Normal 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
|
||||
|
||||
}
|
||||
1
watcher-monitoring/Controllers/NotificationController.cs
Normal file
1
watcher-monitoring/Controllers/NotificationController.cs
Normal file
@@ -0,0 +1 @@
|
||||
// Mailer und ntfy Benachrichtigungen
|
||||
Reference in New Issue
Block a user