forked from k-sone/ipmigo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsensor.go
208 lines (198 loc) · 3.38 KB
/
sensor.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
package ipmigo
import (
"fmt"
)
type ThresholdStatus string
const (
// Normal operating ranges
ThresholdStatusOK ThresholdStatus = "ok"
// Lower Non-Recoverable
ThresholdStatusLNR ThresholdStatus = "lnr"
// Lower Critical
ThresholdStatusLCR ThresholdStatus = "lcr"
// Lower Non-Critical
ThresholdStatusLNC ThresholdStatus = "lnc"
// Upper Non-Recoverable
ThresholdStatusUNR ThresholdStatus = "unr"
// Upper Critical
ThresholdStatusUCR ThresholdStatus = "ucr"
// Upper Non-Critical
ThresholdStatusUNC ThresholdStatus = "unc"
)
// Returns threshold status of threshold-base sensor.
func NewThresholdStatus(status uint8) ThresholdStatus {
if status&0x04 != 0 {
return ThresholdStatusLNR
} else if status&0x20 != 0 {
return ThresholdStatusUNR
} else if status&0x02 != 0 {
return ThresholdStatusLCR
} else if status&0x10 != 0 {
return ThresholdStatusUCR
} else if status&0x01 != 0 {
return ThresholdStatusLNC
} else if status&0x08 != 0 {
return ThresholdStatusUNC
} else {
return ThresholdStatusOK
}
}
// Sensor Type (Table 42-3)
type SensorType uint8
var sensorTypeDescriptions []string = []string{
"reserved",
"Temperature",
"Voltage",
"Current",
"Fan",
"Physical Security",
"Platform Security",
"Processor",
"Power Supply",
"Power Unit",
"Cooling Device",
"Other Units-based Sensor",
"Memory",
"Drive Slot",
"POST Memory Resize",
"System Firmware",
"Event Logging Disabled",
"Watchdog 1",
"System Event",
"Critical Interrupt",
"Button / Switch",
"Module / Board",
"Microcontroller",
"Add-in Card",
"Chassis",
"Chip Set",
"Other FRU",
"Cable / Interconnect",
"Terminator",
"System Boot Initiated",
"Boot Error",
"OS Boot",
"OS Stop",
"Slot / Connector",
"System ACPI Power State",
"Watchdog 2",
"Platform Alert",
"Entity Presence",
"Monitor ASIC",
"LAN",
"Management Subsystem Health",
"Battery",
"Session Audit",
"Version Change",
"FRU State",
}
func (t SensorType) String() string {
if i := int(t); i < len(sensorTypeDescriptions) {
return sensorTypeDescriptions[i]
} else if i < 0xc0 {
return fmt.Sprintf("Reserved(%d)", i)
} else {
return fmt.Sprintf("OEM RESERVED(%d)", i)
}
}
// Sensor Unit Type (Section 43.17)
type UnitType uint8
var unitDescriptions []string = []string{
"unspecified",
"degrees C",
"degrees F",
"degrees K",
"Volts",
"Amps",
"Watts",
"Joules",
"Coulombs",
"VA",
"Nits",
"lumen",
"lux",
"Candela",
"kPa",
"PSI",
"Newton",
"CFM",
"RPM",
"Hz",
"microsecond",
"millisecond",
"second",
"minute",
"hour",
"day",
"week",
"mil",
"inches",
"feet",
"cu in",
"cu feet",
"mm",
"cm",
"m",
"cu cm",
"cu m",
"liters",
"fluid ounce",
"radians",
"steradians",
"revolutions",
"cycles",
"gravities",
"ounce",
"pound",
"ft-lb",
"oz-in",
"gauss",
"gilberts",
"henry",
"millihenry",
"farad",
"microfarad",
"ohms",
"siemens",
"mole",
"becquerel",
"PPM",
"reserved",
"Decibels",
"DbA",
"DbC",
"gray",
"sievert",
"color temp deg K",
"bit",
"kilobit",
"megabit",
"gigabit",
"byte",
"kilobyte",
"megabyte",
"gigabyte",
"word",
"dword",
"qword",
"line",
"hit",
"miss",
"retry",
"reset",
"overflow",
"underrun",
"collision",
"packets",
"messages",
"characters",
"error",
"correctable error",
"uncorrectable error",
}
func (u UnitType) String() string {
if i := int(u); i < len(unitDescriptions) {
return unitDescriptions[i]
}
return fmt.Sprint("unknown(%d)", u)
}