Skip to content

Commit 8d24fc3

Browse files
authored
Merge branch 'main' into feature/dns-latency
2 parents 5211b71 + e61816d commit 8d24fc3

10 files changed

Lines changed: 368 additions & 20 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
matrix:
2222
thread: [ 0, 1, 2 ]
2323
steps:
24-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2525
- uses: prometheus/promci@443c7fc2397e946bc9f5029e313a9c3441b9b86d # v0.4.7
2626
- uses: ./.github/promci/actions/build
2727
with:
@@ -40,7 +40,7 @@ jobs:
4040
matrix:
4141
thread: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ]
4242
steps:
43-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
43+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
4444
- uses: prometheus/promci@443c7fc2397e946bc9f5029e313a9c3441b9b86d # v0.4.7
4545
- uses: ./.github/promci/actions/build
4646
with:
@@ -53,7 +53,7 @@ jobs:
5353
container:
5454
image: quay.io/prometheus/golang-builder:1.25-base
5555
steps:
56-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
56+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
5757
- run: make build
5858
- name: Verify example configs
5959
run: find ./examples -name "*.yml" -print0 | xargs -0 -I % ./yace verify-config -config.file %
@@ -63,11 +63,11 @@ jobs:
6363
runs-on: ubuntu-latest
6464
needs: [build_all, verify-example-configs]
6565
if: |
66-
(github.repository == 'prometheus-community/fortigate-exporter')
66+
(github.repository == 'prometheus-community/fortigate_exporter')
6767
&&
6868
(github.event_name == 'push' && github.event.ref == 'refs/heads/main')
6969
steps:
70-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
70+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
7171
- uses: prometheus/promci@443c7fc2397e946bc9f5029e313a9c3441b9b86d # v0.4.7
7272
- uses: ./.github/promci/actions/publish_main
7373
with:
@@ -83,11 +83,11 @@ jobs:
8383
runs-on: ubuntu-latest
8484
needs: [build_all, verify-example-configs]
8585
if: |
86-
(github.repository == 'prometheus-community/fortigate-exporter')
86+
(github.repository == 'prometheus-community/fortigate_exporter')
8787
&&
88-
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v0.'))
88+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
8989
steps:
90-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
90+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
9191
- uses: prometheus/promci@443c7fc2397e946bc9f5029e313a9c3441b9b86d # v0.4.7
9292
- uses: ./.github/promci/actions/publish_release
9393
with:

.github/workflows/container_description.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
if: github.repository_owner == 'prometheus' || github.repository_owner == 'prometheus-community' # Don't run this workflow on forks.
1919
steps:
2020
- name: git checkout
21-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2222
with:
2323
persist-credentials: false
2424
- name: Set docker hub repo name
@@ -42,7 +42,7 @@ jobs:
4242
if: github.repository_owner == 'prometheus' || github.repository_owner == 'prometheus-community' # Don't run this workflow on forks.
4343
steps:
4444
- name: git checkout
45-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
45+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
4646
with:
4747
persist-credentials: false
4848
- name: Set quay.io org name

