-
Notifications
You must be signed in to change notification settings - Fork 18
/
jvm.go
491 lines (447 loc) · 21.6 KB
/
jvm.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"github.com/blang/semver"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log"
)
var jvmPath = "/admin/metrics?group=jvm&wt=json"
var solrInfoPath = "/admin/info/system?wt=json"
//JVMCollector collects JVM type metrics from solr
type JVMCollector struct {
gcConcurrentMarkSweepCount *prometheus.Desc
gcConcurrentMarkSweepTime *prometheus.Desc
gcParNewCount *prometheus.Desc
gcParNewTime *prometheus.Desc
memoryHeapCommitted *prometheus.Desc
memoryHeapInit *prometheus.Desc
memoryHeapMax *prometheus.Desc
memoryHeapUsage *prometheus.Desc
memoryHeapUsed *prometheus.Desc
memoryNonHeapCommitted *prometheus.Desc
memoryNonHeapInit *prometheus.Desc
memoryNonHeapMax *prometheus.Desc
memoryNonHeapUsage *prometheus.Desc
memoryNonHeapUsed *prometheus.Desc
memoryTotalCommitted *prometheus.Desc
memoryTotalInit *prometheus.Desc
memoryTotalMax *prometheus.Desc
memoryTotalUsed *prometheus.Desc
osAvailableProcessors *prometheus.Desc
osCommittedVirtualMemorySize *prometheus.Desc
osFreePhysicalMemorySize *prometheus.Desc
osFreeSwapSpaceSize *prometheus.Desc
osMaxFileDescriptorCount *prometheus.Desc
osOpenFileDescriptorCount *prometheus.Desc
osProcessCPUTime *prometheus.Desc
osSystemLoadAverage *prometheus.Desc
osTotalPhysicalMemorySize *prometheus.Desc
osTotalSwapSapceSize *prometheus.Desc
threadsBlockedCount *prometheus.Desc
threadsDaemonCount *prometheus.Desc
threadsDeadlockCount *prometheus.Desc
threadsNewCount *prometheus.Desc
threadsRunnableCount *prometheus.Desc
threadsTerminatedCount *prometheus.Desc
threadsTimedWaitingCount *prometheus.Desc
threadsWaitingCount *prometheus.Desc
client http.Client
jvmURL string
solrInfoURL string
}
// NewJVMCollector returns a new Collector exposing solr jvm statistics.
func NewJVMCollector(client http.Client, solrBaseURL string) (*JVMCollector, error) {
jvmURL := fmt.Sprintf("%s%s", solrBaseURL, jvmPath)
solrInfoURL := fmt.Sprintf("%s%s", solrBaseURL, solrInfoPath)
return &JVMCollector{
gcConcurrentMarkSweepCount: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "gc_concurrentmarksweep_count"),
"Garbage collector concurrent mark sweep count.",
[]string{}, nil,
),
gcConcurrentMarkSweepTime: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "gc_concurrentmarksweep_time"),
"Garbage collector concurrent mark sweep time in miliseconds.",
[]string{},
nil,
),
gcParNewCount: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "gc_parnew_count"),
"Garbage collector parnew count.",
[]string{},
nil,
),
gcParNewTime: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "gc_parnew_time"),
"Garbage collector parnew time in miliseconds.",
[]string{},
nil,
),
memoryHeapCommitted: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "memory_heap_committed"),
"JVM memory heap committed bytes.",
[]string{},
nil,
),
memoryHeapInit: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "memory_heap_init"),
"JVM memory heap initial bytes.",
[]string{},
nil,
),
memoryHeapMax: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "memory_heap_max"),
"JVM memory heap max bytes.",
[]string{},
nil,
),
memoryHeapUsage: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "memory_heap_usage"),
"JVM memory heap percentage usage.",
[]string{},
nil,
),
memoryHeapUsed: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "memory_heap_used"),
"JVM memory heap used bytes.",
[]string{},
nil,
),
memoryNonHeapCommitted: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "memory_nonheap_committed"),
"JVM memory non heap committed bytes.",
[]string{},
nil,
),
memoryNonHeapInit: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "memory_nonheap_init"),
"JVM memory non heap initial bytes.",
[]string{},
nil,
),
memoryNonHeapMax: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "memory_nonheap_max"),
"JVM memory non heap max bytes.",
[]string{},
nil,
),
memoryNonHeapUsage: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "memory_nonheap_usage"),
"JVM memory non heap percentage usage.",
[]string{},
nil,
),
memoryNonHeapUsed: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "memory_nonheap_used"),
"JVM memory non heap used bytes.",
[]string{},
nil,
),
memoryTotalCommitted: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "memory_total_committed"),
"JVM memory total committed bytes.",
[]string{},
nil,
),
memoryTotalInit: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "memory_total_init"),
"JVM memory total initial bytes.",
[]string{},
nil,
),
memoryTotalMax: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "memory_total_max"),
"JVM memory total max bytes.",
[]string{},
nil,
),
memoryTotalUsed: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "memory_total_used"),
"JVM memory total used bytes.",
[]string{},
nil,
),
osAvailableProcessors: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "os_availableprocessors"),
"Avaialable number of processors.",
[]string{},
nil,
),
osCommittedVirtualMemorySize: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "os_committedvirtualmemorysize"),
"Operating system committed virtual memory size in bytes.",
[]string{},
nil,
),
osFreePhysicalMemorySize: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "os_freephysicalmemorysize"),
"Operating system free physical memory in bytes.",
[]string{},
nil,
),
osFreeSwapSpaceSize: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "os_freeswapspacesize"),
"Operating system free swap memory in bytes.",
[]string{},
nil,
),
osMaxFileDescriptorCount: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "os_maxfiledescriptorcount"),
"Operating system maximum number of open file descriptors.",
[]string{},
nil,
),
osOpenFileDescriptorCount: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "os_openfiledescriptorcount"),
"Operating system current number of open file descriptors.",
[]string{},
nil,
),
osProcessCPUTime: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "os_processcputime"),
"Time process was running on the cpu in milliseconds.",
[]string{},
nil,
),
osSystemLoadAverage: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "os_systemloadaverage"),
"Operating system load average.",
[]string{},
nil,
),
osTotalPhysicalMemorySize: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "os_totalphysicalmemorysize"),
"Operating System total physical memory size in bytes.",
[]string{},
nil,
),
osTotalSwapSapceSize: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "os_totalswapspacesize"),
"Operating System totale swap memory size in bytes.",
[]string{},
nil,
),
threadsBlockedCount: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "threads_blocked_count"),
"Count of blocked threads.",
[]string{},
nil,
),
threadsDaemonCount: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "threads_daemon_conut"),
"Count of daemon threads.",
[]string{},
nil,
),
threadsDeadlockCount: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "threads_deadlock_count"),
"Count of deadlocked threads.",
[]string{},
nil,
),
threadsNewCount: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "threads_new_count"),
"Count of new threads.",
[]string{},
nil,
),
threadsRunnableCount: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "threads_runnable_count"),
"Count of runnable threads.",
[]string{},
nil,
),
threadsTerminatedCount: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "threads_terminated_count"),
"Count of terminated threads.",
[]string{},
nil,
),
threadsTimedWaitingCount: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "threads_timedwaiting_count"),
"Count of threads in timed_waiting state.",
[]string{},
nil,
),
threadsWaitingCount: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "threads_waiting_count"),
"Count of waiting threads.",
[]string{},
nil,
),
client: client,
jvmURL: jvmURL,
solrInfoURL: solrInfoURL,
}, nil
}
// Update exposes jvm related metrics from solr.
func (c *JVMCollector) Update(ch chan<- prometheus.Metric) error {
resp, err := c.client.Get(c.solrInfoURL)
if err != nil {
return fmt.Errorf("Error while querying Solr for infos : %v", err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("Failed to read infos response body: %v", err)
}
infoSystem := &InfoSystem{}
err = json.Unmarshal(body, infoSystem)
if err != nil {
return fmt.Errorf("Failed to unmarshal solr infos JSON into struct: %v", err)
}
semanticVersion, err := semver.Make(infoSystem.Lucene.SolrVersion)
if err != nil {
return fmt.Errorf("Error parsing version string: %v", err)
}
semanticVersionSolr6, err := semver.Make("6.0.0")
semanticVersionSolr7, err := semver.Make("7.0.0")
// No jvm stats for solr < 6
if semanticVersion.LT(semanticVersionSolr6) {
return nil
}
resp, err = c.client.Get(c.jvmURL)
if err != nil {
return fmt.Errorf("Error while querying Solr for jvm stats: %v", err)
}
defer resp.Body.Close()
body, err = ioutil.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("Failed to read jvm stats response body: %v", err)
}
if semanticVersion.LT(semanticVersionSolr7) == true {
jvmStatus := &JVMStatusV6{}
err = json.Unmarshal(body, jvmStatus)
if err != nil {
return fmt.Errorf("Failed to unmarshal solr jvm JSON into struct: %v", err)
}
ch <- prometheus.MustNewConstMetric(c.gcConcurrentMarkSweepCount, prometheus.CounterValue, float64(jvmStatus.Metrics.JVM.GCConcurrentMarkSweepCount.Value))
ch <- prometheus.MustNewConstMetric(c.gcConcurrentMarkSweepTime, prometheus.CounterValue, float64(jvmStatus.Metrics.JVM.GCConcurrentMarkSweepTime.Value))
ch <- prometheus.MustNewConstMetric(c.gcParNewCount, prometheus.CounterValue, float64(jvmStatus.Metrics.JVM.GCParNewCount.Value))
ch <- prometheus.MustNewConstMetric(c.gcParNewTime, prometheus.CounterValue, float64(jvmStatus.Metrics.JVM.GCParNewTime.Value))
ch <- prometheus.MustNewConstMetric(c.memoryHeapCommitted, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryHeapCommitted.Value))
ch <- prometheus.MustNewConstMetric(c.memoryHeapInit, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryHeapInit.Value))
ch <- prometheus.MustNewConstMetric(c.memoryHeapMax, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryHeapMax.Value))
ch <- prometheus.MustNewConstMetric(c.memoryHeapUsage, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryHeapUsage.Value))
ch <- prometheus.MustNewConstMetric(c.memoryHeapUsed, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryHeapUsed.Value))
ch <- prometheus.MustNewConstMetric(c.memoryNonHeapCommitted, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryNonHeapCommitted.Value))
ch <- prometheus.MustNewConstMetric(c.memoryNonHeapInit, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryNonHeapInit.Value))
ch <- prometheus.MustNewConstMetric(c.memoryNonHeapMax, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryNonHeapMax.Value))
ch <- prometheus.MustNewConstMetric(c.memoryNonHeapUsage, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryNonHeapUsage.Value))
ch <- prometheus.MustNewConstMetric(c.memoryNonHeapUsed, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryNonHeapUsed.Value))
ch <- prometheus.MustNewConstMetric(c.memoryTotalCommitted, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryTotalCommitted.Value))
ch <- prometheus.MustNewConstMetric(c.memoryTotalInit, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryTotalInit.Value))
ch <- prometheus.MustNewConstMetric(c.memoryTotalMax, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryTotalMax.Value))
ch <- prometheus.MustNewConstMetric(c.memoryTotalUsed, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryTotalUsed.Value))
ch <- prometheus.MustNewConstMetric(c.osAvailableProcessors, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.OSAvailableProcessors.Value))
ch <- prometheus.MustNewConstMetric(c.osCommittedVirtualMemorySize, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.OSCommittedVirtualMemorySize.Value))
ch <- prometheus.MustNewConstMetric(c.osFreePhysicalMemorySize, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.OSFreePhysicalMemorySize.Value))
ch <- prometheus.MustNewConstMetric(c.osFreeSwapSpaceSize, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.OSFreeSwapSpaceSize.Value))
ch <- prometheus.MustNewConstMetric(c.osMaxFileDescriptorCount, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.OSMaxFileDescriptorCount.Value))
ch <- prometheus.MustNewConstMetric(c.osOpenFileDescriptorCount, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.OSOpenFileDescriptorCount.Value))
ch <- prometheus.MustNewConstMetric(c.osProcessCPUTime, prometheus.CounterValue, float64(jvmStatus.Metrics.JVM.OSProcessCPUTime.Value))
ch <- prometheus.MustNewConstMetric(c.osSystemLoadAverage, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.OSSystemLoadAverage.Value))
ch <- prometheus.MustNewConstMetric(c.osTotalPhysicalMemorySize, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.OSTotalPhysicalMemorySize.Value))
ch <- prometheus.MustNewConstMetric(c.osTotalSwapSapceSize, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.OSTotalSwapSapceSize.Value))
ch <- prometheus.MustNewConstMetric(c.threadsBlockedCount, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.ThreadsBlockedCount.Value))
ch <- prometheus.MustNewConstMetric(c.threadsDaemonCount, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.ThreadsDaemonCount.Value))
ch <- prometheus.MustNewConstMetric(c.threadsDeadlockCount, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.ThreadsDeadlockCount.Value))
ch <- prometheus.MustNewConstMetric(c.threadsNewCount, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.ThreadsNewCount.Value))
ch <- prometheus.MustNewConstMetric(c.threadsRunnableCount, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.ThreadsRunnableCount.Value))
ch <- prometheus.MustNewConstMetric(c.threadsTerminatedCount, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.ThreadsTerminatedCount.Value))
ch <- prometheus.MustNewConstMetric(c.threadsTimedWaitingCount, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.ThreadsTimedWaitingCount.Value))
ch <- prometheus.MustNewConstMetric(c.threadsWaitingCount, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.ThreadsWaitingCount.Value))
} else {
jvmStatusStruct := &JVMStatus{}
err = json.Unmarshal(body, jvmStatusStruct)
jvmStatus := jvmStatusStruct
if err != nil {
return fmt.Errorf("Failed to unmarshal solr jvm JSON into struct: %v", err)
}
ch <- prometheus.MustNewConstMetric(c.gcConcurrentMarkSweepCount, prometheus.CounterValue, float64(jvmStatus.Metrics.JVM.GCConcurrentMarkSweepCount))
ch <- prometheus.MustNewConstMetric(c.gcConcurrentMarkSweepTime, prometheus.CounterValue, float64(jvmStatus.Metrics.JVM.GCConcurrentMarkSweepTime))
ch <- prometheus.MustNewConstMetric(c.gcParNewCount, prometheus.CounterValue, float64(jvmStatus.Metrics.JVM.GCParNewCount))
ch <- prometheus.MustNewConstMetric(c.gcParNewTime, prometheus.CounterValue, float64(jvmStatus.Metrics.JVM.GCParNewTime))
ch <- prometheus.MustNewConstMetric(c.memoryHeapCommitted, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryHeapCommitted))
ch <- prometheus.MustNewConstMetric(c.memoryHeapInit, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryHeapInit))
ch <- prometheus.MustNewConstMetric(c.memoryHeapMax, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryHeapMax))
ch <- prometheus.MustNewConstMetric(c.memoryHeapUsage, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryHeapUsage))
ch <- prometheus.MustNewConstMetric(c.memoryHeapUsed, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryHeapUsed))
ch <- prometheus.MustNewConstMetric(c.memoryNonHeapCommitted, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryNonHeapCommitted))
ch <- prometheus.MustNewConstMetric(c.memoryNonHeapInit, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryNonHeapInit))
ch <- prometheus.MustNewConstMetric(c.memoryNonHeapMax, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryNonHeapMax))
ch <- prometheus.MustNewConstMetric(c.memoryNonHeapUsage, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryNonHeapUsage))
ch <- prometheus.MustNewConstMetric(c.memoryNonHeapUsed, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryNonHeapUsed))
ch <- prometheus.MustNewConstMetric(c.memoryTotalCommitted, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryTotalCommitted))
ch <- prometheus.MustNewConstMetric(c.memoryTotalInit, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryTotalInit))
ch <- prometheus.MustNewConstMetric(c.memoryTotalMax, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryTotalMax))
ch <- prometheus.MustNewConstMetric(c.memoryTotalUsed, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.MemoryTotalUsed))
ch <- prometheus.MustNewConstMetric(c.osAvailableProcessors, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.OSAvailableProcessors))
ch <- prometheus.MustNewConstMetric(c.osCommittedVirtualMemorySize, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.OSCommittedVirtualMemorySize))
ch <- prometheus.MustNewConstMetric(c.osFreePhysicalMemorySize, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.OSFreePhysicalMemorySize))
ch <- prometheus.MustNewConstMetric(c.osFreeSwapSpaceSize, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.OSFreeSwapSpaceSize))
ch <- prometheus.MustNewConstMetric(c.osMaxFileDescriptorCount, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.OSMaxFileDescriptorCount))
ch <- prometheus.MustNewConstMetric(c.osOpenFileDescriptorCount, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.OSOpenFileDescriptorCount))
ch <- prometheus.MustNewConstMetric(c.osProcessCPUTime, prometheus.CounterValue, float64(jvmStatus.Metrics.JVM.OSProcessCPUTime))
ch <- prometheus.MustNewConstMetric(c.osSystemLoadAverage, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.OSSystemLoadAverage))
ch <- prometheus.MustNewConstMetric(c.osTotalPhysicalMemorySize, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.OSTotalPhysicalMemorySize))
ch <- prometheus.MustNewConstMetric(c.osTotalSwapSapceSize, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.OSTotalSwapSapceSize))
ch <- prometheus.MustNewConstMetric(c.threadsBlockedCount, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.ThreadsBlockedCount))
ch <- prometheus.MustNewConstMetric(c.threadsDaemonCount, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.ThreadsDaemonCount))
ch <- prometheus.MustNewConstMetric(c.threadsDeadlockCount, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.ThreadsDeadlockCount))
ch <- prometheus.MustNewConstMetric(c.threadsNewCount, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.ThreadsNewCount))
ch <- prometheus.MustNewConstMetric(c.threadsRunnableCount, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.ThreadsRunnableCount))
ch <- prometheus.MustNewConstMetric(c.threadsTerminatedCount, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.ThreadsTerminatedCount))
ch <- prometheus.MustNewConstMetric(c.threadsTimedWaitingCount, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.ThreadsTimedWaitingCount))
ch <- prometheus.MustNewConstMetric(c.threadsWaitingCount, prometheus.GaugeValue, float64(jvmStatus.Metrics.JVM.ThreadsWaitingCount))
}
return nil
}
// Collect implements the prometheus.Collector interface.
func (c *JVMCollector) Collect(ch chan<- prometheus.Metric) {
if err := c.Update(ch); err != nil {
log.Errorf("Failed to collect metrics: %v", err)
}
}
// Describe implements the prometheus.Collector interface.
func (c *JVMCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- c.gcConcurrentMarkSweepCount
ch <- c.gcConcurrentMarkSweepTime
ch <- c.gcParNewCount
ch <- c.gcParNewTime
ch <- c.memoryHeapCommitted
ch <- c.memoryHeapInit
ch <- c.memoryHeapMax
ch <- c.memoryHeapUsage
ch <- c.memoryHeapUsed
ch <- c.memoryNonHeapCommitted
ch <- c.memoryNonHeapInit
ch <- c.memoryNonHeapMax
ch <- c.memoryNonHeapUsage
ch <- c.memoryNonHeapUsed
ch <- c.memoryTotalCommitted
ch <- c.memoryTotalInit
ch <- c.memoryTotalMax
ch <- c.memoryTotalUsed
ch <- c.osAvailableProcessors
ch <- c.osCommittedVirtualMemorySize
ch <- c.osFreePhysicalMemorySize
ch <- c.osFreeSwapSpaceSize
ch <- c.osMaxFileDescriptorCount
ch <- c.osOpenFileDescriptorCount
ch <- c.osProcessCPUTime
ch <- c.osSystemLoadAverage
ch <- c.osTotalPhysicalMemorySize
ch <- c.osTotalSwapSapceSize
ch <- c.threadsBlockedCount
ch <- c.threadsDaemonCount
ch <- c.threadsDeadlockCount
ch <- c.threadsNewCount
ch <- c.threadsRunnableCount
ch <- c.threadsTerminatedCount
ch <- c.threadsTimedWaitingCount
ch <- c.threadsWaitingCount
}