static void Main(string[] args) { var mainboard = new Mainboard(); Console.WriteLine(mainboard.Smbios.BIOS.Vendor); var cpu = Cpu.Discover(); foreach (var item in cpu) { Print(item.CoreTemperatures); Print(item.CoreClocks); Print(item.CorePowers); Print(item.CoreVoltages); Print(item.CoreClocks); } var hdd = HardDrive.Discover(); foreach (var item in hdd) { foreach (var smart in item.SmartSensors) { Console.WriteLine(smart.Key.Name); Print(new[] { smart.Value }); } } Console.ReadKey(); }
static void Main(string[] args) { var cpu = Cpu.Discover(); var i = 0; foreach (var item in cpu) { Console.WriteLine($":: cpu#{i}::"); Console.WriteLine(item.Identifier); Console.WriteLine(item.Name); foreach (var temp in item.CoreTemperatures) { Console.WriteLine($"Core temperature: {temp}"); } Console.WriteLine($"Package temperature: {item.PackageTemperature}"); Console.WriteLine(item.TotalLoad); foreach (var voltage in item.CoreVoltages) { Console.WriteLine($"voltage: {voltage}"); } } Console.ReadKey(); }
public void CpuTest2() { var cpus = Cpu.Discover(); for (int i = 0; i < 100; i++) { foreach (var cpu in cpus) { cpu.Update(); Console.WriteLine(cpu.PackageTemperature.ToString()); } Console.WriteLine(NTMiner.Windows.Cpu.Instance.GetTemperature()); System.Threading.Thread.Sleep(10); } }
private void _onTimerElepsed(object sender, ElapsedEventArgs e) { var cpu = Cpu.Discover(); foreach (var item in cpu) { foreach (var temp in item.CoreTemperatures) { var tem = random.Next(141421, 314160) / 10000M; Value = tem; if (_onUpdate != null) { _onUpdate.Invoke(this); } } } }
public static ComputerIdentity Collect() { var mainboard = new Mainboard(); var cpus = Cpu.Discover(); var networkInterfaces = NetworkInterface.GetAllNetworkInterfaces(); var identity = new ComputerIdentity() { MachineName = Environment.MachineName, Os = new OsIdentity { Name = Environment.OSVersion.Platform.ToString(), Version = Environment.OSVersion.VersionString, }, Board = new BoardIdentity { Name = mainboard.Name, Model = mainboard.Model.ToString(), Manufacturer = mainboard.Manufacturer.ToString(), SerialNumber = mainboard.Smbios?.Board?.SerialNumber }, Cpus = (from cpu in cpus select new CpuIdentity { Name = cpu.Name, Identifier = cpu.Identifier, Vendor = cpu.Vendor }).ToArray(), NetworkInterfaces = (from ni in networkInterfaces where ni.OperationalStatus == OperationalStatus.Up let physicalAddress = ni.GetPhysicalAddress()?.ToString() where !string.IsNullOrWhiteSpace(physicalAddress) select new NetworkInterfaceIdentity { Name = ni.Name, Id = ni.Id, Type = ni.NetworkInterfaceType.ToString(), PhysicalAddress = physicalAddress }).ToArray() }; return(identity); }
public static void CopyDiagnosticsToClipboard() { var sb = new StringBuilder(); try { sb.AppendLine("Recorded Unhandled Exceptions:"); var i = 0; foreach (var exc in RecordedUnhandledExceptions) { var excStr = exc.ToString(); sb.Append(" ").Append(++i).Append(". ").AppendLine(excStr.Replace("\n", "\n ")); var iex = exc; var j = 0; while (iex.InnerException != null) { iex = iex.InnerException; sb.Append(" ").Append(i).Append(".").Append(++j).Append(". ").AppendLine(excStr.Replace("\n", "\n ")); } } if (i == 0) { sb.AppendLine(" None."); } } catch (Exception ex) { sb.Append(" *** ERROR: ").Append(ex.GetType().Name).Append(": ").AppendLine(ex.Message); } sb.AppendLine(); try { sb.AppendLine("Recorded First Chance Exceptions:"); var i = 0; foreach (var exc in RecordedFirstChanceExceptions) { var excStr = exc.ToString(); sb.Append(" ").Append(++i).Append(". ").AppendLine(excStr.Replace("\n", "\n ")); var iex = exc; var j = 0; while (iex.InnerException != null) { iex = iex.InnerException; sb.Append(" ").Append(i).Append(".").Append(++j).Append(". ").AppendLine(excStr.Replace("\n", "\n ")); } } if (RecordFirstChanceExceptions) { if (i == 0) { sb.AppendLine(" None recorded."); } } else { sb.AppendLine(" Recording disabled."); } } catch (Exception ex) { sb.Append(" *** ERROR: ").Append(ex.GetType().Name).Append(": ").AppendLine(ex.Message); } sb.AppendLine(); try { sb.AppendLine("Modules Information:"); var i = 0; foreach (var mi in ModuleInfo.GetModules()) { sb.Append(" ").Append(++i).Append(". ").Append(mi.Id).Append(" ").Append(mi.Version.ToString()); if (mi.IsSelected) { sb.Append(" *Selected*"); } sb.AppendLine(); sb.Append(" ").Append(mi.Name); if (!string.IsNullOrWhiteSpace(mi.Alias)) { sb.Append(" (").Append(mi.Alias).Append(")"); } if (mi.IsOfficial) { sb.Append(" *Official*"); } sb.AppendLine(); if (mi.DependedModuleIds.Count <= 0) { continue; } sb.Append(" ").AppendLine("Dependencies:"); var j = 0; foreach (var dep in mi.DependedModuleIds) { sb.Append(" ").Append(++j).Append(". ").AppendLine(dep); } } } catch (Exception ex) { sb.Append(" *** ERROR: ").Append(ex.GetType().Name).Append(": ").AppendLine(ex.Message); } sb.AppendLine(); try { sb.AppendLine("Loaded SubModules:"); var i = 0; foreach (var sm in Module.CurrentModule.SubModules) { sb.Append(" ").Append(++i).Append(". ").AppendLine(sm.GetType().AssemblyQualifiedName); } } catch (Exception ex) { sb.Append(" *** ERROR: ").Append(ex.GetType().Name).Append(": ").AppendLine(ex.Message); } sb.AppendLine(); try { sb.AppendLine("System Info:"); sb.Append(" ").AppendLine(Utilities.GetPCInfo().Replace("\n", "\n ")); sb.Append($" GPU Memory: {Utilities.GetGPUMemoryMB()}MB").AppendLine(); sb.Append($" GC Allocated: {GC.GetTotalMemory(false)}B").AppendLine(); sb.Append($" Engine Memory Used: {Utilities.GetCurrentCpuMemoryUsageMB()}MB").AppendLine(); sb.Append(" GC Latency Mode: ").Append(GCSettings.IsServerGC ? "Server " : "Client ").AppendLine(GCSettings.LatencyMode.ToString()); sb.AppendFormat($" GC LOH Compact Mode: {GCSettings.LargeObjectHeapCompactionMode}").AppendLine(); sb.AppendFormat($" Operating System: {RuntimeInformation.OSDescription}").AppendLine(); sb.AppendFormat($" Framework Compatibility: {RuntimeInformation.FrameworkDescription}").AppendLine(); } catch (Exception ex) { sb.Append(" *** ERROR: ").Append(ex.GetType().Name).Append(": ").AppendLine(ex.Message); } try { var cpus = Cpu.Discover(); sb.AppendLine(" CPU Info:"); for (var i = 0; i < cpus.Length; ++i) { var cpu = cpus[i]; var coreCount = cpu.CoreClocks.Length; sb.Append(" ").Append(i + 1).Append(". ").Append(cpu.Name).Append(" with ").Append(coreCount).AppendLine(" cores:"); for (var c = 0; c < coreCount; ++c) { sb.Append(" ").Append(c + 1).Append(". ").Append(cpu.CoreClocks[c].Value).Append("MHz ") .Append(cpu.CoreTemperatures[c].Value).Append("°C"); sb.AppendLine(); } } } catch (Exception ex) { sb.Append(" *** ERROR: ").Append(ex.GetType().Name).Append(": ").AppendLine(ex.Message); } sb.AppendLine(); try { Input.SetClipboardText(sb.ToString()); ShowMessage("Diagnostics copied to system clipboard."); } catch (Exception ex) { ShowMessage($"Writing to system clipboard failed!\n{ex.GetType().Name}: {ex.Message}"); } }
private static void AppendSystemReport(StringBuilder sb) { if (_systemReportCache != null) { sb.Append(_systemReportCache); return; } var start = sb.Length; try { sb.AppendLine("System Info:"); sb.Append(" ").AppendLine(Utilities.GetPCInfo().Replace("\n", "\n ")); sb.Append($" GPU Memory: {Utilities.GetGPUMemoryMB()}MB").AppendLine(); sb.Append($" GC Allocated: {GC.GetTotalMemory(false)}B").AppendLine(); sb.Append($" Engine Memory Used: {Utilities.GetCurrentCpuMemoryUsageMB()}MB").AppendLine(); sb.Append(" GC Latency Mode: ").Append(GCSettings.IsServerGC ? "Server " : "Client ").AppendLine(GCSettings.LatencyMode.ToString()); sb.AppendFormat($" GC LOH Compact Mode: {GCSettings.LargeObjectHeapCompactionMode}").AppendLine(); sb.AppendFormat($" Operating System: {RuntimeInformation.OSDescription}").AppendLine(); sb.AppendFormat($" Framework Compatibility: {RuntimeInformation.FrameworkDescription}").AppendLine(); sb.AppendFormat($" Hardware Accelerated Vector: {(Vector.IsHardwareAccelerated ? "Yes" : "No")}").AppendLine(); sb.AppendFormat($" Vector Size: {Vector<byte>.Count * 8} bits").AppendLine(); } catch (Exception ex) { sb.Append(" *** ERROR: ").Append(ex.GetType().Name).Append(": ").AppendLine(ex.Message); } try { var cpus = Cpu.Discover(); sb.AppendLine(" CPU Info:"); for (var i = 0; i < cpus.Length; ++i) { var cpu = cpus[i]; cpu.Update(); var coreCount = cpu.CoreCount; for (var c = 0; c < coreCount; ++c) { cpu.ActivateSensor(cpu.CoreClocks[c]); cpu.ActivateSensor(cpu.CoreTemperatures[c]); } Thread.Sleep(100); sb.Append(" ").Append(i + 1).Append(". ").Append(cpu.Name).Append(" with ").Append(coreCount).AppendLine(" cores:"); for (var c = 0; c < coreCount; ++c) { sb.Append(" ").Append(c + 1).Append(". ") .Append(cpu.CoreClocks[c].Max?.ToString(CultureInfo.InvariantCulture) ?? "(?)").Append(" MHz ") .Append(cpu.CoreTemperatures[c].Max?.ToString(CultureInfo.InvariantCulture) ?? "(?)").Append(" °C"); sb.AppendLine(); } for (var c = 0; c < coreCount; ++c) { cpu.DeactivateSensor(cpu.CoreClocks[c]); cpu.DeactivateSensor(cpu.CoreTemperatures[c]); } } } catch (Exception ex) { sb.Append(" *** ERROR: ").Append(ex.GetType().Name).Append(": ").AppendLine(ex.Message); } sb.AppendLine(); try { _systemReportCache = sb.ToString(start, sb.Length - start); } catch { // out of memory? } }
// GET api/values public IEnumerable <Cpu> Get() { return(Cpu.Discover()); }
public Cpu[] GetCpus() { return(Cpu.Discover()); }