Skip to content

Commit 06ec9f6

Browse files
committed
feat: Added hostname & model labels to info metric
Signed-off-by: Bassam Omar <obassam60@gmail.com>
1 parent fafbd96 commit 06ec9f6

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

pkg/probe/system_status.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func probeSystemStatus(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Met
2626
mVersion = prometheus.NewDesc(
2727
"fortigate_version_info",
2828
"System version and build information",
29-
[]string{"serial", "version", "build"}, nil,
29+
[]string{"hostname", "model", "serial", "version", "build"}, nil,
3030
)
3131
)
3232

@@ -35,6 +35,10 @@ func probeSystemStatus(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Met
3535
Serial string
3636
Version string
3737
Build int64
38+
Results struct {
39+
Model string
40+
Hostname string
41+
}
3842
}
3943
var st systemStatus
4044

@@ -44,7 +48,7 @@ func probeSystemStatus(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Met
4448
}
4549

4650
m := []prometheus.Metric{
47-
prometheus.MustNewConstMetric(mVersion, prometheus.GaugeValue, 1.0, st.Serial, st.Version, fmt.Sprintf("%d", st.Build)),
51+
prometheus.MustNewConstMetric(mVersion, prometheus.GaugeValue, 1.0, st.Results.Hostname, st.Results.Model, st.Serial, st.Version, fmt.Sprintf("%d", st.Build)),
4852
}
4953
return m, true
5054
}

pkg/probe/system_status_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestSystemStatus(t *testing.T) {
3232
em := `
3333
# HELP fortigate_version_info System version and build information
3434
# TYPE fortigate_version_info gauge
35-
fortigate_version_info{build="1112",serial="FGVMEVZFNTS3OAC8",version="v6.2.4"} 1
35+
fortigate_version_info{build="1112",hostname="Firewall1",model="FG800D",serial="FGVMEVZFNTS3OAC8",version="v6.2.4"} 1
3636
`
3737

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

pkg/probe/testdata/status.jsonnet

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
{
33
"http_method":"GET",
44
"results":{
5+
"model_name":"FortiGate",
6+
"model_number":"800D",
7+
"model":"FG800D",
8+
"hostname":"Firewall1",
9+
"log_disk_status":"not_available"
510
},
611
"vdom":"root",
712
"path":"system",

0 commit comments

Comments
 (0)