@@ -24,9 +24,9 @@ import (
2424func probeSystemHaPeer (c http.FortiHTTP , meta * TargetMetadata ) ([]prometheus.Metric , bool ) {
2525 var (
2626 Priority = prometheus .NewDesc (
27- "fortigate_ha_peer_priority " ,
28- "Priority level of the HA peer device. " ,
29- []string {"serial" ,"vcluster" ,"hostname" ,"master" ,"primary" }, nil ,
27+ "fortigate_ha_peer " ,
28+ "True when the peer device is the HA primary.(true=1, false=0) " ,
29+ []string {"serial" ,"vcluster" ,"hostname" ,"master" ,"primary" , "priority" }, nil ,
3030 )
3131 )
3232
@@ -51,9 +51,14 @@ func probeSystemHaPeer (c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Me
5151 m := []prometheus.Metric {}
5252 for _ , r := range res .Result {
5353 if meta .VersionMajor >= 7 && meta .VersionMinor >= 4 {
54- m = append (m , prometheus .MustNewConstMetric (Priority , prometheus .GaugeValue , r .Priority , r .Serial , strconv .FormatInt (r .Vcluster , 10 ), r .Hostname , strconv .FormatBool (r .Master ), strconv .FormatBool (r .Primary )))
54+ if (r .Primary ) {
55+ m = append (m , prometheus .MustNewConstMetric (Priority , prometheus .GaugeValue , 1 , r .Serial , strconv .FormatInt (r .Vcluster , 10 ), r .Hostname , strconv .FormatBool (r .Master ), strconv .FormatBool (r .Primary ), strconv .FormatFloat (r .Priority , 'f' , - 1 , 64 )))
56+ } else {
57+ m = append (m , prometheus .MustNewConstMetric (Priority , prometheus .GaugeValue , 0 , r .Serial , strconv .FormatInt (r .Vcluster , 10 ), r .Hostname , strconv .FormatBool (r .Master ), strconv .FormatBool (r .Primary ), strconv .FormatFloat (r .Priority , 'f' , - 1 , 64 )))
58+ }
5559 } else {
56- m = append (m , prometheus .MustNewConstMetric (Priority , prometheus .GaugeValue , r .Priority , r .Serial , strconv .FormatInt (r .Vcluster , 10 ), r .Hostname , strconv .FormatBool (r .Master ), "Unsupported" ))
60+ m = append (m , prometheus .MustNewConstMetric (Priority , prometheus .GaugeValue , - 1 , "None" , "0" , "None" , "false" , "Unsupported" , "false" ))
61+ break
5762 }
5863 }
5964 return m , true
0 commit comments