-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdmi.go
398 lines (365 loc) · 10.8 KB
/
dmi.go
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
package dmijson
import (
"encoding/json"
)
//go:generate sudo bin/dmij -f test.json
//go:generate go-bindata -pkg=dmijson bin
type BaseBoardInformation struct {
Manufacturer string
ProductName string
Version string
SerialNumber string
AssetTag string
Features []string
LocationInChassis string
ChassisHandle string
Type string
ContainedObjectHandles int
}
type BIOSInformation struct {
Vendor string
Version string
ReleaseDate string
Address string
RuntimeSize string
ROMSize string
Characteristics []string
BIOSRevision string
}
type BIOSLanguageInformation struct {
LanguageDescriptionFormat string
InstallableLanguages int
CurrentlyInstalledLanguage string
}
type CacheInformation struct {
SocketDesignation string
Configuration string
OperationalMode string
Location string
InstalledSize string
MaximumSize string
SupportedSRAMTypes []string
InstalledSRAMType string
Speed string
ErrorCorrectionType string
SystemType string
Associativity string
}
type ChassisInformation struct {
Manufacturer string
Type string
Lock string
Version string
SerialNumber string
AssetTag string
BootupState string
PowerSupplyState string
ThermalState string
SecurityStatus string
OEMInformation string
Height string
NumberOfPowerCords int
ContainedElements int
SKUNumber string
}
type CoolingDevice struct {
TemperatureProbeHandle string
Type string
Status string
CoolingUnitGroup int
OEMspecificInformation string
NominalSpeed string
Description string
}
type ElectricalCurrentProbe struct {
Description string
Location string
Status string
MaximumValue string
MinimumValue string
Resolution string
Tolerance string
Accuracy string
OEMspecificInformation string
NominalValue string
}
type IPMIDeviceInformation struct {
InterfaceType string
SpecificationVersion string
I2CSlaveAddress string
NVStorageDevice string
BaseAddress string
RegisterSpacing string
}
type ManagementDevice struct {
Description string
Type string
Address string
AddressType string
}
type ManagementDeviceComponent struct {
Description string
ManagementDeviceHandle string
ComponentHandle string
ThresholdHandle string
}
type ManagementDeviceThresholdData struct {
LowerNoncriticalThreshold int
UpperNoncriticalThreshold int
LowerCriticalThreshold int
UpperCriticalThreshold int
LowerNonrecoverableThreshold int
UpperNonrecoverableThreshold int
}
type MemoryArrayMappedAddress struct {
StartingAddress string
EndingAddress string
RangeSize string
PhysicalArrayHandle string
PartitionWidth int
}
type MemoryDevice struct {
ArrayHandle string
ErrorInformationHandle string
TotalWidth string
DataWidth string
Size string
FormFactor string
Set string
Locator string
BankLocator string
Type string
TypeDetail string
Speed string
Manufacturer string
SerialNumber string
AssetTag string
PartNumber string
Rank string
ConfiguredClockSpeed string
}
type MemoryDeviceMappedAddress struct {
StartingAddress string
EndingAddress string
RangeSize string
PhysicalDeviceHandle string
MemoryArrayMappedAddressHandle string
PartitionRowPosition int
}
type OEMStrings map[string]string
type OnboardDevice struct {
ReferenceDesignation string
Type string
Status string
TypeInstance int
BusAddress string
}
type OnBoardDeviceInformation struct {
Type string
Status string
Description string
}
type PhysicalMemoryArray struct {
Location string
Use string
ErrorCorrectionType string
MaximumCapacity string
ErrorInformationHandle string
NumberOfDevices int
}
type PortConnectorInformation struct {
InternalReferenceDesignator string
InternalConnectorType string
ExternalReferenceDesignator string
ExternalConnectorType string
PortType string
}
type ProcessorInformation struct {
SocketDesignation string
Type string
Family string
Manufacturer string
ID string
Signature string
Flags []string
Version string
Voltage string
ExternalClock string
MaxSpeed string
CurrentSpeed string
Status string
Upgrade string
L1CacheHandle string
L2CacheHandle string
L3CacheHandle string
SerialNumber string
AssetTag string
PartNumber string
CoreCount int
CoreEnabled int
ThreadCount int
Characteristics []string
}
type SystemBootInformation struct {
Status string
}
type SystemConfigurationOptions struct {
Option1 string
}
type SystemEventLog struct {
AreaLength string
HeaderStartOffset string
HeaderLength string
DataStartOffset string
AccessMethod string
AccessAddress string
Status string
ChangeToken string
HeaderFormat string
SupportedLogTypeDescriptors int
Descriptor1 string
DataFormat1 string
Descriptor2 string
DataFormat2 string
Descriptor3 string
DataFormat3 string
Descriptor4 string
DataFormat4 string
Descriptor5 string
DataFormat5 string
Descriptor6 string
DataFormat6 string
Descriptor7 string
DataFormat7 string
Descriptor8 string
DataFormat8 string
Descriptor9 string
DataFormat9 string
Descriptor10 string
DataFormat10 string
Descriptor11 string
DataFormat11 string
Descriptor12 string
DataFormat12 string
Descriptor13 string
DataFormat13 string
Descriptor14 string
DataFormat14 string
Descriptor15 string
DataFormat15 string
Descriptor16 string
DataFormat16 string
Descriptor17 string
DataFormat17 string
Descriptor18 string
DataFormat18 string
Descriptor19 string
DataFormat19 string
Descriptor20 string
DataFormat20 string
Descriptor21 string
DataFormat21 string
Descriptor22 string
DataFormat22 string
Descriptor23 string
DataFormat23 string
Descriptor24 string
DataFormat24 string
Descriptor25 string
DataFormat25 string
}
type SystemInformation struct {
Manufacturer string
ProductName string
Version string
SerialNumber string
UUID string
WakeupType string
SKUNumber string
Family string
}
type SystemPowerSupply struct {
PowerUnitGroup int
Location string
Name string
Manufacturer string
SerialNumber string
AssetTag string
ModelPartNumber string
Revision string
MaxPowerCapacity string
Status string
Type string
InputVoltageRangeSwitching string
Plugged string
HotReplaceable string
InputVoltageProbeHandle string
CoolingDeviceHandle string
InputCurrentProbeHandle string
}
type SystemSlotInformation struct {
Designation string
Type string
CurrentUsage string
Length string
ID int
Characteristics []string
BusAddress string
}
type Probe struct {
Description string
Location string
Status string
MaximumValue string
MinimumValue string
Resolution string
Tolerance string
Accuracy string
OEMspecificInformation string
NominalValue string
}
type DMI struct {
BaseBoardInformation BaseBoardInformation
BIOSInformation BIOSInformation
BIOSLanguageInformation BIOSLanguageInformation
CacheInformation []CacheInformation
ChassisInformation ChassisInformation
CoolingDevice []CoolingDevice
ElectricalCurrentProbe []ElectricalCurrentProbe
IPMIDeviceInformation IPMIDeviceInformation
ManagementDevice []ManagementDevice
ManagementDeviceComponent []ManagementDeviceComponent
ManagementDeviceThresholdData []ManagementDeviceThresholdData
MemoryArrayMappedAddress []MemoryArrayMappedAddress
MemoryDevice []MemoryDevice
MemoryDeviceMappedAddress []MemoryDeviceMappedAddress
OEMStrings OEMStrings
OnboardDevice []OnboardDevice
OnBoardDevice1Information OnBoardDeviceInformation
OnBoardDevice2Information OnBoardDeviceInformation
OnBoardDevice3Information OnBoardDeviceInformation
OnBoardDevice4Information OnBoardDeviceInformation
PhysicalMemoryArray []PhysicalMemoryArray
PortConnectorInformation []PortConnectorInformation
ProcessorInformation []ProcessorInformation
SystemBootInformation SystemBootInformation
SystemConfigurationOptions SystemConfigurationOptions
SystemEventLog SystemEventLog
SystemInformation SystemInformation
SystemPowerSupply SystemPowerSupply
SystemSlotInformation []SystemSlotInformation
TemperatureProbe []Probe
VoltageProbe []Probe
}
func FromJSON(j string) (DMI, error) {
d := DMI{}
return d, json.Unmarshal([]byte(j), &d)
}
func (d DMI) ToJSON() string {
j, _ := json.MarshalIndent(d, " ", " ")
return string(j)
}
func Script() (string, error) {
s, err := Asset("bin/dmij")
return string(s), err
}