@cryptotaxi247 / netdata-1 / commits / 623244f8a

go.d storcli update (#17460)

Ilya Mashchenko committed Apr 20, 2024 at 19:20 UTC 623244f8a9dc134c37599d1e07e7792c9f193583
7 files changed +174 -21
src/go/collectors/go.d.plugin/modules/storcli/charts.go
+43 -2
@@ -18,6 +18,8 @@ const (
18 prioPhysDrivePredictiveFailures
19 prioPhysDriveSmartAlertStatus
20 prioPhysDriveTemperature
21 +
22 + prioBBUTemperature
23 )
24
25 var controllerChartsTmpl = module.Charts{
@@ -106,7 +108,7 @@ var (
108 physDriveTemperatureChartTmpl = module.Chart{
109 ID: "phys_drive_%s_cntrl_%s_temperature",
110 Title: "Physical Drive temperature",
109 - Units: "status",
111 + Units: "Celsius",
112 Fam: "pd temperature",
113 Ctx: "storcli.phys_drive_temperature",
114 Type: module.Line,
@@ -117,6 +119,25 @@ var (
119 }
120 )
121
122 +var bbuChartsTmpl = module.Charts{
123 + bbuTemperatureChartTmpl.Copy(),
124 +}
125 +
126 +var (
127 + bbuTemperatureChartTmpl = module.Chart{
128 + ID: "bbu_%s_cntrl_%s_temperature",
129 + Title: "BBU temperature",
130 + Units: "Celsius",
131 + Fam: "bbu temperature",
132 + Ctx: "storcli.bbu_temperature",
133 + Type: module.Line,
134 + Priority: prioBBUTemperature,
135 + Dims: module.Dims{
136 + {ID: "bbu_%s_cntrl_%s_temperature", Name: "temperature"},
137 + },
138 + }
139 +)
140 +
141 func (s *StorCli) addControllerCharts(cntrl controllerInfo) {
142 charts := controllerChartsTmpl.Copy()
143
@@ -141,7 +162,7 @@ func (s *StorCli) addControllerCharts(cntrl controllerInfo) {
162 func (s *StorCli) addPhysDriveCharts(cntrlNum int, di *driveInfo, ds *driveState, da *driveAttrs) {
163 charts := physDriveChartsTmpl.Copy()
164
144 - if _, ok := parseInt(getDriveTemperature(ds.DriveTemperature)); !ok {
165 + if _, ok := parseInt(getTemperature(ds.DriveTemperature)); !ok {
166 _ = charts.Remove(physDriveTemperatureChartTmpl.ID)
167 }
168
@@ -169,3 +190,23 @@ func (s *StorCli) addPhysDriveCharts(cntrlNum int, di *driveInfo, ds *driveState
190 s.Warning(err)
191 }
192 }
193 +
194 +func (s *StorCli) addBBUCharts(cntrlNum, bbuNum, model string) {
195 + charts := bbuChartsTmpl.Copy()
196 +
197 + for _, chart := range *charts {
198 + chart.ID = fmt.Sprintf(chart.ID, bbuNum, cntrlNum)
199 + chart.Labels = []module.Label{
200 + {Key: "controller_number", Value: cntrlNum},
201 + {Key: "bbu_number", Value: bbuNum},
202 + {Key: "model", Value: model},
203 + }
204 + for _, dim := range chart.Dims {
205 + dim.ID = fmt.Sprintf(dim.ID, bbuNum, cntrlNum)
206 + }
207 + }
208 +
209 + if err := s.Charts().Add(*charts...); err != nil {
210 + s.Warning(err)
211 + }
212 +}
src/go/collectors/go.d.plugin/modules/storcli/collect_controllers.go
+20 -4
@@ -47,13 +47,14 @@ func (s *StorCli) collectControllersInfo(mx map[string]int64, resp *controllersI
47 for _, v := range resp.Controllers {
48 cntrl := v.ResponseData
49
50 - idx := strconv.Itoa(cntrl.Basics.Controller)
51 - if !s.controllers[idx] {
52 - s.controllers[idx] = true
50 + cntrlNum := strconv.Itoa(cntrl.Basics.Controller)
51 +
52 + if !s.controllers[cntrlNum] {
53 + s.controllers[cntrlNum] = true
54 s.addControllerCharts(cntrl)
55 }
56
56 - px := fmt.Sprintf("cntrl_%s_", idx)
57 + px := fmt.Sprintf("cntrl_%s_", cntrlNum)
58
59 for _, st := range []string{"optimal", "degraded", "partially_degraded", "failed"} {
60 mx[px+"status_"+st] = 0
@@ -72,7 +73,22 @@ func (s *StorCli) collectControllersInfo(mx map[string]int64, resp *controllersI
73 default:
74 mx[px+"bbu_status_unhealthy"] = 1
75 }
76 +
77 + for i, bbu := range cntrl.BBUInfo {
78 + bbuNum := strconv.Itoa(i)
79 + if k := cntrlNum + bbuNum; !s.bbu[k] {
80 + s.bbu[k] = true
81 + s.addBBUCharts(cntrlNum, bbuNum, bbu.Model)
82 + }
83 +
84 + px := fmt.Sprintf("bbu_%s_cntrl_%s_", bbuNum, cntrlNum)
85 +
86 + if v, ok := parseInt(getTemperature(bbu.Temp)); ok {
87 + mx[px+"temperature"] = v
88 + }
89 + }
90 }
91 +
92 return nil
93 }
94
src/go/collectors/go.d.plugin/modules/storcli/collect_drives.go
+7 -5
@@ -112,7 +112,7 @@ func (s *StorCli) collectMegaRaidDrives(mx map[string]int64, resp *drivesInfoRes
112 if v, ok := parseInt(string(state.PredictiveFailureCount)); ok {
113 mx[px+"predictive_failure_count"] = v
114 }
115 - if v, ok := parseInt(getDriveTemperature(state.DriveTemperature)); ok {
115 + if v, ok := parseInt(getTemperature(state.DriveTemperature)); ok {
116 mx[px+"temperature"] = v
117 }
118 for _, st := range []string{"active", "inactive"} {
@@ -120,6 +120,8 @@ func (s *StorCli) collectMegaRaidDrives(mx map[string]int64, resp *drivesInfoRes
120 }
121 if state.SmartAlertFlagged == "Yes" {
122 mx[px+"smart_alert_status_active"] = 1
123 + } else {
124 + mx[px+"smart_alert_status_inactive"] = 1
125 }
126 }
127 }
@@ -216,13 +218,13 @@ func getDriveAttrs(driveDetailedInfo map[string]json.RawMessage, id string) (*dr
218 return &state, nil
219 }
220
219 -func getDriveTemperature(s string) string {
220 - // ' 28C (82.40 F)'
221 - i := strings.IndexByte(s, 'C')
221 +func getTemperature(temp string) string {
222 + // ' 28C (82.40 F)' (drive) or '33C' (bbu)
223 + i := strings.IndexByte(temp, 'C')
224 if i == -1 {
225 return ""
226 }
225 - return strings.TrimSpace(s[:i])
227 + return strings.TrimSpace(temp[:i])
228 }
229
230 func parseInt(s string) (int64, bool) {
src/go/collectors/go.d.plugin/modules/storcli/metadata.yaml
+34 -2
@@ -80,7 +80,23 @@ modules:
80 troubleshooting:
81 problems:
82 list: []
83 - alerts: []
83 + alerts:
84 + - name: storcli_controller_status
85 + metric: storcli.controller_status
86 + info: RAID controller ${label:controller_number} health status is not optimal
87 + link: https://github.com/netdata/netdata/blob/master/src/health/health.d/storcli.conf
88 + - name: storcli_controller_bbu_status
89 + metric: storcli.controller_bbu_status
90 + info: RAID controller ${label:controller_number} BBU is unhealthy
91 + link: https://github.com/netdata/netdata/blob/master/src/health/health.d/storcli.conf
92 + - name: storcli_phys_drive_errors
93 + metric: storcli.phys_drive_errors
94 + info: RAID physical drive c${label:controller_number}/e${label:enclosure_number}/s${label:slot_number} errors
95 + link: https://github.com/netdata/netdata/blob/master/src/health/health.d/storcli.conf
96 + - name: storcli_phys_drive_predictive_failures
97 + metric: storcli.phys_drive_predictive_failures
98 + info: RAID physical drive c${label:controller_number}/e${label:enclosure_number}/s${label:slot_number} predictive failures
99 + link: https://github.com/netdata/netdata/blob/master/src/health/health.d/storcli.conf
100 metrics:
101 folding:
102 title: Metrics
@@ -147,7 +163,23 @@ modules:
163 - name: inactive
164 - name: storcli.phys_drive_temperature
165 description: Physical Drive temperature
150 - unit: status
166 + unit: Celsius
167 + chart_type: line
168 + dimensions:
169 + - name: temperature
170 + - name: bbu
171 + description: These metrics refer to the Backup Battery Unit.
172 + labels:
173 + - name: controller_number
174 + description: Controller number (index)
175 + - name: bbu_number
176 + description: BBU number (index)
177 + - name: model
178 + description: BBU model
179 + metrics:
180 + - name: storcli.bbu_temperature
181 + description: BBU temperature
182 + unit: Celsius
183 chart_type: line
184 dimensions:
185 - name: temperature
src/go/collectors/go.d.plugin/modules/storcli/storcli_test.go
+8 -7
@@ -147,8 +147,9 @@ func TestStorCli_Collect(t *testing.T) {
147 }{
148 "success MegaRAID controller": {
149 prepareMock: prepareMockMegaRaidOK,
150 - wantCharts: len(controllerChartsTmpl)*1 + len(physDriveChartsTmpl)*6,
150 + wantCharts: len(controllerChartsTmpl)*1 + len(physDriveChartsTmpl)*6 + len(bbuChartsTmpl)*1,
151 wantMetrics: map[string]int64{
152 + "bbu_0_cntrl_0_temperature": 34,
153 "cntrl_0_bbu_status_healthy": 1,
154 "cntrl_0_bbu_status_na": 0,
155 "cntrl_0_bbu_status_unhealthy": 0,
@@ -160,37 +161,37 @@ func TestStorCli_Collect(t *testing.T) {
161 "phys_drive_5000C500C36C8BCD_cntrl_0_other_error_count": 0,
162 "phys_drive_5000C500C36C8BCD_cntrl_0_predictive_failure_count": 0,
163 "phys_drive_5000C500C36C8BCD_cntrl_0_smart_alert_status_active": 0,
163 - "phys_drive_5000C500C36C8BCD_cntrl_0_smart_alert_status_inactive": 0,
164 + "phys_drive_5000C500C36C8BCD_cntrl_0_smart_alert_status_inactive": 1,
165 "phys_drive_5000C500C36C8BCD_cntrl_0_temperature": 28,
166 "phys_drive_5000C500D59840FE_cntrl_0_media_error_count": 0,
167 "phys_drive_5000C500D59840FE_cntrl_0_other_error_count": 0,
168 "phys_drive_5000C500D59840FE_cntrl_0_predictive_failure_count": 0,
169 "phys_drive_5000C500D59840FE_cntrl_0_smart_alert_status_active": 0,
169 - "phys_drive_5000C500D59840FE_cntrl_0_smart_alert_status_inactive": 0,
170 + "phys_drive_5000C500D59840FE_cntrl_0_smart_alert_status_inactive": 1,
171 "phys_drive_5000C500D59840FE_cntrl_0_temperature": 28,
172 "phys_drive_5000C500D6061539_cntrl_0_media_error_count": 0,
173 "phys_drive_5000C500D6061539_cntrl_0_other_error_count": 0,
174 "phys_drive_5000C500D6061539_cntrl_0_predictive_failure_count": 0,
175 "phys_drive_5000C500D6061539_cntrl_0_smart_alert_status_active": 0,
175 - "phys_drive_5000C500D6061539_cntrl_0_smart_alert_status_inactive": 0,
176 + "phys_drive_5000C500D6061539_cntrl_0_smart_alert_status_inactive": 1,
177 "phys_drive_5000C500D6061539_cntrl_0_temperature": 28,
178 "phys_drive_5000C500DC79B194_cntrl_0_media_error_count": 0,
179 "phys_drive_5000C500DC79B194_cntrl_0_other_error_count": 0,
180 "phys_drive_5000C500DC79B194_cntrl_0_predictive_failure_count": 0,
181 "phys_drive_5000C500DC79B194_cntrl_0_smart_alert_status_active": 0,
181 - "phys_drive_5000C500DC79B194_cntrl_0_smart_alert_status_inactive": 0,
182 + "phys_drive_5000C500DC79B194_cntrl_0_smart_alert_status_inactive": 1,
183 "phys_drive_5000C500DC79B194_cntrl_0_temperature": 28,
184 "phys_drive_5000C500E54F4EBB_cntrl_0_media_error_count": 0,
185 "phys_drive_5000C500E54F4EBB_cntrl_0_other_error_count": 0,
186 "phys_drive_5000C500E54F4EBB_cntrl_0_predictive_failure_count": 0,
187 "phys_drive_5000C500E54F4EBB_cntrl_0_smart_alert_status_active": 0,
187 - "phys_drive_5000C500E54F4EBB_cntrl_0_smart_alert_status_inactive": 0,
188 + "phys_drive_5000C500E54F4EBB_cntrl_0_smart_alert_status_inactive": 1,
189 "phys_drive_5000C500E54F4EBB_cntrl_0_temperature": 28,
190 "phys_drive_5000C500E5659BA7_cntrl_0_media_error_count": 0,
191 "phys_drive_5000C500E5659BA7_cntrl_0_other_error_count": 0,
192 "phys_drive_5000C500E5659BA7_cntrl_0_predictive_failure_count": 0,
193 "phys_drive_5000C500E5659BA7_cntrl_0_smart_alert_status_active": 0,
193 - "phys_drive_5000C500E5659BA7_cntrl_0_smart_alert_status_inactive": 0,
194 + "phys_drive_5000C500E5659BA7_cntrl_0_smart_alert_status_inactive": 1,
195 "phys_drive_5000C500E5659BA7_cntrl_0_temperature": 27,
196 },
197 },
src/health/health.d/megacli.conf
+1 -1
@@ -38,7 +38,7 @@ component: RAID
38 type: System
39 component: RAID
40 lookup: sum -10s
41 - units: media errors
41 + units: failures
42 every: 10s
43 warn: $this > 0
44 delay: up 1m down 5m multiplier 2 max 10m
src/health/health.d/storcli.conf new
+61
@@ -0,0 +1,61 @@
1 +# you can disable an alarm notification by setting the 'to' line to: silent
2 +
3 +# Controllers
4 +
5 + template: storcli_controller_status
6 + on: storcli.controller_status
7 + class: Errors
8 + type: System
9 +component: RAID
10 + lookup: average -1m unaligned percentage of optimal
11 + units: %
12 + every: 10s
13 + crit: $this < 100
14 + delay: down 5m multiplier 2 max 10m
15 + summary: RAID controller ${label:controller_number} health
16 + info: RAID controller ${label:controller_number} health status is not optimal
17 + to: sysadmin
18 +
19 + template: storcli_controller_bbu_status
20 + on: storcli.controller_bbu_status
21 + class: Errors
22 + type: System
23 +component: RAID
24 + lookup: average -1m unaligned percentage of healthy,na
25 + units: %
26 + every: 10s
27 + crit: $this < 100
28 + delay: down 5m multiplier 2 max 10m
29 + summary: RAID controller ${label:controller_number} BBU health
30 + info: RAID controller ${label:controller_number} BBU is unhealthy
31 + to: sysadmin
32 +
33 +# Physical Drives
34 +
35 + template: storcli_phys_drive_errors
36 + on: storcli.phys_drive_errors
37 + class: Errors
38 + type: System
39 +component: RAID
40 + lookup: sum -10s
41 + units: errors
42 + every: 10s
43 + warn: $this > 0
44 + delay: up 1m down 5m multiplier 2 max 10m
45 + summary: RAID PD c${label:controller_number}/e${label:enclosure_number}/s${label:slot_number} errors
46 + info: RAID physical drive c${label:controller_number}/e${label:enclosure_number}/s${label:slot_number} errors
47 + to: sysadmin
48 +
49 + template: storcli_phys_drive_predictive_failures
50 + on: storcli.phys_drive_predictive_failures
51 + class: Errors
52 + type: System
53 +component: RAID
54 + lookup: sum -10s
55 + units: failures
56 + every: 10s
57 + warn: $this > 0
58 + delay: up 1m down 5m multiplier 2 max 10m
59 + summary: RAID PD c${label:controller_number}/e${label:enclosure_number}/s${label:slot_number} predictive failures
60 + info: RAID physical drive c${label:controller_number}/e${label:enclosure_number}/s${label:slot_number} predictive failures
61 + to: sysadmin