.github/workflows/golangci-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ jobs:
2424
runs-on: ubuntu-latest
2525
steps:
2626
- name: Checkout repository
27-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
27+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2828
with:
2929
persist-credentials: false
3030
- name: Install Go
31-
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
31+
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
3232
with:
3333
go-version: 1.25.x
3434
- name: Install snmp_exporter/generator dependencies

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ Global:
5656
* `fortigate_current_sessions`
5757
* _System/HAChecksums_
5858
* `fortigate_ha_member_has_role`
59+
* _System/Ntp/Status_
60+
* `fortigate_system_ntp_delay_seconds`
61+
* `fortigate_system_ntp_dispersion_seconds`
62+
* `fortigate_system_ntp_dispersion_peer_seconds`
63+
* `fortigate_system_ntp_expires_seconds`
64+
* `fortigate_system_ntp_offset_seconds`
65+
* `fortigate_system_ntp_reftime_seconds`
66+
* `fortigate_system_ntp_stratum`
5967
* _License/Status_
6068
* `fortigate_license_vdom_usage`
6169
* `fortigate_license_vdom_max`
@@ -422,6 +430,7 @@ To improve security, limit permissions to required ones only (least privilege pr
422430
|System/HAStatistics | sysgrp.cfg |api/v2/monitor/system/ha-statistics<br>api/v2/cmdb/system/ha |
423431
|System/Interface | netgrp.cfg |api/v2/monitor/system/interface/select |
424432
|System/LinkMonitor | sysgrp.cfg |api/v2/monitor/system/link-monitor |
433+
|System/Ntp/Status | netgrp.cfg |api/v2/monitor/system/ntp/status |
425434
|System/Resource/Usage | sysgrp.cfg |api/v2/monitor/system/resource/usage |
426435
|System/SensorInfo | sysgrp.cfg |api/v2/monitor/system/sensor-info |
427436
|System/Status | *any* |api/v2/monitor/system/status |

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/prometheus-community/fortigate_exporter
33
go 1.24.0
44

55
require (
6-
github.com/google/go-jsonnet v0.20.0
6+
github.com/google/go-jsonnet v0.21.0
77
github.com/prometheus/client_golang v1.23.2
88
gopkg.in/yaml.v2 v2.4.0
99
)
@@ -18,7 +18,8 @@ require (
1818
github.com/prometheus/common v0.66.1 // indirect
1919
github.com/prometheus/procfs v0.16.1 // indirect
2020
go.yaml.in/yaml/v2 v2.4.2 // indirect
21+
golang.org/x/crypto v0.36.0 // indirect
2122
golang.org/x/sys v0.35.0 // indirect
2223
google.golang.org/protobuf v1.36.8 // indirect
23-
sigs.k8s.io/yaml v1.1.0 // indirect
24+
sigs.k8s.io/yaml v1.4.0 // indirect
2425
)

go.sum

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
55
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
66
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
77
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
8+
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
89
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
910
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
10-
github.com/google/go-jsonnet v0.20.0 h1:WG4TTSARuV7bSm4PMB4ohjxe33IHT5WVTrJSU33uT4g=
11-
github.com/google/go-jsonnet v0.20.0/go.mod h1:VbgWF9JX7ztlv770x/TolZNGGFfiHEVx9G6ca2eUmeA=
11+
github.com/google/go-jsonnet v0.21.0 h1:43Bk3K4zMRP/aAZm9Po2uSEjY6ALCkYUVIcz9HLGMvA=
12+
github.com/google/go-jsonnet v0.21.0/go.mod h1:tCGAu8cpUpEZcdGMmdOu37nh8bGgqubhI5v2iSk3KJQ=
1213
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
1314
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
1415
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
@@ -31,14 +32,16 @@ github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzM
3132
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
3233
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
3334
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
34-
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
35-
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
35+
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
36+
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
3637
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
3738
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
3839
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
3940
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
4041
go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI=
4142
go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU=
43+
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
44+
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
4245
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
4346
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
4447
google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc=
@@ -50,5 +53,5 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
5053
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
5154
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
5255
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
53-
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
54-
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
56+
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
57+
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=

pkg/probe/probe.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ func (p *ProbeCollector) Probe(ctx context.Context, target map[string]string, hc
146146
{"System/HAStatistics", probeSystemHAStatistics},
147147
{"System/Interface", probeSystemInterface},
148148
{"System/LinkMonitor", probeSystemLinkMonitor},
149+
{"System/Ntp/Status", probeSystemNtpStatus},
149150
{"System/Resource/Usage", probeSystemResourceUsage},
150151
{"System/SDNConnector", probeSystemSDNConnector},
151152
{"System/SensorInfo", probeSystemSensorInfo},

pkg/probe/system_ntp_status.go

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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+
"strconv"
19+
20+
"github.com/prometheus-community/fortigate_exporter/pkg/http"
21+
"github.com/prometheus/client_golang/prometheus"
22+
)
23+
24+
func probeSystemNtpStatus(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Metric, bool) {
25+
var (
26+
ntpExpires = prometheus.NewDesc(
27+
"fortigate_system_ntp_expires_seconds",
28+
"NTP expire time, in seconds",
29+
[]string{"ip", "server", "reachable", "selected", "version", "vdom"}, nil,
30+
)
31+
ntpStratum = prometheus.NewDesc(
32+
"fortigate_system_ntp_stratum",
33+
"NTP stratum value",
34+
[]string{"ip", "server", "reachable", "selected", "version", "vdom"}, nil,
35+
)
36+
ntpRefTime = prometheus.NewDesc(
37+
"fortigate_system_ntp_reftime_seconds",
38+
"NTP reftime in epoch seconds",
39+
[]string{"ip", "server", "reachable", "selected", "version", "vdom"}, nil,
40+
)
41+
ntpOffset = prometheus.NewDesc(
42+
"fortigate_system_ntp_offset_seconds",
43+
"NTP combined offset, in seconds",
44+
[]string{"ip", "server", "reachable", "selected", "version", "vdom"}, nil,
45+
)
46+
ntpDelay = prometheus.NewDesc(
47+
"fortigate_system_ntp_delay_seconds",
48+
"NTP round trip delay, in seconds",
49+
[]string{"ip", "server", "reachable", "selected", "version", "vdom"}, nil,
50+
)
51+
ntpDispersion = prometheus.NewDesc(
52+
"fortigate_system_ntp_dispersion_seconds",
53+
"NTP dispersion to primary clock, in seconds",
54+
[]string{"ip", "server", "reachable", "selected", "version", "vdom"}, nil,
55+
)
56+
ntpPeerDispersion = prometheus.NewDesc(
57+
"fortigate_system_ntp_dispersion_peer_seconds",
58+
"NTP peer dispersion, in seconds",
59+
[]string{"ip", "server", "reachable", "selected", "version", "vdom"}, nil,
60+
)
61+
)
62+
63+
type SystemNtpStatus struct {
64+
Ip string `json:"ip"`
65+
Server string `json:"server"`
66+
Reachable bool `json:"reachable"`
67+
Expires int `json:"expires"`
68+
Selected bool `json:"selected"`
69+
Version int `json:"version"`
70+
Stratum int `json:"stratum"`
71+
Reftime int `json:"reftime"`
72+
Offset float64 `json:"offset"`
73+
Delay float64 `json:"delay"`
74+
Dispersion float64 `json:"dispersion"`
75+
PeerDispersion int `json:"peer_dispersion"`
76+
}
77+
78+
type SystemNtpStatusResult struct {
79+
Results []SystemNtpStatus `json:"results"`
80+
VDOM string `json:"vdom"`
81+
}
82+
83+
var result []SystemNtpStatusResult
84+
if err := c.Get("api/v2/monitor/system/ntp/status","vdom=*",&result); err != nil {
85+
log.Printf("Error: %v", err)
86+
return nil, false
87+
}
88+
89+
m := []prometheus.Metric{}
90+
if meta.VersionMajor >=7 && meta.VersionMinor >=4 {
91+
for _, res := range result {
92+
for _, r := range res.Results {
93+
m = append(m, prometheus.MustNewConstMetric(ntpExpires, prometheus.GaugeValue, float64(r.Expires), r.Ip, r.Server, strconv.FormatBool(r.Reachable), strconv.FormatBool(r.Reachable), strconv.Itoa(r.Version), res.VDOM))
94+
m = append(m, prometheus.MustNewConstMetric(ntpStratum, prometheus.GaugeValue, float64(r.Stratum), r.Ip, r.Server, strconv.FormatBool(r.Reachable), strconv.FormatBool(r.Reachable), strconv.Itoa(r.Version), res.VDOM))
95+
m = append(m, prometheus.MustNewConstMetric(ntpRefTime, prometheus.CounterValue, float64(r.Reftime), r.Ip, r.Server, strconv.FormatBool(r.Reachable), strconv.FormatBool(r.Reachable), strconv.Itoa(r.Version), res.VDOM))
96+
m = append(m, prometheus.MustNewConstMetric(ntpOffset, prometheus.GaugeValue, float64(r.Offset) * 0.001, r.Ip, r.Server, strconv.FormatBool(r.Reachable), strconv.FormatBool(r.Reachable), strconv.Itoa(r.Version), res.VDOM))
97+
m = append(m, prometheus.MustNewConstMetric(ntpDelay, prometheus.GaugeValue, float64(r.Delay) * 0.001, r.Ip, r.Server, strconv.FormatBool(r.Reachable), strconv.FormatBool(r.Reachable), strconv.Itoa(r.Version), res.VDOM))
98+
m = append(m, prometheus.MustNewConstMetric(ntpDispersion, prometheus.GaugeValue, float64(r.Dispersion) * 0.001, r.Ip, r.Server, strconv.FormatBool(r.Reachable), strconv.FormatBool(r.Reachable), strconv.Itoa(r.Version), res.VDOM))
99+
m = append(m, prometheus.MustNewConstMetric(ntpPeerDispersion, prometheus.GaugeValue, float64(r.PeerDispersion) * 0.001, r.Ip, r.Server, strconv.FormatBool(r.Reachable), strconv.FormatBool(r.Reachable), strconv.Itoa(r.Version), res.VDOM))
100+
}
101+
}
102+
} else {
103+
log.Printf("Not implemented in versions under 7.4")
104+
}
105+
return m, true
106+
}

0 commit comments

Comments
 (0)