forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemorymetrics.go
216 lines (196 loc) · 10 KB
/
memorymetrics.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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"github.com/stmcginnis/gofish/common"
)
// AlarmTrips shall contain properties describing the types of alarms that have
// been raised by the memory. These alarms shall be reset when the system
// resets. Note that if they are re-discovered they can be reasserted.
type AlarmTrips struct {
// AddressParityError shall be true if an Address Parity Error was detected
// which could not be corrected by retry.
AddressParityError bool
// CorrectableECCError shall be true if the correctable error threshold
// crossing alarm trip was detected.
CorrectableECCError bool
// SpareBlock shall be true if the spare block capacity crossing alarm trip
// was detected.
SpareBlock bool
// Temperature shall be true if a temperature threshold alarm trip was detected.
Temperature bool
// UncorrectableECCError shall be true if the uncorrectable error threshold
// alarm trip was detected.
UncorrectableECCError bool
}
// AlertCapabilities shall contain the conditions that would generate an alert to the CXL Fabric Manager or host.
type AlertCapabilities struct {
// CorrectableECCError shall indicate whether correctable ECC errors generate an alert to the CXL Fabric Manager or
// host.
CorrectableECCError bool
// SpareBlock shall indicate whether spare block conditions generate an alert to the CXL Fabric Manager or host.
SpareBlock bool
// Temperature shall indicate whether temperature conditions generate an alert to the CXL Fabric Manager or host.
Temperature bool
// UncorrectableECCError shall indicate whether uncorrectable ECC errors generate an alert to the CXL Fabric
// Manager or host.
UncorrectableECCError bool
}
// CXLMemoryMetrics shall contain the memory metrics specific to CXL devices.
type CXLMemoryMetrics struct {
// AlertCapabilities shall contain the conditions that would generate an alert to the CXL Fabric Manager or host.
AlertCapabilities AlertCapabilities
}
// CurrentPeriod shall describe the metrics of the memory since last time the
// ClearCurrentPeriod Action was performed or the system reset.
type CurrentPeriod struct {
// BlocksRead shall be number of blocks read since reset.
BlocksRead uint
// BlocksWritten shall be number of blocks written since reset.
BlocksWritten uint
// CorrectableECCErrorCount shall contain the number of correctable errors since reset. When this resource is
// subordinate to the MemorySummary object, this property shall be the sum of CorrectableECCErrorCount over all
// memory.
CorrectableECCErrorCount int
// IndeterminateCorrectableErrorCount shall contain the number of indeterminate correctable errors since reset.
// Since the error origin is indeterminate, the same error can be duplicated across multiple MemoryMetrics
// resources. When this resource is subordinate to the MemorySummary object, this property shall be the sum of
// indeterminate correctable errors across all memory without duplication, which may not be the sum of all
// IndeterminateCorrectableErrorCount properties over all memory.
IndeterminateCorrectableErrorCount int
// IndeterminateUncorrectableErrorCount shall contain the number of indeterminate uncorrectable errors since reset.
// Since the error origin is indeterminate, the same error can be duplicated across multiple MemoryMetrics
// resources. When this resource is subordinate to the MemorySummary object, this property shall be the sum of
// indeterminate uncorrectable errors across all memory without duplication, which may not be the sum of all
// IndeterminateUncorrectableErrorCount properties over all memory.
IndeterminateUncorrectableErrorCount int
// UncorrectableECCErrorCount shall contain the number of uncorrectable errors since reset. When this resource is
// subordinate to the MemorySummary object, this property shall be the sum of UncorrectableECCErrorCount over all
// memory.
UncorrectableECCErrorCount int
}
// HealthData shall contain properties which describe the HealthData metrics for
// the current resource.
type HealthData struct {
// AlarmTrips shall contain properties describe the types of alarms that
// have been raised by the memory.
AlarmTrips AlarmTrips
// DataLossDetected shall be data loss detection status, with true
// indicating data loss detected.
DataLossDetected bool
// LastShutdownSuccess shall be the status of the last shutdown, with true
// indicating success.
LastShutdownSuccess bool
// PerformanceDegraded shall be performance degraded mode status, with true
// indicating performance degraded.
PerformanceDegraded bool
// PredictedMediaLifeLeftPercent shall contain an indicator
// of the percentage of life remaining in the media.
PredictedMediaLifeLeftPercent float32
// RemainingSpareBlockPercentage shall be the remaining spare blocks in percentage.
RemainingSpareBlockPercentage float32
}
// LifeTime shall describe the metrics of the memory since manufacturing.
type LifeTime struct {
// BlocksRead shall be number of blocks read for the lifetime of the Memory.
BlocksRead uint64
// BlocksWritten shall be number of blocks written for the lifetime of the Memory.
BlocksWritten uint64
// CorrectableECCErrorCount shall contain the number of correctable errors for the lifetime of the memory. When
// this resource is subordinate to the MemorySummary object, this property shall be the sum of
// CorrectableECCErrorCount over all memory.
CorrectableECCErrorCount int
// IndeterminateCorrectableErrorCount shall contain the number of indeterminate correctable errors for the lifetime
// of the memory. Since the error origin is indeterminate, the same error can be duplicated across multiple
// MemoryMetrics resources. When this resource is subordinate to the MemorySummary object, this property shall be
// the sum of indeterminate correctable errors across all memory without duplication, which may not be the sum of
// all IndeterminateCorrectableErrorCount properties over all memory.
IndeterminateCorrectableErrorCount int
// IndeterminateUncorrectableErrorCount shall contain the number of indeterminate uncorrectable errors for the
// lifetime of the memory. Since the error origin is indeterminate, the same error can be duplicated across
// multiple MemoryMetrics resources. When this resource is subordinate to the MemorySummary object, this property
// shall be the sum of indeterminate uncorrectable errors across all memory without duplication, which may not be
// the sum of all IndeterminateUncorrectableErrorCount properties over all memory.
IndeterminateUncorrectableErrorCount int
// UncorrectableECCErrorCount shall contain the number of uncorrectable errors for the lifetime of the memory. When
// this resource is subordinate to the MemorySummary object, this property shall be the sum of
// UncorrectableECCErrorCount over all memory.
UncorrectableECCErrorCount int
}
// MemoryMetrics is used to represent the Memory Metrics for a single Memory
// device in a Redfish implementation.
type MemoryMetrics struct {
common.Entity
// ODataContext is the odata context.
ODataContext string `json:"@odata.context"`
// ODataType is the odata type.
ODataType string `json:"@odata.type"`
// BandwidthPercent shall contain memory bandwidth utilization as a
// percentage. When this resource is subordinate to the MemorySummary
// object, this property shall be the memory bandwidth utilization over all
// memory as a percentage.
BandwidthPercent float32
// BlockSizeBytes shall be the block size in bytes of all structure elements.
BlockSizeBytes int
// CXL shall contain the memory metrics specific to CXL devices.
CXL CXLMemoryMetrics
// CapacityUtilizationPercent shall contain the memory capacity utilization as a percentage, typically '0' to
// '100'. When this resource is subordinate to the MemorySummary object, this property shall be the memory capacity
// utilization over all memory as a percentage.
CapacityUtilizationPercent float64
// CorrectedPersistentErrorCount shall contain the number of corrected errors in persistent memory.
CorrectedPersistentErrorCount int
// CorrectedVolatileErrorCount shall contain the number of corrected errors in volatile memory.
CorrectedVolatileErrorCount int
// CurrentPeriod shall contain properties which describe the CurrentPeriod
// metrics for the current resource.
CurrentPeriod CurrentPeriod
// Description provides a description of this resource.
Description string
// DirtyShutdownCount shall contain the number of shutdowns while outstanding writes have not completed to
// persistent memory.
DirtyShutdownCount int
// HealthData shall contain properties which describe the HealthData metrics
// for the current resource.
HealthData HealthData
// LifeTime shall contain properties which describe the LifeTime metrics for
// the current resource.
LifeTime LifeTime
// OperatingSpeedMHz is used by the memory device.
OperatingSpeedMHz int
clearCurrentPeriodTarget string
}
// UnmarshalJSON unmarshals a MemoryMetrics object from the raw JSON.
func (memorymetrics *MemoryMetrics) UnmarshalJSON(b []byte) error {
type temp MemoryMetrics
type Actions struct {
ClearCurrentPeriod common.ActionTarget `json:"#MemoryMetrics.ClearCurrentPeriod"`
}
var t struct {
temp
Actions Actions
}
err := json.Unmarshal(b, &t)
if err != nil {
return err
}
*memorymetrics = MemoryMetrics(t.temp)
// Extract the links to other entities for later
memorymetrics.clearCurrentPeriodTarget = t.Actions.ClearCurrentPeriod.Target
return nil
}
// ClearCurrentPeriod sets the CurrentPeriod property's values to 0.
func (memorymetrics *MemoryMetrics) ClearCurrentPeriod() error {
return memorymetrics.Post(memorymetrics.clearCurrentPeriodTarget, nil)
}
// GetMemoryMetrics will get a MemoryMetrics instance from the service.
func GetMemoryMetrics(c common.Client, uri string) (*MemoryMetrics, error) {
return common.GetObject[MemoryMetrics](c, uri)
}
// ListReferencedMemoryMetricss gets the collection of MemoryMetrics from
// a provided reference.
func ListReferencedMemoryMetricss(c common.Client, link string) ([]*MemoryMetrics, error) {
return common.GetCollectionObjects[MemoryMetrics](c, link)
}