Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEriks Sneiders <eriks.sneiders@zabbix.com>2022-03-23 14:40:42 +0300
committerEriks Sneiders <eriks.sneiders@zabbix.com>2022-03-31 17:47:11 +0300
commit5a0e86eb1d521293d74876f960ba9ec646b59324 (patch)
tree789b35d0b78d316afcd8dee8c1af4631ad9c0095 /src/go/plugins
parenta889644cb1e3120d5d2dae408c8067a5a7b8fdf3 (diff)
...G...... [ZBXNEXT-7559] changed attributes in smart.disk.discovery to be an array
Diffstat (limited to 'src/go/plugins')
-rw-r--r--src/go/plugins/smart/smart.go8
-rw-r--r--src/go/plugins/smart/smart_test.go39
-rw-r--r--src/go/plugins/smart/smartfs.go12
3 files changed, 49 insertions, 10 deletions
diff --git a/src/go/plugins/smart/smart.go b/src/go/plugins/smart/smart.go
index 0401f0eead1..29b92ec864d 100644
--- a/src/go/plugins/smart/smart.go
+++ b/src/go/plugins/smart/smart.go
@@ -374,13 +374,13 @@ func getAttributeType(devType string, rate int, tables []table) string {
return getTypeByRateAndAttr(rate, tables)
}
-func getAttributes(in deviceParser) []string {
- out := make([]string, len(in.SmartAttributes.Table))
+func getAttributes(in deviceParser) string {
+ tmp := make([]string, len(in.SmartAttributes.Table))
for i, table := range in.SmartAttributes.Table {
- out[i] = table.Attrname
+ tmp[i] = table.Attrname
}
- return out
+ return strings.Join(tmp, " ")
}
func getType(devType string, rate int, tables []table) string {
diff --git a/src/go/plugins/smart/smart_test.go b/src/go/plugins/smart/smart_test.go
index 8f9a9c5a94b..4da7816fa7c 100644
--- a/src/go/plugins/smart/smart_test.go
+++ b/src/go/plugins/smart/smart_test.go
@@ -467,6 +467,45 @@ func Test_getAttributeType(t *testing.T) {
}
}
+func Test_getAttributes(t *testing.T) {
+ type args struct {
+ in deviceParser
+ }
+ tests := []struct {
+ name string
+ args args
+ want string
+ }{
+ {
+ "attributes_set",
+ args{deviceParser{SmartAttributes: smartAttributes{Table: []table{table1, table2}}}},
+ "test1 test2",
+ },
+ {
+ "attributes_table_empty",
+ args{deviceParser{SmartAttributes: smartAttributes{Table: []table{}}}},
+ "",
+ },
+ {
+ "attributes_missing",
+ args{deviceParser{}},
+ "",
+ },
+ {
+ "parser_missing",
+ args{},
+ "",
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ if got := getAttributes(tt.args.in); got != tt.want {
+ t.Errorf("getAttributes() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
func Test_getType(t *testing.T) {
type args struct {
devType string
diff --git a/src/go/plugins/smart/smartfs.go b/src/go/plugins/smart/smartfs.go
index 4a573cb11c2..a485a947e45 100644
--- a/src/go/plugins/smart/smartfs.go
+++ b/src/go/plugins/smart/smartfs.go
@@ -64,12 +64,12 @@ type devices struct {
}
type device struct {
- Name string `json:"{#NAME}"`
- DeviceType string `json:"{#DISKTYPE}"`
- Model string `json:"{#MODEL}"`
- SerialNumber string `json:"{#SN}"`
- Path string `json:"{#PATH}"`
- Attributes []string `json:"{#ATTRIBUTES}"`
+ Name string `json:"{#NAME}"`
+ DeviceType string `json:"{#DISKTYPE}"`
+ Model string `json:"{#MODEL}"`
+ SerialNumber string `json:"{#SN}"`
+ Path string `json:"{#PATH}"`
+ Attributes string `json:"{#ATTRIBUTES}"`
}
type jsonDevice struct {
serialNumber string