@@ -23,10 +23,16 @@ import (
2323)
2424
2525func probeSystemHaPeer (c http.FortiHTTP , meta * TargetMetadata ) ([]prometheus.Metric , bool ) {
26- Priority := prometheus .NewDesc (
27- "fortigate_ha_peer" ,
26+ Info := prometheus .NewDesc (
27+ "fortigate_ha_peer_info" ,
28+ "Information about the ha peer." ,
29+ []string {"serial" , "vcluster" , "hostname" , "priority" }, nil ,
30+ )
31+
32+ Primary := prometheus .NewDesc (
33+ "fortigate_ha_peer_primary" ,
2834 "True when the peer device is the HA primary." ,
29- []string {"serial" , " vcluster" , "hostname" , "master" , "primary" , "priority " }, nil ,
35+ []string {"vcluster" , "hostname" }, nil ,
3036 )
3137
3238 type SystemHaPeer struct {
@@ -50,15 +56,14 @@ func probeSystemHaPeer(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Met
5056 m := []prometheus.Metric {}
5157 for _ , r := range res .Result {
5258 if meta .VersionMajor >= 7 && meta .VersionMinor >= 4 {
59+ 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 )))
5360 if r .Primary {
54- m = append (m , prometheus .MustNewConstMetric (Priority , prometheus .GaugeValue , 1 , r .Serial , strconv .FormatInt (r .Vcluster , 10 ), r .Hostname , strconv .FormatBool (r .Master ), "true" , strconv .FormatFloat (r .Priority , 'f' , - 1 , 64 )))
55- m = append (m , prometheus .MustNewConstMetric (Priority , prometheus .GaugeValue , 0 , r .Serial , strconv .FormatInt (r .Vcluster , 10 ), r .Hostname , strconv .FormatBool (r .Master ), "false" , strconv .FormatFloat (r .Priority , 'f' , - 1 , 64 )))
61+ m = append (m , prometheus .MustNewConstMetric (Primary , prometheus .GaugeValue , 1 , strconv .FormatInt (r .Vcluster , 10 ), r .Hostname ))
5662 } else {
57- m = append (m , prometheus .MustNewConstMetric (Priority , prometheus .GaugeValue , 0 , r .Serial , strconv .FormatInt (r .Vcluster , 10 ), r .Hostname , strconv .FormatBool (r .Master ), "true" , strconv .FormatFloat (r .Priority , 'f' , - 1 , 64 )))
58- m = append (m , prometheus .MustNewConstMetric (Priority , prometheus .GaugeValue , 1 , r .Serial , strconv .FormatInt (r .Vcluster , 10 ), r .Hostname , strconv .FormatBool (r .Master ), "false" , strconv .FormatFloat (r .Priority , 'f' , - 1 , 64 )))
63+ m = append (m , prometheus .MustNewConstMetric (Primary , prometheus .GaugeValue , 0 , strconv .FormatInt (r .Vcluster , 10 ), r .Hostname ))
5964 }
6065 } else {
61- m = append (m , prometheus .MustNewConstMetric (Priority , prometheus .GaugeValue , - 1 , "None" , "0" , "None" , "false" , "Unsupported " , "false" ))
66+ m = append (m , prometheus .MustNewConstMetric (Info , prometheus .GaugeValue , - 1 , "None" , "0" , "None" , "false" ))
6267 break
6368 }
6469 }
0 commit comments