完成linux系统下内存信息、磁盘信息获取
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Extensions;
|
||||
using Infrastructure.Model;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
@@ -7,8 +8,6 @@ using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Common;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers.monitor
|
||||
{
|
||||
@@ -17,7 +16,7 @@ namespace ZR.Admin.WebApi.Controllers.monitor
|
||||
{
|
||||
private OptionsSetting Options;
|
||||
private IWebHostEnvironment HostEnvironment;
|
||||
|
||||
private NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
public MonitorController(IOptions<OptionsSetting> options, IWebHostEnvironment hostEnvironment)
|
||||
{
|
||||
this.HostEnvironment = hostEnvironment;
|
||||
@@ -55,13 +54,16 @@ namespace ZR.Admin.WebApi.Controllers.monitor
|
||||
string version = RuntimeInformation.FrameworkDescription;
|
||||
string appRAM = ((double)Process.GetCurrentProcess().WorkingSet64 / 1048576).ToString("N2") + " MB";
|
||||
string startTime = Process.GetCurrentProcess().StartTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
string runTime = Process.GetCurrentProcess().StartTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
string serverIP = (Request.HttpContext.Connection.LocalIpAddress.MapToIPv4().ToString() + ":" + Request.HttpContext.Connection.LocalPort);//获取服务器IP
|
||||
string sysRunTime = ComputerHelper.GetRunTime();
|
||||
string serverIP = Request.HttpContext.Connection.LocalIpAddress.MapToIPv4().ToString() + ":" + Request.HttpContext.Connection.LocalPort;//获取服务器IP
|
||||
|
||||
var programStartTime = Process.GetCurrentProcess().StartTime;
|
||||
string programRunTime = DateTimeHelper.FormatTime((DateTime.Now - programStartTime).TotalMilliseconds.ToString().Split('.')[0].ParseToLong());
|
||||
var data = new
|
||||
{
|
||||
cpu = ComputerHelper.GetComputerInfo(),
|
||||
sys = new { cpuNum, computerName, osName, osArch, serverIP },
|
||||
disk = ComputerHelper.GetDiskInfos(),
|
||||
sys = new { cpuNum, computerName, osName, osArch, serverIP, runTime = sysRunTime },
|
||||
app = new
|
||||
{
|
||||
name = HostEnvironment.EnvironmentName,
|
||||
@@ -70,9 +72,9 @@ namespace ZR.Admin.WebApi.Controllers.monitor
|
||||
version,
|
||||
appRAM,
|
||||
startTime,
|
||||
runTime,
|
||||
runTime = programRunTime,
|
||||
host = serverIP
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
return SUCCESS(data);
|
||||
|
||||
Reference in New Issue
Block a user