Skip to content

Commit 462bf39

Browse files
committed
fix: correct version comparison for FortiOS 7.4+ feature gates
The check 'VersionMajor >= 7 && VersionMinor >= 4' fails for future major versions with minor < 4 (e.g., 8.0 would not match). Use 'VersionMajor > 7 || (VersionMajor == 7 && VersionMinor >= 4)' to correctly express 'version 7.4 or later'. Signed-off-by: Aprazors <Aprazors@gmail.com>
1 parent b3a54c2 commit 462bf39

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

pkg/probe/system_ha_peer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func probeSystemHaPeer(c fortigatehttpclient.FortiHTTP, meta *TargetMetadata) ([
6161
}
6262
m := []prometheus.Metric{}
6363
for _, r := range res.Result {
64-
if meta.VersionMajor >= 7 && meta.VersionMinor >= 4 {
64+
if meta.VersionMajor > 7 || (meta.VersionMajor == 7 && meta.VersionMinor >= 4) {
6565
m = append(m, prometheus.MustNewConstMetric(info, prometheus.GaugeValue, 1, r.Serial, strconv.FormatInt(r.Vcluster, 10), r.Hostname, strconv.FormatFloat(r.Priority, 'f', -1, 64)))
6666
if r.Primary {
6767
m = append(m, prometheus.MustNewConstMetric(primary, prometheus.GaugeValue, 1, strconv.FormatInt(r.Vcluster, 10), r.Hostname))

pkg/probe/system_ntp_status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func probeSystemNtpStatus(c fortigatehttpclient.FortiHTTP, meta *TargetMetadata)
8888
}
8989

9090
m := []prometheus.Metric{}
91-
if meta.VersionMajor >= 7 && meta.VersionMinor >= 4 {
91+
if meta.VersionMajor > 7 || (meta.VersionMajor == 7 && meta.VersionMinor >= 4) {
9292
for _, res := range result {
9393
for _, r := range res.Results {
9494
m = append(m, prometheus.MustNewConstMetric(ntpExpires, prometheus.GaugeValue, float64(r.Expires), r.IP, r.Server, strconv.FormatBool(r.Reachable), strconv.FormatBool(r.Reachable), strconv.Itoa(r.Version), res.VDOM))

0 commit comments

Comments
 (0)