diff --git a/go.mod b/go.mod index 910d8a9..7cb441a 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( github.com/NETWAYS/go-check v0.6.1 github.com/gosnmp/gosnmp v1.37.0 github.com/hashicorp/go-version v1.6.0 - github.com/mcuadros/go-version v0.0.0-20190830083331-035f6764e8d2 github.com/stretchr/testify v1.8.4 ) diff --git a/go.sum b/go.sum index 278ebb3..49eb805 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,6 @@ github.com/gosnmp/gosnmp v1.37.0 h1:/Tf8D3b9wrnNuf/SfbvO+44mPrjVphBhRtcGg22V07Y= github.com/gosnmp/gosnmp v1.37.0/go.mod h1:GDH9vNqpsD7f2HvZhKs5dlqSEcAS6s6Qp099oZRCR+M= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/mcuadros/go-version v0.0.0-20190830083331-035f6764e8d2 h1:YocNLcTBdEdvY3iDK6jfWXvEaM5OCKkjxPKoJRdB3Gg= -github.com/mcuadros/go-version v0.0.0-20190830083331-035f6764e8d2/go.mod h1:76rfSfYPWj01Z85hUf/ituArm797mNKcvINh1OlsZKo= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= diff --git a/hp/cntlr/firmware.go b/hp/cntlr/firmware.go index 4873b8b..fc027b6 100644 --- a/hp/cntlr/firmware.go +++ b/hp/cntlr/firmware.go @@ -2,7 +2,7 @@ package cntlr import ( "github.com/NETWAYS/go-check" - "github.com/mcuadros/go-version" + "github.com/hashicorp/go-version" ) type VersionInfo struct { @@ -26,16 +26,22 @@ func init() { // Note: we can't validate against existing logical drives at the moment func IsAffected(firmware string) (int, string) { - if version.Compare(firmware, VersionFixed, ">=") { + firmwareVersion, _ := version.NewVersion(firmware) + fixedVersion, _ := version.NewVersion(VersionFixed) + + if firmwareVersion.GreaterThanOrEqual(fixedVersion) { return check.OK, "firmware has been updated" } - if version.Compare(firmware, VersionAffectedRaid1, ">=") { + affectedRaid1, _ := version.NewVersion(VersionAffectedRaid1) + + if firmwareVersion.GreaterThanOrEqual(affectedRaid1) { return check.Critical, "if you have RAID 1/10/ADM - update immediately!" } for _, v := range VersionAffectedRaid5 { - if v == firmware { + affectedRaid5, _ := version.NewVersion(v) + if firmwareVersion.Equal(affectedRaid5) { return check.Critical, "if you have RAID 5/6/50/60 - update immediately!" } } diff --git a/snmp/table.go b/snmp/table.go index 61884ae..612823a 100644 --- a/snmp/table.go +++ b/snmp/table.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/gosnmp/gosnmp" - "github.com/mcuadros/go-version" + "github.com/hashicorp/go-version" ) type Table struct { @@ -137,7 +137,9 @@ func (t *Table) GetSortedOIDs() []string { func SortOIDs(list []string) []string { sort.Slice(list, func(i, j int) bool { - return version.Compare(list[i], list[j], "<") + v1, _ := version.NewVersion(list[i]) + v2, _ := version.NewVersion(list[j]) + return v1.LessThan(v2) }) return list