Skip to content

Commit 9550fbd

Browse files
committed
Reverted back old version and added new to metrics
Signed-off-by: Örnfeldt Philip (66140321) <philip.ornfeldt@forsakringskassan.se>
1 parent 1717a62 commit 9550fbd

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

metrics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Per-VDOM:
8989
* _System/Interface/Transceivers_
9090
* `fortigate_inteface_transceivers_info`
9191
* _System/SDNConnector_
92+
* `fortigate_system_sdn_connector_state`
9293
* `fortigate_system_sdn_connector_status`
9394
* `fortigate_system_sdn_connector_last_update_seconds`
9495
* _/System/CentralManagement/Status_

pkg/probe/system_sdn_connector.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ type SystemSDNConnector struct {
3636

3737
func probeSystemSDNConnector(c http.FortiHTTP, _ *TargetMetadata) ([]prometheus.Metric, bool) {
3838
var (
39+
SDNConnectorsStatus = prometheus.NewDesc(
40+
"fortigate_system_sdn_connector_status",
41+
"Status of SDN connectors (0=Disabled, 1=Down, 2=Unknown, 3=Up, 4=Updating)",
42+
[]string{"vdom", "name", "type"}, nil,
43+
)
3944
SDNConnectorsState = prometheus.NewDesc(
4045
"fortigate_system_sdn_connector_state",
4146
"Status of SDN connectors disabled",
@@ -66,14 +71,19 @@ func probeSystemSDNConnector(c http.FortiHTTP, _ *TargetMetadata) ([]prometheus.
6671
}
6772
switch sdnConn.Status {
6873
case "Disabled":
74+
m = append(m, prometheus.MustNewConstMetric(SDNConnectorsStatus, prometheus.GaugeValue, float64(0), r.VDOM, sdnConn.Name, sdnConn.Type))
6975
t[0] = prometheus.MustNewConstMetric(SDNConnectorsState, prometheus.GaugeValue, 1.0, r.VDOM, sdnConn.Name, sdnConn.Type, sdnConn.Status)
7076
case "Down":
77+
m = append(m, prometheus.MustNewConstMetric(SDNConnectorsStatus, prometheus.GaugeValue, float64(1), r.VDOM, sdnConn.Name, sdnConn.Type))
7178
t[1] = prometheus.MustNewConstMetric(SDNConnectorsState, prometheus.GaugeValue, 1.0, r.VDOM, sdnConn.Name, sdnConn.Type, sdnConn.Status)
7279
case "Unknown":
80+
m = append(m, prometheus.MustNewConstMetric(SDNConnectorsStatus, prometheus.GaugeValue, float64(2), r.VDOM, sdnConn.Name, sdnConn.Type))
7381
t[2] = prometheus.MustNewConstMetric(SDNConnectorsState, prometheus.GaugeValue, 1.0, r.VDOM, sdnConn.Name, sdnConn.Type, sdnConn.Status)
7482
case "Up":
83+
m = append(m, prometheus.MustNewConstMetric(SDNConnectorsStatus, prometheus.GaugeValue, float64(3), r.VDOM, sdnConn.Name, sdnConn.Type))
7584
t[3] = prometheus.MustNewConstMetric(SDNConnectorsState, prometheus.GaugeValue, 1.0, r.VDOM, sdnConn.Name, sdnConn.Type, sdnConn.Status)
7685
case "Updating":
86+
m = append(m, prometheus.MustNewConstMetric(SDNConnectorsStatus, prometheus.GaugeValue, float64(4), r.VDOM, sdnConn.Name, sdnConn.Type))
7787
t[4] = prometheus.MustNewConstMetric(SDNConnectorsState, prometheus.GaugeValue, 1.0, r.VDOM, sdnConn.Name, sdnConn.Type, sdnConn.Status)
7888
}
7989
m = append(m, prometheus.MustNewConstMetric(SDNConnectorsLastUpdate, prometheus.GaugeValue, float64(sdnConn.LastUpdate), r.VDOM, sdnConn.Name, sdnConn.Type))

pkg/probe/system_sdn_connector_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ func TestSystemSDNConnector(t *testing.T) {
4646
fortigate_system_sdn_connector_state{name="GCP Infra",state="Unknown",type="gcp",vdom="google"} 0
4747
fortigate_system_sdn_connector_state{name="GCP Infra",state="Up",type="gcp",vdom="google"} 0
4848
fortigate_system_sdn_connector_state{name="GCP Infra",state="Updating",type="gcp",vdom="google"} 0
49+
# HELP fortigate_system_sdn_connector_status Status of SDN connectors (0=Disabled, 1=Down, 2=Unknown, 3=Up, 4=Updating)
50+
# TYPE fortigate_system_sdn_connector_status gauge
51+
fortigate_system_sdn_connector_status{name="AWS Infra",type="aws",vdom="root"} 3
52+
fortigate_system_sdn_connector_status{name="GCP Infra",type="gcp",vdom="google"} 1
4953
`
5054

5155
if err := testutil.GatherAndCompare(r, strings.NewReader(em)); err != nil {

0 commit comments

Comments
 (0)