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+
14+ package probe
15+
16+ import (
17+ "log"
18+
19+ "github.com/prometheus-community/fortigate_exporter/pkg/http"
20+ "github.com/prometheus/client_golang/prometheus"
21+ )
22+
23+ func probeSystemInterfaceTransceivers (c http.FortiHTTP , meta * TargetMetadata ) ([]prometheus.Metric , bool ) {
24+ var (
25+ interfaceTransceivers = prometheus .NewDesc (
26+ "fortigate_inteface_transceivers_info" ,
27+ "Interface transceivers information" ,
28+ []string {"interface" , "type" , "vendor" , "vendorpartnumber" , "vendorserialnumber" }, nil ,
29+ )
30+ )
31+
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"`
38+ }
39+
40+ type SystemInterfaceTransceivers struct {
41+ Results []SystemInterfaceTransceiversResult `json:"results"`
42+ }
43+
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 )
47+ return nil , false
48+ }
49+
50+ m := []prometheus.Metric {}
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 ))
53+ }
54+
55+ return m , true
56+ }
0 commit comments