-
Notifications
You must be signed in to change notification settings - Fork 827
Expand file tree
/
Copy pathHardwareSummary.cs
More file actions
115 lines (102 loc) · 4.47 KB
/
HardwareSummary.cs
File metadata and controls
115 lines (102 loc) · 4.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
using System.Collections.Generic;
using System;
namespace Opserver.Data.Dashboard
{
public partial class Node
{
public HardwareSummary Hardware { get; internal set; }
}
public class HardwareSummary
{
public List<ProcessorInfo> Processors { get; internal set; } = new List<ProcessorInfo>();
public List<MemoryModuleInfo> MemoryModules { get; internal set; } = new List<MemoryModuleInfo>();
public List<ComponentInfo> Components { get; internal set; } = new List<ComponentInfo>();
public StorageInfo Storage { get; internal set; } = new StorageInfo();
public List<TemperatureInfo> Temps { get; internal set; } = new List<TemperatureInfo>();
public List<PowerSupplyInfo> PowerSupplies { get; internal set; } = new List<PowerSupplyInfo>();
public BoardPowerInfo BoardPowerReading { get; internal set; } = new BoardPowerInfo();
public class ComponentInfo : IMonitorStatus
{
public string Name { get; internal set; }
public string Status { get; internal set; }
public MonitorStatus MonitorStatus => Status == "Ok" ? MonitorStatus.Good : MonitorStatus.Warning;
public string MonitorStatusReason => "Status is " + Status;
}
public class ProcessorInfo
{
public string Name { get; internal set; }
public string Description { get; internal set; }
}
public class MemoryModuleInfo : ComponentInfo
{
public string Size { get; internal set; }
public string PrettyName => Name?.Replace("DIMM_", "");
private string _bank;
public string Bank => _bank ??= Name?.TrimEnd(StringSplits.Numbers);
private int? _label;
public int? Label
{
get
{
if (!_label.HasValue)
{
if (Bank == null) return null;
if (Name.Length > Bank.Length)
{
if (int.TryParse(Name.AsSpan(Bank.Length), out int position))
{
_label = position;
}
}
}
return _label;
}
}
}
public class StorageInfo
{
public List<ControllerInfo> Controllers { get; internal set; } = new List<ControllerInfo>();
public List<PhysicalDiskInfo> PhysicalDisks { get; internal set; } = new List<PhysicalDiskInfo>();
public List<VirtualDiskInfo> VirtualDisks { get; internal set; } = new List<VirtualDiskInfo>();
public List<ComponentInfo> Batteries { get; internal set; } = new List<ComponentInfo>();
public class ControllerInfo : ComponentInfo
{
public string SlotId { get; internal set; }
public string State { get; internal set; }
public string FirmwareVersion { get; internal set; }
public string DriverVersion { get; internal set; }
}
public class PhysicalDiskInfo : ComponentInfo
{
public string Media { get; internal set; }
public string Capacity { get; internal set; }
public string VendorId { get; internal set; }
public string ProductId { get; internal set; }
public string Serial { get; internal set; }
public string Part { get; internal set; }
public string NegotatiedSpeed { get; internal set; }
public string CapableSpeed { get; internal set; }
public string SectorSize { get; internal set; }
}
public class VirtualDiskInfo : ComponentInfo
{
public long Size { get; internal set; }
}
}
public class TemperatureInfo : ComponentInfo
{
public double Celsius { get; internal set; }
}
public class PowerSupplyInfo : ComponentInfo
{
public double Amps { get; internal set; }
public double Volts { get; internal set; }
public string RatedInputWattage { get; internal set; }
public string RatedOutputWattage { get; internal set; }
}
public class BoardPowerInfo
{
public double Watts { get; internal set; }
}
}
}