@@ -26,72 +26,72 @@ func probeSystemPerformanceStatus(c http.FortiHTTP, meta *TargetMetadata) ([]pro
2626 cpuCoresUser = prometheus .NewDesc (
2727 "fortigate_system_performance_status_cpu_cores_user" ,
2828 "Percentage of CPU utilization that occurred at the user level." ,
29- []string {"label" }, nil ,
29+ []string {"label" , "vdom" }, nil ,
3030 )
3131 cpuCoresSystem = prometheus .NewDesc (
3232 "fortigate_system_performance_status_cpu_cores_system" ,
3333 "Percentage of CPU utilization that occurred while executing at the system level." ,
34- []string {"label" }, nil ,
34+ []string {"label" , "vdom" }, nil ,
3535 )
3636 cpuCoresNice = prometheus .NewDesc (
3737 "fortigate_system_performance_status_cpu_cores_nice" ,
3838 "Percentage of CPU utilization that occurred while executing at the user level with nice priority." ,
39- []string {"label" }, nil ,
39+ []string {"label" , "vdom" }, nil ,
4040 )
4141 cpuCoresIdle = prometheus .NewDesc (
4242 "fortigate_system_performance_status_cpu_cores_idle" ,
4343 "Percentage of time that the CPU was idle and the system did not have an outstanding disk I/O request." ,
44- []string {"label" }, nil ,
44+ []string {"label" , "vdom" }, nil ,
4545 )
4646 cpuCoresIowait = prometheus .NewDesc (
4747 "fortigate_system_performance_status_cpu_cores_iowait" ,
4848 "Percentage of time that the CPU was idle during which the system had an outstanding disk I/O request." ,
49- []string {"label" }, nil ,
49+ []string {"label" , "vdom" }, nil ,
5050 )
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" }, nil ,
54+ []string {"label" , "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" }, nil ,
59+ []string {"label" , "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" }, nil ,
64+ []string {"label" , "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" }, nil ,
69+ []string {"label" , "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" }, nil ,
74+ []string {"label" , "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" }, nil ,
79+ []string {"label" , "vdom" }, nil ,
8080 )
8181 memUsed = prometheus .NewDesc (
8282 "fortigate_system_performance_status_mem_used" ,
8383 "Memory are being used, in bytes." ,
84- []string {"label" }, nil ,
84+ []string {"label" , "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" }, nil ,
89+ []string {"label" , "vdom" }, nil ,
9090 )
9191 memFreeable = prometheus .NewDesc (
9292 "fortigate_system_performance_status_mem_freeable" ,
9393 "Freeable buffers/caches memory, in bytes." ,
94- []string {"label" }, nil ,
94+ []string {"label" , "vdom" }, nil ,
9595 )
9696 )
9797
@@ -126,36 +126,38 @@ func probeSystemPerformanceStatus(c http.FortiHTTP, meta *TargetMetadata) ([]pro
126126
127127 type SystemPerformanceStatusResult struct {
128128 Results []SystemPerformanceStatus `json:"results"`
129+ VDOM string `json:"vdom"`
129130 }
130131
131- var res SystemPerformanceStatusResult
132- if err := c .Get ("api/v2/monitor/system/performance/status" , "" , & res ); err != nil {
132+ var result [] SystemPerformanceStatusResult
133+ if err := c .Get ("api/v2/monitor/system/performance/status" , "vdom=* " , & result ); err != nil {
133134 log .Printf ("Error: %v" , err )
134135 return nil , false
135136 }
136137 m := []prometheus.Metric {}
137138 var cpu_num , mem_num , core_num string
138- for n , r := range res .Results {
139- cpu_num = "cpu_" + strconv .Itoa (n )
140- mem_num = "mem_" + strconv .Itoa (n )
141- for i , core := range r .Cpu .Cores {
142- core_num = "core_" + strconv .Itoa (i )
143- m = append (m , prometheus .MustNewConstMetric (cpuCoresUser , prometheus .GaugeValue , float64 (core .User ), cpu_num + "_" + core_num ))
144- m = append (m , prometheus .MustNewConstMetric (cpuCoresSystem , prometheus .GaugeValue , float64 (core .System ), cpu_num + "_" + core_num ))
145- m = append (m , prometheus .MustNewConstMetric (cpuCoresNice , prometheus .GaugeValue , float64 (core .Nice ), cpu_num + "_" + core_num ))
146- m = append (m , prometheus .MustNewConstMetric (cpuCoresIdle , prometheus .GaugeValue , float64 (core .Idle ), cpu_num + "_" + core_num ))
147- m = append (m , prometheus .MustNewConstMetric (cpuCoresIowait , prometheus .GaugeValue , float64 (core .Iowait ), cpu_num + "_" + core_num ))
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 ))
148160 }
149- m = append (m , prometheus .MustNewConstMetric (cpuUser ,prometheus .GaugeValue , float64 (r .Cpu .User ), cpu_num ))
150- m = append (m , prometheus .MustNewConstMetric (cpuSystem ,prometheus .GaugeValue , float64 (r .Cpu .System ), cpu_num ))
151- m = append (m , prometheus .MustNewConstMetric (cpuNice ,prometheus .GaugeValue , float64 (r .Cpu .Nice ), cpu_num ))
152- m = append (m , prometheus .MustNewConstMetric (cpuIdle ,prometheus .GaugeValue , float64 (r .Cpu .Idle ), cpu_num ))
153- m = append (m , prometheus .MustNewConstMetric (cpuIowait ,prometheus .GaugeValue , float64 (r .Cpu .Iowait ), cpu_num ))
154- m = append (m , prometheus .MustNewConstMetric (memTotal ,prometheus .GaugeValue , float64 (r .Mem .Total ), mem_num ))
155- m = append (m , prometheus .MustNewConstMetric (memUsed ,prometheus .GaugeValue , float64 (r .Mem .Used ), mem_num ))
156- m = append (m , prometheus .MustNewConstMetric (memFree ,prometheus .GaugeValue , float64 (r .Mem .Free ), mem_num ))
157- m = append (m , prometheus .MustNewConstMetric (memFreeable ,prometheus .GaugeValue , float64 (r .Mem .Freeable ), mem_num ))
158161 }
159-
160162 return m , true
161163}
0 commit comments