Skip to content

Commit a03e09f

Browse files
Version 7.6 of system status (#367)
* Version 7.6 of system status Signed-off-by: Örnfeldt Philip (66140321) <philip.ornfeldt@forsakringskassan.se> * New stateset implemented Signed-off-by: Philip Örnfeldt <philip.ornfeldt@outlook.com> * Added entry to metric.md Signed-off-by: Örnfeldt Philip (66140321) <philip.ornfeldt@forsakringskassan.se> * Typo and clarification on model information, removed labels on disk state Signed-off-by: Philip Örnfeldt <philip.ornfeldt@outlook.com> --------- Signed-off-by: Örnfeldt Philip (66140321) <philip.ornfeldt@forsakringskassan.se> Signed-off-by: Philip Örnfeldt <philip.ornfeldt@outlook.com> Co-authored-by: Sebastian Schubert <16682281+bastischubert@users.noreply.github.com>
1 parent 9f611b1 commit a03e09f

4 files changed

Lines changed: 40 additions & 4 deletions

File tree

metrics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Global:
1414
* `fortigate_sensor_thresholds`
1515
* _System/Status_
1616
* `fortigate_version_info`
17+
* `fortigate_system_status_log_disk_state`
1718
* _System/Transceivers_
1819
* `fortigate_interface_transceivers`
1920
* _System/Time/Clock_

pkg/probe/system_status.go

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,28 @@ func probeSystemStatus(c http.FortiHTTP, _ *TargetMetadata) ([]prometheus.Metric
2626
mVersion := prometheus.NewDesc(
2727
"fortigate_version_info",
2828
"System version and build information",
29-
[]string{"serial", "version", "build"}, nil,
29+
[]string{"serial", "version", "build", "model_name", "model_number", "model", "hostname"}, nil,
3030
)
31+
mLogDiskState := prometheus.NewDesc(
32+
"fortigate_system_status_log_disk_state",
33+
"System log disk availability state",
34+
[]string{"state"}, nil,
35+
)
36+
37+
type systemResult struct {
38+
Name string `json:"model_name"`
39+
Number string `json:"model_number"`
40+
Model string `json:"model"`
41+
Hostname string `json:"hostname"`
42+
LogDiskStatus string `json:"log_disk_status"`
43+
}
3144

3245
type systemStatus struct {
3346
Status string
3447
Serial string
3548
Version string
3649
Build int64
50+
Results systemResult
3751
}
3852
var st systemStatus
3953

@@ -43,7 +57,18 @@ func probeSystemStatus(c http.FortiHTTP, _ *TargetMetadata) ([]prometheus.Metric
4357
}
4458

4559
m := []prometheus.Metric{
46-
prometheus.MustNewConstMetric(mVersion, prometheus.GaugeValue, 1.0, st.Serial, st.Version, fmt.Sprintf("%d", st.Build)),
60+
prometheus.MustNewConstMetric(mLogDiskState, prometheus.GaugeValue, 0.0, "available"),
61+
prometheus.MustNewConstMetric(mLogDiskState, prometheus.GaugeValue, 0.0, "need_format"),
62+
prometheus.MustNewConstMetric(mLogDiskState, prometheus.GaugeValue, 0.0, "not_available"),
63+
}
64+
switch st.Results.LogDiskStatus {
65+
case "available":
66+
m[0] = prometheus.MustNewConstMetric(mLogDiskState, prometheus.GaugeValue, 1.0, st.Results.LogDiskStatus)
67+
case "need_format":
68+
m[1] = prometheus.MustNewConstMetric(mLogDiskState, prometheus.GaugeValue, 1.0, st.Results.LogDiskStatus)
69+
case "not_available":
70+
m[2] = prometheus.MustNewConstMetric(mLogDiskState, prometheus.GaugeValue, 1.0, st.Results.LogDiskStatus)
4771
}
72+
m = append(m, prometheus.MustNewConstMetric(mVersion, prometheus.GaugeValue, 1.0, st.Serial, st.Version, fmt.Sprintf("%d", st.Build), st.Results.Name, st.Results.Number, st.Results.Model, st.Results.Hostname))
4873
return m, true
4974
}

pkg/probe/system_status_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,14 @@ func TestSystemStatus(t *testing.T) {
3030
}
3131

3232
em := `
33+
# HELP fortigate_system_status_log_disk_state System log disk availability state
34+
# TYPE fortigate_system_status_log_disk_state gauge
35+
fortigate_system_status_log_disk_state{state="available"} 0
36+
fortigate_system_status_log_disk_state{state="need_format"} 0
37+
fortigate_system_status_log_disk_state{state="not_available"} 1
3338
# HELP fortigate_version_info System version and build information
3439
# TYPE fortigate_version_info gauge
35-
fortigate_version_info{build="1112",serial="FGVMEVZFNTS3OAC8",version="v6.2.4"} 1
40+
fortigate_version_info{build="1112",hostname="fgt-test-1",model="F2K60F",model_name="FortiGate",model_number="2600F",serial="FGVMEVZFNTS3OAC8",version="v6.2.4"} 1
3641
`
3742

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

pkg/probe/testdata/status.jsonnet

Lines changed: 6 additions & 1 deletion
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":"2600F",
7+
"model":"F2K60F",
8+
"hostname":"fgt-test-1",
9+
"log_disk_status":"not_available"
510
},
611
"vdom":"root",
712
"path":"system",
@@ -10,4 +15,4 @@
1015
"serial":"FGVMEVZFNTS3OAC8",
1116
"version":"v6.2.4",
1217
"build":1112
13-
}
18+
}

0 commit comments

Comments
 (0)