Files
tnb.server/system/Tnb.Systems/System/MonitorService.cs
2023-03-13 15:00:34 +08:00

53 lines
1.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.Systems.Entitys.Dto.Monitor;
using JNPF.Systems.Interfaces.System;
using Microsoft.AspNetCore.Mvc;
using System.Runtime.InteropServices;
namespace JNPF.Systems;
/// <summary>
/// 系统监控
/// 版 本V3.2
/// 版 权拓通智联科技有限公司http://www.tuotong-tech.com
/// 日 期2021-06-01.
/// </summary>
[ApiDescriptionSettings(Tag = "System", Name = "Monitor", Order = 215)]
[Route("api/system/[controller]")]
public class MonitorService : IDynamicApiController, ITransient
{
#region Get
/// <summary>
/// 系统监控.
/// </summary>
/// <returns></returns>
[HttpGet("")]
public dynamic GetInfo()
{
var flag_Linux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
var flag_Windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
MonitorOutput output = new MonitorOutput();
if (flag_Linux)
{
output.system = MachineHelper.GetSystemInfo_Linux();
output.cpu = MachineHelper.GetCpuInfo_Linux();
output.memory = MachineHelper.GetMemoryInfo_Linux();
output.disk = MachineHelper.GetDiskInfo_Linux();
}
else if (flag_Windows)
{
output.system = MachineHelper.GetSystemInfo_Windows();
output.cpu = MachineHelper.GetCpuInfo_Windows();
output.memory = MachineHelper.GetMemoryInfo_Windows();
output.disk = MachineHelper.GetDiskInfo_Windows();
}
output.time = DateTime.Now;
return output;
}
#endregion
}