1+ // Copyright 2025 The Prometheus Authors
2+ // Licensed under the Apache License, Version 2.0 (the "License");
3+ // you may not use this file except in compliance with the License.
4+ // You may obtain a copy of the License at
5+ //
6+ // http://www.apache.org/licenses/LICENSE-2.0
7+ //
8+ // Unless required by applicable law or agreed to in writing, software
9+ // distributed under the License is distributed on an "AS IS" BASIS,
10+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+ // See the License for the specific language governing permissions and
12+ // limitations under the License.
13+
114package probe
215
316import (
417 "log"
5-
6- "github.com/bluecmd /fortigate_exporter/pkg/http"
18+
19+ "github.com/prometheus-community /fortigate_exporter/pkg/http"
720 "github.com/prometheus/client_golang/prometheus"
821)
922
1023func probeSystemInterfaceTransceivers (c http.FortiHTTP , meta * TargetMetadata ) ([]prometheus.Metric , bool ) {
1124 var (
12- mVersion = prometheus .NewDesc (
13- "fortigate_interface_transceivers " ,
14- "List of transceivers being used by the FortiGate " ,
15- []string {"name " , "type" , "vendor" , "partnumber " , "description " }, nil ,
25+ interfaceTransceivers = prometheus .NewDesc (
26+ "fortigate_inteface_transceivers " ,
27+ "Interface transceivers information " ,
28+ []string {"interface " , "type" , "vendor" , "vendorpartnumber " , "vendorserialnumber " }, nil ,
1629 )
1730 )
1831
19- type ifResult struct {
20- Description string
21- Interface string
22- Type string
23- Vendor string
24- VendorPartNr string `json:"vendor_part_number "`
32+ type SystemInterfaceTransceiversResult struct {
33+ Interface string `json:"interface"`
34+ Type string `json:"type"`
35+ Vendor string `json:"vendor"`
36+ VendorPartNumber string `json:"vendor_part_number"`
37+ VendorSerialNumber string `json:"vendor_serial_number "`
2538 }
26- type ifResponse struct {
27- Results []ifResult
39+
40+ type SystemInterfaceTransceivers struct {
41+ Results []SystemInterfaceTransceiversResult `json:"results"`
2842 }
29- var r ifResponse
3043
31- if err := c .Get ("api/v2/monitor/system/interface/transceivers" , "scope=global" , & r ); err != nil {
32- log .Printf ("Error: %v" , err )
44+ var res SystemInterfaceTransceivers
45+ if err := c .Get ("api/v2/monitor/system/interface/transceivers" , "scope=global" , & res ); err != nil {
46+ log .Printf ("Warning: %v" , err )
3347 return nil , false
3448 }
3549
3650 m := []prometheus.Metric {}
37- for _ , result := range r .Results {
38- m = append (m , prometheus .MustNewConstMetric (mVersion , prometheus .GaugeValue , 1.0 , result .Interface , result .Type , result .Vendor , result . VendorPartNr , result . Description ))
51+ for _ , r := range res .Results {
52+ m = append (m , prometheus .MustNewConstMetric (interfaceTransceivers , prometheus .GaugeValue , 1.0 , r .Interface , r .Type , r .Vendor , r . VendorPartNumber , r . VendorSerialNumber ))
3953 }
54+
4055 return m , true
41- }
56+ }
0 commit comments