using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using System.Diagnostics; using System.Management; using System.Runtime.InteropServices; namespace Admin.Areas.Identity.Pages.Server { public class InfoModel : PageModel { private readonly IHostEnvironment _env; // ¾Û, È£½ºÆ®(Host) public required string EnvironmentName { get; set; } public required string ContentRootPath { get; set; } public required string ApplicationName { get; set; } // OS, Framework public required string OSDescription { get; set; } public required string OSArchitecture { get; set; } public required string FrameworkDescription { get; set; } public required string ProcessArchitecture { get; set; } public long WorkingSet { get; set; } public TimeSpan TotalCpuTime { get; set; } // ½Ã½ºÅÛ public required string MachineName { get; set; } public required string CurrentDirectory { get; set; } public required string SystemDirectory { get; set; } public bool Is64BitOperatingSystem { get; set; } public bool Is64BitProcess { get; set; } public int ProcessorCount { get; set; } public required string TickCount { get; set; } public ManagementObjectCollection? CPU { get; private set; } public ManagementObjectCollection? Memory { get; private set; } public ManagementObjectCollection? Disk { get; private set; } public InfoModel(IHostEnvironment env) { _env = env; } public async Task OnGetAsync() { var process = Process.GetCurrentProcess(); // ¾Û, È£½ºÆ®(Host) °ü·Ã EnvironmentName = _env.EnvironmentName; ContentRootPath = _env.ContentRootPath; ApplicationName = _env.ApplicationName; // OS, Framework °ü·Ã OSDescription = RuntimeInformation.OSDescription; OSArchitecture = RuntimeInformation.OSArchitecture.ToString(); FrameworkDescription = RuntimeInformation.FrameworkDescription; ProcessArchitecture = RuntimeInformation.ProcessArchitecture.ToString(); WorkingSet = process.WorkingSet64 / 1048576; // ¹°¸® ¸Þ¸ð¸® »ç¿ë·®(¹ÙÀÌÆ®) TotalCpuTime = process.TotalProcessorTime; // ÇÁ·Î¼¼½º ½ÇÇà ½Ã°£ // ½Ã½ºÅÛ(ȯ°æº¯¼ö) °ü·Ã MachineName = Environment.MachineName; CurrentDirectory = Environment.CurrentDirectory; SystemDirectory = Environment.SystemDirectory; Is64BitOperatingSystem = Environment.Is64BitOperatingSystem; Is64BitProcess = Environment.Is64BitProcess; ProcessorCount = Environment.ProcessorCount; // ½ÃÀÛ ½Ã°¢ µî TickCount = TimeSpan.FromMicroseconds(Environment.TickCount).ToString(); // ½Ã½ºÅÛ ½ÃÀÛ ÈÄ °æ°ú ½Ã°£(¹Ð¸®ÃÊ) // Ç÷§Æû Á¶°ÇºÎ ÄÚµå·Î Windows¿¡¼­¸¸ ½ÇÇàµÇµµ·Ï ¼öÁ¤ if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { // CPU Á¤º¸ CPU = new ManagementObjectSearcher("select * from Win32_Processor").Get(); // ¸Þ¸ð¸® Á¤º¸ Memory = new ManagementObjectSearcher("select * from Win32_MemoryDevice").Get(); // µð½ºÅ© Á¤º¸ Disk = new ManagementObjectSearcher("select * from Win32_DiskDrive").Get(); } return Page(); } } }