Battery, BIOS, CPU - processor, storage drive, keyboard, RAM - memory, monitor, motherboard, mouse, NIC - network adapter, printer, sound card - audio card, graphics card - video card. Hardware.Info is a .NET 5+ library and uses /dev, /proc, /sys on Linux and sysctl, system_profiler on macOS.
$ dotnet add package Hardware.Info.LinuxAndMacThis fork of https://github.com/Jinjinov/Hardware.Info/
Only Linux and macOS operating system is supported!
Battery, BIOS, CPU - processor, storage drive, keyboard, RAM - memory, monitor, motherboard, mouse, NIC - network adapter, printer, sound card - audio card, graphics card - video card. Hardware.Info is a .NET 5+ library and /dev, /proc, /sys on Linux.
Include NuGet package from https://www.nuget.org/packages/Hardware.Info.Linux
<ItemGroup>
<PackageReference Include="Hardware.Info.Linux" Version="100.0.0.0" />
</ItemGroup>
Call RefreshAll() or one of the other Refresh*() methods:
class Program
{
static readonly IHardwareInfo hardwareInfo = new HardwareInfo();
static void Main(string[] _)
{
//hardwareInfo.RefreshOperatingSystem();
//hardwareInfo.RefreshMemoryStatus();
//hardwareInfo.RefreshBatteryList();
//hardwareInfo.RefreshBIOSList();
//hardwareInfo.RefreshCPUList();
//hardwareInfo.RefreshDriveList();
//hardwareInfo.RefreshKeyboardList();
//hardwareInfo.RefreshMemoryList();
//hardwareInfo.RefreshMonitorList();
//hardwareInfo.RefreshMotherboardList();
//hardwareInfo.RefreshMouseList();
//hardwareInfo.RefreshNetworkAdapterList();
//hardwareInfo.RefreshPrinterList();
//hardwareInfo.RefreshSoundDeviceList();
//hardwareInfo.RefreshVideoControllerList();
hardwareInfo.RefreshAll();
Console.WriteLine(hardwareInfo.OperatingSystem);
Console.WriteLine(hardwareInfo.MemoryStatus);
foreach (var hardware in hardwareInfo.BatteryList)
Console.WriteLine(hardware);
foreach (var hardware in hardwareInfo.BiosList)
Console.WriteLine(hardware);
foreach (var cpu in hardwareInfo.CpuList)
{
Console.WriteLine(cpu);
foreach (var cpuCore in cpu.CpuCoreList)
Console.WriteLine(cpuCore);
}
Console.ReadLine();
foreach (var drive in hardwareInfo.DriveList)
{
Console.WriteLine(drive);
foreach (var partition in drive.PartitionList)
{
Console.WriteLine(partition);
foreach (var volume in partition.VolumeList)
Console.WriteLine(volume);
}
}
Console.ReadLine();
foreach (var hardware in hardwareInfo.KeyboardList)
Console.WriteLine(hardware);
foreach (var hardware in hardwareInfo.MemoryList)
Console.WriteLine(hardware);
foreach (var hardware in hardwareInfo.MonitorList)
Console.WriteLine(hardware);
foreach (var hardware in hardwareInfo.MotherboardList)
Console.WriteLine(hardware);
foreach (var hardware in hardwareInfo.MouseList)
Console.WriteLine(hardware);
foreach (var hardware in hardwareInfo.NetworkAdapterList)
Console.WriteLine(hardware);
foreach (var hardware in hardwareInfo.PrinterList)
Console.WriteLine(hardware);
foreach (var hardware in hardwareInfo.SoundDeviceList)
Console.WriteLine(hardware);
foreach (var hardware in hardwareInfo.VideoControllerList)
Console.WriteLine(hardware);
Console.ReadLine();
foreach (var address in HardwareInfo.GetLocalIPv4Addresses(NetworkInterfaceType.Ethernet, OperationalStatus.Up))
Console.WriteLine(address);
Console.WriteLine();
foreach (var address in HardwareInfo.GetLocalIPv4Addresses(NetworkInterfaceType.Wireless80211))
Console.WriteLine(address);
Console.WriteLine();
foreach (var address in HardwareInfo.GetLocalIPv4Addresses(OperationalStatus.Up))
Console.WriteLine(address);
Console.WriteLine();
foreach (var address in HardwareInfo.GetLocalIPv4Addresses())
Console.WriteLine(address);
Console.ReadLine();
}
}
In these two methods you can exclude some slow queries by setting the parameters to false:
RefreshCPUList(bool includePercentProcessorTime = true)
RefreshNetworkAdapterList(bool includeBytesPersec = true, bool includeNetworkAdapterConfiguration = true)
Setting includePercentProcessorTime and includeBytesPersec to false will exclude the queries that:
Setting includeNetworkAdapterConfiguration to false has only a small impact on performance.
GetCpuList in Linux - thanks to @inelisoniGetMonitorList in Windows - by @GeevoGetMonitorList in Windows - by @GeevoNetworkAdapter.Speed in Windows - by @isenmannKeyboard info in LinuxMouse info in LinuxSoundDevice info in LinuxVideoController.CurrentHorizontalResolution in LinuxVideoController.CurrentVerticalResolution in LinuxVideoController.CurrentRefreshRate in LinuxVideoController.AdapterRAM in Windows - by @jesperllL1DataCacheSize and L1InstructionCacheSize in Windows, macOS, LinuxL2CacheSize and L3CacheSize in Windows, LinuxGetNetworkAdapterList in Windows - thanks to @isenmannCurrentClockSpeed in Windows - thanks to @jason-c-danielsGetCpuUsage in Linux - thanks to @glebov21CPU.Name and CPU.CurrentClockSpeed in macOS - by @davidaramantCPU.MaxClockSpeed in macOS - by @davidaramantPercentProcessorTime in Windows - thanks to @C6OIGetOperatingSystem() in Windows, macOS, Linux - thanks to @adhip94GetBatteryList() in macOS - by @TadelsuchtGetBatteryList() in Linux - by @TadelsuchtGetDriveList() and GetMemoryList() in Linux - thanks to @misaka00251Memory.BankLabel, Memory.MinVoltage, Memory.MaxVoltage in Windows - by @AathifMahirCPU.SocketDesignation, CPU.SecondLevelAddressTranslationExtensions in Windows - by @AathifMahirIHardwareInfo so that HardwareInfo can be mocked - by @240026763MemAvailable instead of MemFree in Linux - by @schotimeBattery.EstimatedChargeRemaining in Windows, Linux - by @reptailBattery.ExpectedLife in LinuxBattery.EstimatedRunTime in LinuxBattery.MaxRechargeTime in LinuxBattery.TimeToFullCharge in LinuxBattery.DesignCapacity in LinuxBattery.FullChargeCapacity in LinuxBattery.BatteryStatusDescription in LinuxMonitor info in macOSVideoController info in macOSCPU.L2CacheSize in macOSCPU.L3CacheSize in macOSMemory info in macOSBIOS.ReleaseDate in LinuxCPU.Manufacturer in LinuxCPU.L3CacheSize in LinuxMotherboard.SerialNumber in LinuxNetworkAdapter info in LinuxGetLocalIPv4Addresses() in macOSGetLocalIPv4Addresses() in Windows, macOS, LinuxMotherboard.SerialNumber in WindowsDrive, NetworkAdapter info in macOS, Linux