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
|
// SPDX-License-Identifier: GPL-3.0-or-later
package storcli
import (
"fmt"
"strconv"
"strings"
"github.com/netdata/netdata/go/go.d.plugin/agent/module"
)
const (
prioControllerStatus = module.Priority + iota
prioControllerBBUStatus
prioPhysDriveErrors
prioPhysDrivePredictiveFailures
prioPhysDriveSmartAlertStatus
prioPhysDriveTemperature
)
var controllerChartsTmpl = module.Charts{
controllerStatusChartTmpl.Copy(),
controllerBBUStatusChartTmpl.Copy(),
}
var (
controllerStatusChartTmpl = module.Chart{
ID: "controller_%s_status",
Title: "Controller status",
Units: "status",
Fam: "cntrl status",
Ctx: "storcli.controller_status",
Type: module.Line,
Priority: prioControllerStatus,
Dims: module.Dims{
{ID: "cntrl_%s_status_optimal", Name: "optimal"},
{ID: "cntrl_%s_status_degraded", Name: "degraded"},
{ID: "cntrl_%s_status_partially_degraded", Name: "partially_degraded"},
{ID: "cntrl_%s_status_failed", Name: "failed"},
},
}
controllerBBUStatusChartTmpl = module.Chart{
ID: "controller_%s_bbu_status",
Title: "Controller BBU status",
Units: "status",
Fam: "cntrl status",
Ctx: "storcli.controller_bbu_status",
Type: module.Line,
Priority: prioControllerBBUStatus,
Dims: module.Dims{
{ID: "cntrl_%s_bbu_status_healthy", Name: "healthy"},
{ID: "cntrl_%s_bbu_status_unhealthy", Name: "unhealthy"},
{ID: "cntrl_%s_bbu_status_na", Name: "na"},
},
}
)
var physDriveChartsTmpl = module.Charts{
physDriveMediaErrorsRateChartTmpl.Copy(),
physDrivePredictiveFailuresRateChartTmpl.Copy(),
physDriveSmartAlertStatusChartTmpl.Copy(),
physDriveTemperatureChartTmpl.Copy(),
}
var (
physDriveMediaErrorsRateChartTmpl = module.Chart{
ID: "phys_drive_%s_cntrl_%s_media_errors_rate",
Title: "Physical Drive media errors rate",
Units: "errors/s",
Fam: "pd errors",
Ctx: "storcli.phys_drive_errors",
Type: module.Line,
Priority: prioPhysDriveErrors,
Dims: module.Dims{
{ID: "phys_drive_%s_cntrl_%s_media_error_count", Name: "media"},
{ID: "phys_drive_%s_cntrl_%s_other_error_count", Name: "other"},
},
}
physDrivePredictiveFailuresRateChartTmpl = module.Chart{
ID: "phys_drive_%s_cntrl_%s_predictive_failures_rate",
Title: "Physical Drive predictive failures rate",
Units: "failures/s",
Fam: "pd errors",
Ctx: "storcli.phys_drive_predictive_failures",
Type: module.Line,
Priority: prioPhysDrivePredictiveFailures,
Dims: module.Dims{
{ID: "phys_drive_%s_cntrl_%s_predictive_failure_count", Name: "predictive_failures"},
},
}
physDriveSmartAlertStatusChartTmpl = module.Chart{
ID: "phys_drive_%s_cntrl_%s_smart_alert_status",
Title: "Physical Drive SMART alert status",
Units: "status",
Fam: "pd smart",
Ctx: "storcli.phys_drive_smart_alert_status",
Type: module.Line,
Priority: prioPhysDriveSmartAlertStatus,
Dims: module.Dims{
{ID: "phys_drive_%s_cntrl_%s_smart_alert_status_active", Name: "active"},
{ID: "phys_drive_%s_cntrl_%s_smart_alert_status_inactive", Name: "inactive"},
},
}
physDriveTemperatureChartTmpl = module.Chart{
ID: "phys_drive_%s_cntrl_%s_temperature",
Title: "Physical Drive temperature",
Units: "status",
Fam: "pd temperature",
Ctx: "storcli.phys_drive_temperature",
Type: module.Line,
Priority: prioPhysDriveTemperature,
Dims: module.Dims{
{ID: "phys_drive_%s_cntrl_%s_temperature", Name: "temperature"},
},
}
)
func (s *StorCli) addControllerCharts(cntrl controllerInfo) {
charts := controllerChartsTmpl.Copy()
num := strconv.Itoa(cntrl.Basics.Controller)
for _, chart := range *charts {
chart.ID = fmt.Sprintf(chart.ID, num)
chart.Labels = []module.Label{
{Key: "controller_number", Value: num},
{Key: "model", Value: cntrl.Basics.Model},
}
for _, dim := range chart.Dims {
dim.ID = fmt.Sprintf(dim.ID, num)
}
}
if err := s.Charts().Add(*charts...); err != nil {
s.Warning(err)
}
}
func (s *StorCli) addPhysDriveCharts(cntrlNum int, di *driveInfo, ds *driveState, da *driveAttrs) {
charts := physDriveChartsTmpl.Copy()
if _, ok := parseInt(getDriveTemperature(ds.DriveTemperature)); !ok {
_ = charts.Remove(physDriveTemperatureChartTmpl.ID)
}
num := strconv.Itoa(cntrlNum)
var enc, slot string
if parts := strings.Split(di.EIDSlt, ":"); len(parts) == 2 { // EID:Slt
enc, slot = parts[0], parts[1]
}
for _, chart := range *charts {
chart.ID = fmt.Sprintf(chart.ID, da.WWN, num)
chart.Labels = []module.Label{
{Key: "controller_number", Value: num},
{Key: "enclosure_number", Value: enc},
{Key: "slot_number", Value: slot},
{Key: "media_type", Value: di.Med},
}
for _, dim := range chart.Dims {
dim.ID = fmt.Sprintf(dim.ID, da.WWN, num)
}
}
if err := s.Charts().Add(*charts...); err != nil {
s.Warning(err)
}
}
|