Re-organised statistic endpoints and services/helpers

This commit is contained in:
2024-12-13 20:35:22 +01:00
parent d15c5326ed
commit edc91229e1
13 changed files with 218 additions and 191 deletions

View File

@@ -1,33 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using MoonlightServers.Daemon.Services;
using MoonlightServers.DaemonShared.Http.Responses.Sys;
namespace MoonlightServers.Daemon.Http.Controllers.Sys;
[ApiController]
[Route("api/system/dataUsage")]
public class SystemDataUsageController : Controller
{
private readonly DockerInfoService DockerInfoService;
public SystemDataUsageController(DockerInfoService dockerInfoService)
{
DockerInfoService = dockerInfoService;
}
[HttpGet]
public async Task<SystemDataUsageResponse> Get()
{
var report = await DockerInfoService.GetDataUsage();
return new SystemDataUsageResponse()
{
ImagesReclaimable = report.Images.Reclaimable,
ImagesUsed = report.Images.Used,
ContainersReclaimable = report.Containers.Reclaimable,
ContainersUsed = report.Containers.Used,
BuildCacheReclaimable = report.BuildCache.Reclaimable,
BuildCacheUsed = report.BuildCache.Used
};
}
}

View File

@@ -1,33 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using MoonlightServers.Daemon.Services;
using MoonlightServers.DaemonShared.Http.Responses.Sys;
namespace MoonlightServers.Daemon.Http.Controllers.Sys;
[ApiController]
[Route("api/system/info")]
public class SystemInfoController : Controller
{
private readonly SystemInfoService SystemInfoService;
private readonly DockerInfoService DockerInfoService;
public SystemInfoController(SystemInfoService systemInfoService, DockerInfoService dockerInfoService)
{
SystemInfoService = systemInfoService;
DockerInfoService = dockerInfoService;
}
[HttpGet]
public async Task<SystemInfoResponse> GetInfo()
{
return new SystemInfoResponse()
{
Uptime = await SystemInfoService.GetUptime(),
Version = "2.1.0",
CpuUsage = await SystemInfoService.GetCpuUsage(),
DockerVersion = await DockerInfoService.GetDockerVersion(),
MemoryUsage = await SystemInfoService.GetMemoryUsage(),
OsName = await SystemInfoService.GetOsName()
};
}
}