@@ -22,35 +22,10 @@ import (
2222)
2323
2424func probeSystemSandboxConnection (c http.FortiHTTP , _ * TargetMetadata ) ([]prometheus.Metric , bool ) {
25- connectionStatusDisable := prometheus .NewDesc (
26- "fortigate_sandbox_connection_status_disabled " ,
25+ connectionStatus := prometheus .NewDesc (
26+ "fortigate_sandbox_connection_state " ,
2727 "Sandbox connection status" ,
28- []string {"sandbox_type" }, nil ,
29- )
30- connectionStatusUreachable := prometheus .NewDesc (
31- "fortigate_sandbox_connection_status_unreachable" ,
32- "Sandbox connection status" ,
33- []string {"sandbox_type" }, nil ,
34- )
35- connectionStatusReachable := prometheus .NewDesc (
36- "fortigate_sandbox_connection_status_reachable" ,
37- "Sandbox connection status" ,
38- []string {"sandbox_type" }, nil ,
39- )
40- connectionStatusUnauthorized := prometheus .NewDesc (
41- "fortigate_sandbox_connection_status_unauthorized" ,
42- "Sandbox connection status" ,
43- []string {"sandbox_type" }, nil ,
44- )
45- connectionStatusIncompatible := prometheus .NewDesc (
46- "fortigate_sandbox_connection_status_incompatible" ,
47- "Sandbox connection status" ,
48- []string {"sandbox_type" }, nil ,
49- )
50- connectionStatusUnverified := prometheus .NewDesc (
51- "fortigate_sandbox_connection_status_unverified" ,
52- "Sandbox connection status" ,
53- []string {"sandbox_type" }, nil ,
28+ []string {"sandbox_type" , "status" }, nil ,
5429 )
5530
5631 type SystemSandboxConnection struct {
@@ -69,50 +44,29 @@ func probeSystemSandboxConnection(c http.FortiHTTP, _ *TargetMetadata) ([]promet
6944
7045 m := []prometheus.Metric {}
7146 for _ , r := range res .Results {
47+ t := []prometheus.Metric {
48+ prometheus .MustNewConstMetric (connectionStatus , prometheus .GaugeValue , 0 , r .Type , "unreachable" ),
49+ prometheus .MustNewConstMetric (connectionStatus , prometheus .GaugeValue , 0 , r .Type , "reachable" ),
50+ prometheus .MustNewConstMetric (connectionStatus , prometheus .GaugeValue , 0 , r .Type , "disabled" ),
51+ prometheus .MustNewConstMetric (connectionStatus , prometheus .GaugeValue , 0 , r .Type , "unauthorized" ),
52+ prometheus .MustNewConstMetric (connectionStatus , prometheus .GaugeValue , 0 , r .Type , "incompatible" ),
53+ prometheus .MustNewConstMetric (connectionStatus , prometheus .GaugeValue , 0 , r .Type , "unverified" ),
54+ }
7255 switch r .Status {
7356 case "unreachable" :
74- m = append (m , prometheus .MustNewConstMetric (connectionStatusUreachable , prometheus .GaugeValue , 1 , r .Type ))
75- m = append (m , prometheus .MustNewConstMetric (connectionStatusReachable , prometheus .GaugeValue , 0 , r .Type ))
76- m = append (m , prometheus .MustNewConstMetric (connectionStatusDisable , prometheus .GaugeValue , 0 , r .Type ))
77- m = append (m , prometheus .MustNewConstMetric (connectionStatusUnauthorized , prometheus .GaugeValue , 0 , r .Type ))
78- m = append (m , prometheus .MustNewConstMetric (connectionStatusIncompatible , prometheus .GaugeValue , 0 , r .Type ))
79- m = append (m , prometheus .MustNewConstMetric (connectionStatusUnverified , prometheus .GaugeValue , 0 , r .Type ))
57+ t [0 ] = prometheus .MustNewConstMetric (connectionStatus , prometheus .GaugeValue , 1 , r .Type , r .Status )
8058 case "reachable" :
81- m = append (m , prometheus .MustNewConstMetric (connectionStatusUreachable , prometheus .GaugeValue , 0 , r .Type ))
82- m = append (m , prometheus .MustNewConstMetric (connectionStatusReachable , prometheus .GaugeValue , 1 , r .Type ))
83- m = append (m , prometheus .MustNewConstMetric (connectionStatusDisable , prometheus .GaugeValue , 0 , r .Type ))
84- m = append (m , prometheus .MustNewConstMetric (connectionStatusUnauthorized , prometheus .GaugeValue , 0 , r .Type ))
85- m = append (m , prometheus .MustNewConstMetric (connectionStatusIncompatible , prometheus .GaugeValue , 0 , r .Type ))
86- m = append (m , prometheus .MustNewConstMetric (connectionStatusUnverified , prometheus .GaugeValue , 0 , r .Type ))
59+ t [1 ] = prometheus .MustNewConstMetric (connectionStatus , prometheus .GaugeValue , 1 , r .Type , r .Status )
8760 case "disabled" :
88- m = append (m , prometheus .MustNewConstMetric (connectionStatusUreachable , prometheus .GaugeValue , 0 , r .Type ))
89- m = append (m , prometheus .MustNewConstMetric (connectionStatusReachable , prometheus .GaugeValue , 0 , r .Type ))
90- m = append (m , prometheus .MustNewConstMetric (connectionStatusDisable , prometheus .GaugeValue , 1 , r .Type ))
91- m = append (m , prometheus .MustNewConstMetric (connectionStatusUnauthorized , prometheus .GaugeValue , 0 , r .Type ))
92- m = append (m , prometheus .MustNewConstMetric (connectionStatusIncompatible , prometheus .GaugeValue , 0 , r .Type ))
93- m = append (m , prometheus .MustNewConstMetric (connectionStatusUnverified , prometheus .GaugeValue , 0 , r .Type ))
61+ t [2 ] = prometheus .MustNewConstMetric (connectionStatus , prometheus .GaugeValue , 1 , r .Type , r .Status )
9462 case "unauthorized" :
95- m = append (m , prometheus .MustNewConstMetric (connectionStatusUreachable , prometheus .GaugeValue , 0 , r .Type ))
96- m = append (m , prometheus .MustNewConstMetric (connectionStatusReachable , prometheus .GaugeValue , 0 , r .Type ))
97- m = append (m , prometheus .MustNewConstMetric (connectionStatusDisable , prometheus .GaugeValue , 0 , r .Type ))
98- m = append (m , prometheus .MustNewConstMetric (connectionStatusUnauthorized , prometheus .GaugeValue , 1 , r .Type ))
99- m = append (m , prometheus .MustNewConstMetric (connectionStatusIncompatible , prometheus .GaugeValue , 0 , r .Type ))
100- m = append (m , prometheus .MustNewConstMetric (connectionStatusUnverified , prometheus .GaugeValue , 0 , r .Type ))
63+ t [3 ] = prometheus .MustNewConstMetric (connectionStatus , prometheus .GaugeValue , 1 , r .Type , r .Status )
10164 case "incompatible" :
102- m = append (m , prometheus .MustNewConstMetric (connectionStatusUreachable , prometheus .GaugeValue , 0 , r .Type ))
103- m = append (m , prometheus .MustNewConstMetric (connectionStatusReachable , prometheus .GaugeValue , 0 , r .Type ))
104- m = append (m , prometheus .MustNewConstMetric (connectionStatusDisable , prometheus .GaugeValue , 0 , r .Type ))
105- m = append (m , prometheus .MustNewConstMetric (connectionStatusUnauthorized , prometheus .GaugeValue , 0 , r .Type ))
106- m = append (m , prometheus .MustNewConstMetric (connectionStatusIncompatible , prometheus .GaugeValue , 1 , r .Type ))
107- m = append (m , prometheus .MustNewConstMetric (connectionStatusUnverified , prometheus .GaugeValue , 0 , r .Type ))
65+ t [4 ] = prometheus .MustNewConstMetric (connectionStatus , prometheus .GaugeValue , 1 , r .Type , r .Status )
10866 case "unverified" :
109- m = append (m , prometheus .MustNewConstMetric (connectionStatusUreachable , prometheus .GaugeValue , 0 , r .Type ))
110- m = append (m , prometheus .MustNewConstMetric (connectionStatusReachable , prometheus .GaugeValue , 0 , r .Type ))
111- m = append (m , prometheus .MustNewConstMetric (connectionStatusDisable , prometheus .GaugeValue , 0 , r .Type ))
112- m = append (m , prometheus .MustNewConstMetric (connectionStatusUnauthorized , prometheus .GaugeValue , 0 , r .Type ))
113- m = append (m , prometheus .MustNewConstMetric (connectionStatusIncompatible , prometheus .GaugeValue , 0 , r .Type ))
114- m = append (m , prometheus .MustNewConstMetric (connectionStatusUnverified , prometheus .GaugeValue , 1 , r .Type ))
67+ t [5 ] = prometheus .MustNewConstMetric (connectionStatus , prometheus .GaugeValue , 1 , r .Type , r .Status )
11568 }
69+ m = append (m , t ... )
11670 }
11771 return m , true
11872}
0 commit comments