@@ -25,18 +25,18 @@ func probeSystemCentralManagementStatus (c http.FortiHTTP, meta *TargetMetadata)
2525 var (
2626 mode = prometheus .NewDesc (
2727 "fortigate_system_central_management_mode" ,
28- "Operating mode of the central management. (Normal = 1, Backup = 0) " ,
29- []string {"server" , "mgmt_ip" , "mgmt_port" , "sn" , "pendfortman" }, nil ,
28+ "Operating mode of the central management." ,
29+ []string {"mode" , " server" , "mgmt_ip" , "mgmt_port" , "sn" , "pendfortman" }, nil ,
3030 )
3131 status = prometheus .NewDesc (
3232 "fortigate_system_central_management_status" ,
33- "Status of the connection from FortiGate to the central management server. (down = 0, up = 1, handshake = 2) " ,
34- []string {"server" , "mgmt_ip" , "mgmt_port" , "sn" , "pendfortman" }, nil ,
33+ "Status of the connection from FortiGate to the central management server." ,
34+ []string {"status" , " server" , "mgmt_ip" , "mgmt_port" , "sn" , "pendfortman" }, nil ,
3535 )
3636 registrationStatus = prometheus .NewDesc (
3737 "fortigate_system_central_management_registration_status" ,
38- "Status of the registration from FortiGate to the central management server. (unknown = -1, in_progress = 2, registered = 1, unregistered = 0) " ,
39- []string {"server" , "mgmt_ip" , "mgmt_port" , "sn" , "pendfortman" }, nil ,
38+ "Status of the registration from FortiGate to the central management server." ,
39+ []string {"status" , " server" , "mgmt_ip" , "mgmt_port" , "sn" , "pendfortman" }, nil ,
4040 )
4141 )
4242
@@ -62,28 +62,40 @@ func probeSystemCentralManagementStatus (c http.FortiHTTP, meta *TargetMetadata)
6262 }
6363
6464 m := []prometheus.Metric {}
65- if res .Result .Mode == "normal" {
66- m = append (m , prometheus .MustNewConstMetric (mode , prometheus .GaugeValue , 1 , res .Result .Server , res .Result .MgmtIp , strconv .FormatFloat (res .Result .MgmtPort , 'f' , - 1 , 64 ), res .Result .Sn , res .Result .PenFortMan ))
65+ var normal , backup , down , up , handshake , inProgress , registered , unregistered , defaultValue float64
66+ if res .Result .Mode == "normal" {
67+ normal = 1
6768 } else {
68- m = append ( m , prometheus . MustNewConstMetric ( mode , prometheus . GaugeValue , 0 , res . Result . Server , res . Result . MgmtIp , strconv . FormatFloat ( res . Result . MgmtPort , 'f' , - 1 , 64 ), res . Result . Sn , res . Result . PenFortMan ))
69+ backup = 1
6970 }
7071 switch res .Result .Status {
7172 case "down" :
72- m = append ( m , prometheus . MustNewConstMetric ( status , prometheus . GaugeValue , 0 , res . Result . Server , res . Result . MgmtIp , strconv . FormatFloat ( res . Result . MgmtPort , 'f' , - 1 , 64 ), res . Result . Sn , res . Result . PenFortMan ))
73+ down = 1
7374 case "up" :
74- m = append ( m , prometheus . MustNewConstMetric ( status , prometheus . GaugeValue , 1 , res . Result . Server , res . Result . MgmtIp , strconv . FormatFloat ( res . Result . MgmtPort , 'f' , - 1 , 64 ), res . Result . Sn , res . Result . PenFortMan ))
75+ up = 1
7576 case "handshake" :
76- m = append ( m , prometheus . MustNewConstMetric ( status , prometheus . GaugeValue , 2 , res . Result . Server , res . Result . MgmtIp , strconv . FormatFloat ( res . Result . MgmtPort , 'f' , - 1 , 64 ), res . Result . Sn , res . Result . PenFortMan ))
77+ handshake = 1
7778 }
7879 switch res .Result .RegStat {
7980 case "in_progress" :
80- m = append ( m , prometheus . MustNewConstMetric ( registration_status , prometheus . GaugeValue , 2 , res . Result . Server , res . Result . MgmtIp , strconv . FormatFloat ( res . Result . MgmtPort , 'f' , - 1 , 64 ), res . Result . Sn , res . Result . PenFortMan ))
81+ inProgress = 1
8182 case "registered" :
82- m = append ( m , prometheus . MustNewConstMetric ( registration_status , prometheus . GaugeValue , 1 , res . Result . Server , res . Result . MgmtIp , strconv . FormatFloat ( res . Result . MgmtPort , 'f' , - 1 , 64 ), res . Result . Sn , res . Result . PenFortMan ))
83+ registered = 1
8384 case "unregistered" :
84- m = append ( m , prometheus . MustNewConstMetric ( registration_status , prometheus . GaugeValue , 0 , res . Result . Server , res . Result . MgmtIp , strconv . FormatFloat ( res . Result . MgmtPort , 'f' , - 1 , 64 ), res . Result . Sn , res . Result . PenFortMan ))
85+ unregistered = 1
8586 default :
86- m = append ( m , prometheus . MustNewConstMetric ( registration_status , prometheus . GaugeValue , - 1 , res . Result . Server , res . Result . MgmtIp , strconv . FormatFloat ( res . Result . MgmtPort , 'f' , - 1 , 64 ), res . Result . Sn , res . Result . PenFortMan ))
87+ defaultValue = 1
8788 }
89+ m = append (m , prometheus .MustNewConstMetric (mode , prometheus .GaugeValue , normal , "normal" , res .Result .Server , res .Result .MgmtIp , strconv .FormatFloat (res .Result .MgmtPort , 'f' , - 1 , 64 ), res .Result .Sn , res .Result .PenFortMan ))
90+ m = append (m , prometheus .MustNewConstMetric (mode , prometheus .GaugeValue , backup , "backup" , res .Result .Server , res .Result .MgmtIp , strconv .FormatFloat (res .Result .MgmtPort , 'f' , - 1 , 64 ), res .Result .Sn , res .Result .PenFortMan ))
91+ m = append (m , prometheus .MustNewConstMetric (status , prometheus .GaugeValue , down , "down" , res .Result .Server , res .Result .MgmtIp , strconv .FormatFloat (res .Result .MgmtPort , 'f' , - 1 , 64 ), res .Result .Sn , res .Result .PenFortMan ))
92+ m = append (m , prometheus .MustNewConstMetric (status , prometheus .GaugeValue , up , "up" , res .Result .Server , res .Result .MgmtIp , strconv .FormatFloat (res .Result .MgmtPort , 'f' , - 1 , 64 ), res .Result .Sn , res .Result .PenFortMan ))
93+ m = append (m , prometheus .MustNewConstMetric (status , prometheus .GaugeValue , handshake , "handshake" , res .Result .Server , res .Result .MgmtIp , strconv .FormatFloat (res .Result .MgmtPort , 'f' , - 1 , 64 ), res .Result .Sn , res .Result .PenFortMan ))
94+ m = append (m , prometheus .MustNewConstMetric (registrationStatus , prometheus .GaugeValue , inProgress , "inprogress" , res .Result .Server , res .Result .MgmtIp , strconv .FormatFloat (res .Result .MgmtPort , 'f' , - 1 , 64 ), res .Result .Sn , res .Result .PenFortMan ))
95+ m = append (m , prometheus .MustNewConstMetric (registrationStatus , prometheus .GaugeValue , registered , "registered" , res .Result .Server , res .Result .MgmtIp , strconv .FormatFloat (res .Result .MgmtPort , 'f' , - 1 , 64 ), res .Result .Sn , res .Result .PenFortMan ))
96+ m = append (m , prometheus .MustNewConstMetric (registrationStatus , prometheus .GaugeValue , unregistered , "unregistered" , res .Result .Server , res .Result .MgmtIp , strconv .FormatFloat (res .Result .MgmtPort , 'f' , - 1 , 64 ), res .Result .Sn , res .Result .PenFortMan ))
97+ m = append (m , prometheus .MustNewConstMetric (registrationStatus , prometheus .GaugeValue , defaultValue , "unknown" , res .Result .Server , res .Result .MgmtIp , strconv .FormatFloat (res .Result .MgmtPort , 'f' , - 1 , 64 ), res .Result .Sn , res .Result .PenFortMan ))
98+
99+
88100 return m , true
89101}
0 commit comments