How to collect system information in Mono?

Since System.Management is not implemented in Mono, so what is the way to get system information in Mono? The information I'm looking for is as follows:

  • CPU - number of processors, processor type, model number, core, native thread, clock speed, manufacturer, limb, SSE information

  • GPU - model number, manufacturer, number of CUDA cores

  • Memory - shared memory, page size

  • OS - Basic OS Information

This data can be obtained using System.Management, but only for .net / Windows. But if I try to run the same code in Mono / Linux, it will fail because System.Management will not be implemented in Mono. So, how can I get this information uniformly regardless of the OS?

+4
source share
2 answers

A simple attempt:

Try using the "Environment" element . May you have access to some of them.

0
source

The correct way to resolve this issue and as many Mono-related issues, and how to deal with differences in behavior across different operating systems (for example, the Ping class is a real pain), you should probably use the ProcessStartInfo class and do the parsing.

IMHO, this is a real solution that requires a lot of work (remember that sometimes console commands are localized = /) to make it truly "platform independent". Ironically, you will have to make a great platform to work to achieve your goals, but in any case, it can be a way to achieve your goal.

public static class SystemInformation { static SystemInformation() { switch (Environment.OSVersion.Platform) { case PlatformID.Unix: case PlatformID.MacOSX: break; // Let "assume" for a while that our default case // below covers all Windows related Operating Systems... default: break; } } private readonly static CPUInformation _cpu; public static CPUInformation CPU { get { return SystemInformation._cpu; } } private readonly static OSInformation _os; public static OSInformation OS { get { return SystemInformation._os; } } private readonly static RAMInformation _ram; public static RAMInformation RAM { get { return SystemInformation._ram; } } private readonly static GPUInformation _gpu; public static GPUInformation GPU { get { return SystemInformation._gpu; } } } public sealed class CPUInformation { internal CPUInformation( /*... Add some parameters here .. */ ) { // Fill the constructor... } // Add some properties here... } public sealed class OSInformation { internal OSInformation( /*... Add some parameters here .. */ ) { // Fill the constructor... } // Add some properties here... } public sealed class GPUInformation { internal GPUInformation( /*... Add some parameters here .. */ ) { // Fill the constructor... } // Add some properties here... } public sealed class RAMInformation { internal RAMInformation( /*... Add some parameters here .. */ ) { // Fill the constructor... } // Add some properties here... } 
0
source

All Articles