@@ -51,47 +51,47 @@ func probeSystemPerformanceStatus(c http.FortiHTTP, meta *TargetMetadata) ([]pro
5151 cpuUser = prometheus .NewDesc (
5252 "fortigate_system_performance_status_cpu_user" ,
5353 "Percentage of CPU utilization that occurred at the user level." ,
54- []string {"label" , " vdom" }, nil ,
54+ []string {"vdom" }, nil ,
5555 )
5656 cpuSystem = prometheus .NewDesc (
5757 "fortigate_system_performance_status_cpu_system" ,
5858 "Percentage of CPU utilization that occurred while executing at the system level." ,
59- []string {"label" , " vdom" }, nil ,
59+ []string {"vdom" }, nil ,
6060 )
6161 cpuNice = prometheus .NewDesc (
6262 "fortigate_system_performance_status_cpu_nice" ,
6363 "Percentage of CPU utilization that occurred while executing at the user level with nice priority." ,
64- []string {"label" , " vdom" }, nil ,
64+ []string {"vdom" }, nil ,
6565 )
6666 cpuIdle = prometheus .NewDesc (
6767 "fortigate_system_performance_status_cpu_idle" ,
6868 "Percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request." ,
69- []string {"label" , " vdom" }, nil ,
69+ []string {"vdom" }, nil ,
7070 )
7171 cpuIowait = prometheus .NewDesc (
7272 "fortigate_system_performance_status_cpu_iowait" ,
7373 "Percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request." ,
74- []string {"label" , " vdom" }, nil ,
74+ []string {"vdom" }, nil ,
7575 )
7676 memTotal = prometheus .NewDesc (
7777 "fortigate_system_performance_status_mem_total" ,
7878 "All the installed memory in RAM, in bytes." ,
79- []string {"label" , " vdom" }, nil ,
79+ []string {"vdom" }, nil ,
8080 )
8181 memUsed = prometheus .NewDesc (
8282 "fortigate_system_performance_status_mem_used" ,
8383 "Memory are being used, in bytes." ,
84- []string {"label" , " vdom" }, nil ,
84+ []string {"vdom" }, nil ,
8585 )
8686 memFree = prometheus .NewDesc (
8787 "fortigate_system_performance_status_mem_free" ,
8888 "All the memory in RAM that is not being used for anything (even caches), in bytes." ,
89- []string {"label" , " vdom" }, nil ,
89+ []string {"vdom" }, nil ,
9090 )
9191 memFreeable = prometheus .NewDesc (
9292 "fortigate_system_performance_status_mem_freeable" ,
9393 "Freeable buffers/caches memory, in bytes." ,
94- []string {"label" , " vdom" }, nil ,
94+ []string {"vdom" }, nil ,
9595 )
9696 )
9797
@@ -125,39 +125,33 @@ func probeSystemPerformanceStatus(c http.FortiHTTP, meta *TargetMetadata) ([]pro
125125 }
126126
127127 type SystemPerformanceStatusResult struct {
128- Results [] SystemPerformanceStatus `json:"results"`
129- VDOM string `json:"vdom"`
128+ Results SystemPerformanceStatus `json:"results"`
129+ VDOM string `json:"vdom"`
130130 }
131131
132- var result [] SystemPerformanceStatusResult
133- if err := c .Get ("api/v2/monitor/system/performance/status" , "vdom=* " , & result ); err != nil {
132+ var res SystemPerformanceStatusResult
133+ if err := c .Get ("api/v2/monitor/system/performance/status" , "" , & res ); err != nil {
134134 log .Printf ("Error: %v" , err )
135135 return nil , false
136136 }
137137 m := []prometheus.Metric {}
138- var cpu_num , mem_num , core_num string
139- for _ , res := range result {
140- for n , r := range res .Results {
141- cpu_num = "cpu_" + strconv .Itoa (n )
142- mem_num = "mem_" + strconv .Itoa (n )
143- for i , core := range r .Cpu .Cores {
144- core_num = "core_" + strconv .Itoa (i )
145- m = append (m , prometheus .MustNewConstMetric (cpuCoresUser , prometheus .GaugeValue , float64 (core .User ), cpu_num + "_" + core_num , res .VDOM ))
146- m = append (m , prometheus .MustNewConstMetric (cpuCoresSystem , prometheus .GaugeValue , float64 (core .System ), cpu_num + "_" + core_num , res .VDOM ))
147- m = append (m , prometheus .MustNewConstMetric (cpuCoresNice , prometheus .GaugeValue , float64 (core .Nice ), cpu_num + "_" + core_num , res .VDOM ))
148- m = append (m , prometheus .MustNewConstMetric (cpuCoresIdle , prometheus .GaugeValue , float64 (core .Idle ), cpu_num + "_" + core_num , res .VDOM ))
149- m = append (m , prometheus .MustNewConstMetric (cpuCoresIowait , prometheus .GaugeValue , float64 (core .Iowait ), cpu_num + "_" + core_num , res .VDOM ))
150- }
151- m = append (m , prometheus .MustNewConstMetric (cpuUser ,prometheus .GaugeValue , float64 (r .Cpu .User ), cpu_num , res .VDOM ))
152- m = append (m , prometheus .MustNewConstMetric (cpuSystem ,prometheus .GaugeValue , float64 (r .Cpu .System ), cpu_num , res .VDOM ))
153- m = append (m , prometheus .MustNewConstMetric (cpuNice ,prometheus .GaugeValue , float64 (r .Cpu .Nice ), cpu_num , res .VDOM ))
154- m = append (m , prometheus .MustNewConstMetric (cpuIdle ,prometheus .GaugeValue , float64 (r .Cpu .Idle ), cpu_num , res .VDOM ))
155- m = append (m , prometheus .MustNewConstMetric (cpuIowait ,prometheus .GaugeValue , float64 (r .Cpu .Iowait ), cpu_num , res .VDOM ))
156- m = append (m , prometheus .MustNewConstMetric (memTotal ,prometheus .GaugeValue , float64 (r .Mem .Total ), mem_num , res .VDOM ))
157- m = append (m , prometheus .MustNewConstMetric (memUsed ,prometheus .GaugeValue , float64 (r .Mem .Used ), mem_num , res .VDOM ))
158- m = append (m , prometheus .MustNewConstMetric (memFree ,prometheus .GaugeValue , float64 (r .Mem .Free ), mem_num , res .VDOM ))
159- m = append (m , prometheus .MustNewConstMetric (memFreeable ,prometheus .GaugeValue , float64 (r .Mem .Freeable ), mem_num , res .VDOM ))
160- }
138+ var core_num string
139+ for i , core := range res .Results .Cpu .Cores {
140+ core_num = "core_" + strconv .Itoa (i )
141+ m = append (m , prometheus .MustNewConstMetric (cpuCoresUser , prometheus .GaugeValue , float64 (core .User ), core_num , res .VDOM ))
142+ m = append (m , prometheus .MustNewConstMetric (cpuCoresSystem , prometheus .GaugeValue , float64 (core .System ), core_num , res .VDOM ))
143+ m = append (m , prometheus .MustNewConstMetric (cpuCoresNice , prometheus .GaugeValue , float64 (core .Nice ), core_num , res .VDOM ))
144+ m = append (m , prometheus .MustNewConstMetric (cpuCoresIdle , prometheus .GaugeValue , float64 (core .Idle ), core_num , res .VDOM ))
145+ m = append (m , prometheus .MustNewConstMetric (cpuCoresIowait , prometheus .GaugeValue , float64 (core .Iowait ), core_num , res .VDOM ))
161146 }
147+ m = append (m , prometheus .MustNewConstMetric (cpuUser ,prometheus .GaugeValue , float64 (res .Results .Cpu .User ), res .VDOM ))
148+ m = append (m , prometheus .MustNewConstMetric (cpuSystem ,prometheus .GaugeValue , float64 (res .Results .Cpu .System ), res .VDOM ))
149+ m = append (m , prometheus .MustNewConstMetric (cpuNice ,prometheus .GaugeValue , float64 (res .Results .Cpu .Nice ), res .VDOM ))
150+ m = append (m , prometheus .MustNewConstMetric (cpuIdle ,prometheus .GaugeValue , float64 (res .Results .Cpu .Idle ), res .VDOM ))
151+ m = append (m , prometheus .MustNewConstMetric (cpuIowait ,prometheus .GaugeValue , float64 (res .Results .Cpu .Iowait ), res .VDOM ))
152+ m = append (m , prometheus .MustNewConstMetric (memTotal ,prometheus .GaugeValue , float64 (res .Results .Mem .Total ), res .VDOM ))
153+ m = append (m , prometheus .MustNewConstMetric (memUsed ,prometheus .GaugeValue , float64 (res .Results .Mem .Used ), res .VDOM ))
154+ m = append (m , prometheus .MustNewConstMetric (memFree ,prometheus .GaugeValue , float64 (res .Results .Mem .Free ), res .VDOM ))
155+ m = append (m , prometheus .MustNewConstMetric (memFreeable ,prometheus .GaugeValue , float64 (res .Results .Mem .Freeable ), res .VDOM ))
162156 return m , true
163157}
0 commit comments