master
go 3,133 lines 83.5 KB
Raw
1 //go:build cgo
2
3 package pmi
4
5 import (
6 "context"
7 "errors"
8 "math"
9 "sort"
10 "strconv"
11 "strings"
12 "sync"
13
14 "github.com/netdata/netdata/go/plugins/pkg/matcher"
15 "github.com/netdata/netdata/go/plugins/plugin/ibm.d/framework"
16 "github.com/netdata/netdata/go/plugins/plugin/ibm.d/modules/websphere/common"
17 "github.com/netdata/netdata/go/plugins/plugin/ibm.d/modules/websphere/pmi/contexts"
18 pmiproto "github.com/netdata/netdata/go/plugins/plugin/ibm.d/protocols/websphere/pmi"
19 )
20
21 // Collector implements the WebSphere PMI module using the ibm.d framework.
22 type Collector struct {
23 framework.Collector
24
25 Config `yaml:",inline" json:",inline"`
26
27 once sync.Once
28
29 client *pmiproto.Client
30
31 identity common.Identity
32
33 appSelector matcher.Matcher
34 poolSelector matcher.Matcher
35 jmsSelector matcher.Matcher
36 servletSelector matcher.Matcher
37 ejbSelector matcher.Matcher
38 }
39
40 func (c *Collector) initOnce() {
41 c.once.Do(func() {})
42 }
43
44 // CollectOnce performs a single PMI collection iteration.
45 func (c *Collector) CollectOnce() error {
46 c.initOnce()
47 if c.client == nil {
48 return errors.New("pmi client not initialised")
49 }
50
51 ctx := context.Background()
52 snapshot, err := c.client.Fetch(ctx)
53 if err != nil {
54 return err
55 }
56
57 agg := newAggregator(c.Config)
58 agg.identity = c.identity
59
60 agg.processSnapshot(snapshot, c.applySelectors())
61 c.Debugf("PMI aggregator counts: threadPools=%d transactions=%d jdbcPools=%d jcaPools=%d jmsQueues=%d jmsTopics=%d webApps=%d sessions=%d dynamicCaches=%d urls=%d securityAuth=%d", len(agg.threadPools), len(agg.transactions), len(agg.jdbcPools), len(agg.jcaPools), len(agg.jmsQueues), len(agg.jmsTopics), len(agg.webApps), len(agg.sessions), len(agg.dynamicCaches), len(agg.urls), len(agg.securityAuth))
62 agg.exportMetrics(c.State)
63
64 if labels := c.identity.Labels(); len(labels) > 0 {
65 c.SetGlobalLabels(labels)
66 }
67
68 return nil
69 }
70
71 var _ framework.CollectorImpl = (*Collector)(nil)
72
73 type selectorBundle struct {
74 app matcher.Matcher
75 pool matcher.Matcher
76 jms matcher.Matcher
77 servlet matcher.Matcher
78 ejb matcher.Matcher
79 }
80
81 func (c *Collector) applySelectors() selectorBundle {
82 return selectorBundle{
83 app: c.appSelector,
84 pool: c.poolSelector,
85 jms: c.jmsSelector,
86 servlet: c.servletSelector,
87 ejb: c.ejbSelector,
88 }
89 }
90
91 type aggregator struct {
92 cfg Config
93
94 identity common.Identity
95
96 system jvmSystemMetrics
97 threadPools map[string]threadPoolMetrics
98 transactions map[string]*transactionMetrics
99 jdbcPools map[string]*jdbcPoolMetrics
100 webApps map[string]*webAppMetrics
101 sessions map[string]*sessionMetrics
102 dynamicCaches map[string]*dynamicCacheMetrics
103 urls map[string]*urlMetrics
104 securityAuth map[string]*securityAuthMetrics
105 orb map[string]*orbMetrics
106 systemData systemDataMetrics
107 securityAuthz map[string]*securityAuthorizationMetrics
108 haManager map[string]*haManagerMetrics
109 alarmManagers map[string]*alarmManagerMetrics
110 schedulers map[string]*schedulerMetrics
111 objectPools map[string]*objectPoolMetrics
112 enterpriseEJB map[string]*enterpriseBeanMetrics
113 webServices map[string]*webServiceMetrics
114 webGateway map[string]*webServiceGatewayMetrics
115 pmiModules map[string]*pmiWebServiceModuleMetrics
116 extensionReg extensionRegistryMetrics
117 jcaPools map[string]*jcaPoolMetrics
118 jmsQueues map[string]*jmsQueueMetrics
119 jmsTopics map[string]*jmsTopicMetrics
120 jmsStores map[string]*jmsStoreSectionMetrics
121 portletApps map[string]*portletAppMetrics
122 portlets map[string]*portletMetrics
123
124 coverage *statCoverage
125 }
126
127 type statCoverage struct {
128 all map[string]struct{}
129 handled map[string]struct{}
130 }
131
132 func newStatCoverage() *statCoverage {
133 return &statCoverage{
134 all: make(map[string]struct{}),
135 handled: make(map[string]struct{}),
136 }
137 }
138
139 func (c *statCoverage) Reset() {
140 if c == nil {
141 return
142 }
143 c.all = make(map[string]struct{})
144 c.handled = make(map[string]struct{})
145 }
146
147 func (c *statCoverage) Seed(snapshot *pmiproto.Snapshot) {
148 if c == nil || snapshot == nil {
149 return
150 }
151 for i := range snapshot.Nodes {
152 node := &snapshot.Nodes[i]
153 for j := range node.Servers {
154 server := &node.Servers[j]
155 for k := range server.Stats {
156 c.walk(&server.Stats[k])
157 }
158 }
159 }
160 for i := range snapshot.Stats {
161 c.walk(&snapshot.Stats[i])
162 }
163 }
164
165 func (c *statCoverage) walk(stat *pmiproto.Stat) {
166 if stat == nil {
167 return
168 }
169 path := statPath(stat)
170 c.all[path] = struct{}{}
171 for i := range stat.SubStats {
172 c.walk(&stat.SubStats[i])
173 }
174 }
175
176 func (c *statCoverage) Handle(stat *pmiproto.Stat) {
177 if c == nil || stat == nil {
178 return
179 }
180 path := statPath(stat)
181 c.handled[path] = struct{}{}
182 }
183
184 func (c *statCoverage) Missing() []string {
185 if c == nil {
186 return nil
187 }
188 missing := make([]string, 0)
189 for path := range c.all {
190 if _, ok := c.handled[path]; !ok {
191 missing = append(missing, path)
192 }
193 }
194 sort.Strings(missing)
195 return missing
196 }
197
198 func statPath(stat *pmiproto.Stat) string {
199 if stat == nil {
200 return ""
201 }
202 path := strings.TrimSpace(stat.Path)
203 if path == "" {
204 path = strings.TrimSpace(stat.Name)
205 }
206 return path
207 }
208
209 func (a *aggregator) markNestedStats(stats ...*pmiproto.Stat) {
210 for _, stat := range stats {
211 if stat == nil {
212 continue
213 }
214 a.coverage.Handle(stat)
215 for i := range stat.SubStats {
216 a.markNestedStats(&stat.SubStats[i])
217 }
218 }
219 }
220
221 func (a *aggregator) markNestedStatsSlice(stats []pmiproto.Stat) {
222 for i := range stats {
223 a.markNestedStats(&stats[i])
224 }
225 }
226
227 type jvmSystemMetrics struct {
228 cpuUtilization int64
229 heapUsed int64
230 heapFree int64
231 heapCommitted int64
232 heapMax int64
233 uptimeSeconds int64
234 gcCollections int64
235 gcTimeMs int64
236 threadDaemon int64
237 threadOther int64
238 threadPeak int64
239 }
240
241 type threadPoolMetrics struct {
242 active int64
243 size int64
244 }
245
246 type transactionMetrics struct {
247 node string
248 server string
249
250 globalBegun int64
251 globalCommitted int64
252 globalRolledBack int64
253 globalTimeout int64
254 globalInvolved int64
255 optimizations int64
256
257 localBegun int64
258 localCommitted int64
259 localRolledBack int64
260 localTimeout int64
261
262 activeGlobal int64
263 activeLocal int64
264
265 globalTotalMs int64
266 globalPrepareMs int64
267 globalCommitMs int64
268 globalBeforeCompletionMs int64
269 localTotalMs int64
270 localCommitMs int64
271 localBeforeCompletionMs int64
272 }
273
274 type jdbcPoolMetrics struct {
275 node string
276 server string
277 name string
278 provider string
279
280 percentUsed int64
281 percentMaxed int64
282 waitingThreads int64
283
284 managedConnections int64
285 connectionHandles int64
286
287 createCount int64
288 closeCount int64
289 allocateCount int64
290 returnCount int64
291 faultCount int64
292 prepDiscardCount int64
293
294 useTimeMs int64
295 waitTimeMs int64
296 jdbcTimeMs int64
297 }
298
299 type webAppMetrics struct {
300 node string
301 server string
302 name string
303
304 loadedServlets int64
305 reloads int64
306 }
307
308 type sessionMetrics struct {
309 node string
310 server string
311 app string
312
313 active int64
314 live int64
315
316 createCount int64
317 invalidateCount int64
318 timeoutInvalidations int64
319 affinityBreaks int64
320 cacheDiscards int64
321 noRoomCount int64
322 activateNonExistCount int64
323 }
324
325 type dynamicCacheMetrics struct {
326 node string
327 server string
328 cache string
329
330 maxEntries int64
331 entries int64
332 }
333
334 type systemDataMetrics struct {
335 cpuUsageSinceLast int64
336 freeMemoryBytes int64
337 }
338
339 type urlMetrics struct {
340 node string
341 server string
342 url string
343
344 requestCount int64
345 serviceTimeMs int64
346 asyncResponseMs int64
347 }
348
349 type portletAppMetrics struct {
350 node string
351 server string
352 loadedPortlets int64
353 }
354
355 type portletMetrics struct {
356 node string
357 server string
358 name string
359
360 requestCount int64
361 concurrent int64
362 errors int64
363 renderTimeMs int64
364 actionTimeMs int64
365 processEventMs int64
366 serveResourceMs int64
367 }
368
369 type securityAuthMetrics struct {
370 node string
371 server string
372
373 webAuth int64
374 taiRequests int64
375 identityAssertions int64
376 basicAuth int64
377 tokenAuth int64
378 jaasIdentity int64
379 jaasBasic int64
380 jaasToken int64
381 rmiAuth int64
382 }
383
384 type orbMetrics struct {
385 node string
386 server string
387
388 concurrentRequests int64
389 requestCount int64
390 }
391
392 type securityAuthorizationMetrics struct {
393 node string
394 server string
395
396 webMs int64
397 ejbMs int64
398 adminMs int64
399 cwwjaMs int64
400 }
401
402 type haManagerMetrics struct {
403 node string
404 server string
405
406 localGroups int64
407 bBoardSubjects int64
408 bBoardSubscriptions int64
409 localSubjects int64
410 localSubscriptions int64
411 groupStateRebuildMs int64
412 bBoardRebuildMs int64
413 }
414
415 type alarmManagerMetrics struct {
416 node string
417 server string
418 name string
419
420 created int64
421 cancelled int64
422 fired int64
423 }
424
425 type schedulerMetrics struct {
426 node string
427 server string
428 name string
429 finished int64
430 failures int64
431 polls int64
432 }
433
434 type objectPoolMetrics struct {
435 node string
436 server string
437 name string
438 created int64
439 allocated int64
440 returned int64
441 idle int64
442 }
443
444 type enterpriseBeanMetrics struct {
445 node string
446 server string
447 name string
448
449 createCount int64
450 removeCount int64
451 activateCount int64
452 passivateCount int64
453 instantiateCount int64
454 storeCount int64
455 loadCount int64
456
457 messageCount int64
458 messageBackoutCnt int64
459
460 readyCount int64
461 liveCount int64
462 pooledCount int64
463 activeMethodCount int64
464 passiveCount int64
465 serverSessionPoolUsage int64
466 methodReadyCount int64
467 asyncQueueSize int64
468
469 activationTimeMs int64
470 passivationTimeMs int64
471 createTimeMs int64
472 removeTimeMs int64
473 loadTimeMs int64
474 storeTimeMs int64
475 methodResponseTimeMs int64
476 waitTimeMs int64
477 asyncWaitTimeMs int64
478 readLockTimeMs int64
479 writeLockTimeMs int64
480 }
481
482 type webServiceMetrics struct {
483 node string
484 server string
485 service string
486
487 loaded int64
488 }
489
490 type webServiceGatewayMetrics struct {
491 node string
492 server string
493 name string
494
495 syncRequests int64
496 syncResponses int64
497 asyncRequests int64
498 asyncResponses int64
499 }
500
501 type pmiWebServiceModuleMetrics struct {
502 node string
503 server string
504 name string
505
506 loaded int64
507 }
508
509 type extensionRegistryMetrics struct {
510 node string
511 server string
512
513 requests int64
514 hits int64
515 displacements int64
516 hitRate int64
517 }
518
519 type jcaPoolMetrics struct {
520 node string
521 server string
522 provider string
523 name string
524
525 createCount int64
526 closeCount int64
527 allocateCount int64
528 freedCount int64
529 faultCount int64
530
531 managedConnections int64
532 connectionHandles int64
533
534 percentUsed int64
535 percentMaxed int64
536
537 waitingThreads int64
538 }
539
540 type jmsQueueMetrics struct {
541 node string
542 server string
543 engine string
544 name string
545
546 totalProduced int64
547 bestEffortProduced int64
548 expressProduced int64
549 reliableNonPersistentProduced int64
550 reliablePersistentProduced int64
551 assuredPersistentProduced int64
552
553 totalConsumed int64
554 bestEffortConsumed int64
555 expressConsumed int64
556 reliableNonPersistentConsumed int64
557 reliablePersistentConsumed int64
558 assuredPersistentConsumed int64
559
560 reportEnabledExpired int64
561
562 localProducerAttaches int64
563 localProducerCount int64
564 localConsumerAttaches int64
565 localConsumerCount int64
566
567 availableMessages int64
568 unavailableMessages int64
569 oldestMessageAgeMs int64
570
571 aggregateWaitMs int64
572 localWaitMs int64
573 }
574
575 type jmsTopicMetrics struct {
576 node string
577 server string
578 engine string
579 name string
580
581 assuredHits int64
582 bestEffortHits int64
583 expressHits int64
584
585 assuredPublished int64
586 bestEffortPublished int64
587 expressPublished int64
588
589 durableLocalSubscriptions int64
590 incompletePublications int64
591 localOldestPublicationMs int64
592 localPublisherAttaches int64
593 localSubscriberAttaches int64
594 }
595
596 type jmsStoreSectionMetrics struct {
597 node string
598 server string
599 engine string
600 section string
601
602 cacheAddStored int64
603 cacheAddNotStored int64
604 cacheCurrentStoredCount int64
605 cacheCurrentStoredBytes int64
606 cacheCurrentNotStoredCount int64
607 cacheCurrentNotStoredBytes int64
608 cacheDiscardCount int64
609 cacheDiscardBytes int64
610
611 datastoreInsertBatches int64
612 datastoreUpdateBatches int64
613 datastoreDeleteBatches int64
614 datastoreInsertCount int64
615 datastoreUpdateCount int64
616 datastoreDeleteCount int64
617 datastoreOpenCount int64
618 datastoreAbortCount int64
619 datastoreTransactionMs int64
620
621 expiryIndexItemCount int64
622
623 globalTxnStart int64
624 globalTxnCommit int64
625 globalTxnAbort int64
626 globalTxnInDoubt int64
627 localTxnStart int64
628 localTxnCommit int64
629 localTxnAbort int64
630 }
631
632 func newAggregator(cfg Config) *aggregator {
633 cfg.CollectJVMMetrics = cfg.CollectJVMMetrics.WithDefault(true)
634 cfg.CollectThreadPoolMetrics = cfg.CollectThreadPoolMetrics.WithDefault(true)
635 cfg.CollectJDBCMetrics = cfg.CollectJDBCMetrics.WithDefault(true)
636 cfg.CollectJCAMetrics = cfg.CollectJCAMetrics.WithDefault(true)
637 cfg.CollectJMSMetrics = cfg.CollectJMSMetrics.WithDefault(true)
638 cfg.CollectWebAppMetrics = cfg.CollectWebAppMetrics.WithDefault(true)
639 cfg.CollectSessionMetrics = cfg.CollectSessionMetrics.WithDefault(true)
640 cfg.CollectTransactionMetrics = cfg.CollectTransactionMetrics.WithDefault(true)
641 cfg.CollectClusterMetrics = cfg.CollectClusterMetrics.WithDefault(true)
642 cfg.CollectServletMetrics = cfg.CollectServletMetrics.WithDefault(true)
643 cfg.CollectEJBMetrics = cfg.CollectEJBMetrics.WithDefault(true)
644 cfg.CollectJDBCAdvanced = cfg.CollectJDBCAdvanced.WithDefault(false)
645
646 return &aggregator{
647 cfg: cfg,
648 threadPools: make(map[string]threadPoolMetrics),
649 transactions: make(map[string]*transactionMetrics),
650 jdbcPools: make(map[string]*jdbcPoolMetrics),
651 webApps: make(map[string]*webAppMetrics),
652 sessions: make(map[string]*sessionMetrics),
653 dynamicCaches: make(map[string]*dynamicCacheMetrics),
654 urls: make(map[string]*urlMetrics),
655 securityAuth: make(map[string]*securityAuthMetrics),
656 orb: make(map[string]*orbMetrics),
657 securityAuthz: make(map[string]*securityAuthorizationMetrics),
658 haManager: make(map[string]*haManagerMetrics),
659 alarmManagers: make(map[string]*alarmManagerMetrics),
660 schedulers: make(map[string]*schedulerMetrics),
661 objectPools: make(map[string]*objectPoolMetrics),
662 enterpriseEJB: make(map[string]*enterpriseBeanMetrics),
663 webServices: make(map[string]*webServiceMetrics),
664 webGateway: make(map[string]*webServiceGatewayMetrics),
665 pmiModules: make(map[string]*pmiWebServiceModuleMetrics),
666 jcaPools: make(map[string]*jcaPoolMetrics),
667 jmsQueues: make(map[string]*jmsQueueMetrics),
668 jmsTopics: make(map[string]*jmsTopicMetrics),
669 jmsStores: make(map[string]*jmsStoreSectionMetrics),
670 portletApps: make(map[string]*portletAppMetrics),
671 portlets: make(map[string]*portletMetrics),
672 coverage: newStatCoverage(),
673 }
674 }
675
676 func (a *aggregator) processSnapshot(snapshot *pmiproto.Snapshot, selectors selectorBundle) {
677 if a.coverage == nil {
678 a.coverage = newStatCoverage()
679 } else {
680 a.coverage.Reset()
681 }
682 a.coverage.Seed(snapshot)
683
684 for _, node := range snapshot.Nodes {
685 for _, server := range node.Servers {
686 a.processStats(node.Name, server.Name, server.Stats, selectors)
687 }
688 }
689 if len(snapshot.Stats) > 0 {
690 a.processStats("", "", snapshot.Stats, selectors)
691 }
692 }
693
694 func (a *aggregator) processStats(node, server string, stats []pmiproto.Stat, selectors selectorBundle) {
695 for i := range stats {
696 stat := &stats[i]
697 handled := false
698 switch stat.Name {
699 case "JVM Runtime":
700 a.processJVMRuntime(stat)
701 handled = true
702 case "JVM Runtime MBean":
703 a.processJVMRuntime(stat)
704 handled = true
705 case "JVM Thread":
706 a.processJVMThreads(stat)
707 handled = true
708 case "JVM Thread MBean":
709 a.processJVMThreads(stat)
710 handled = true
711 case "JVM Memory":
712 a.processJVMMemory(stat)
713 handled = true
714 case "JVM Memory MBean":
715 a.processJVMMemory(stat)
716 handled = true
717 case "JVM GC":
718 a.processJVMGC(stat)
719 handled = true
720 case "Thread Pools":
721 for j := range stat.SubStats {
722 a.processThreadPool(&stat.SubStats[j])
723 }
724 handled = true
725 case "Transaction Manager":
726 a.processTransactionManager(node, server, stat)
727 handled = true
728 case "JDBC Connection Pools":
729 if !a.collectJDBCMetricsEnabled() {
730 a.coverage.Handle(stat)
731 continue
732 }
733 for j := range stat.SubStats {
734 provider := &stat.SubStats[j]
735 a.coverage.Handle(provider)
736 for k := range provider.SubStats {
737 a.processJDBCPool(node, server, provider.Name, &provider.SubStats[k], selectors)
738 }
739 }
740 handled = true
741 case "JCA Connection Pools":
742 if !a.collectJCAMetricsEnabled() {
743 a.coverage.Handle(stat)
744 continue
745 }
746 for j := range stat.SubStats {
747 provider := &stat.SubStats[j]
748 a.coverage.Handle(provider)
749 for k := range provider.SubStats {
750 a.processJCAPool(node, server, provider.Name, &provider.SubStats[k], selectors)
751 }
752 }
753 handled = true
754 case "Web Applications":
755 if !a.collectWebAppMetricsEnabled() {
756 a.coverage.Handle(stat)
757 continue
758 }
759 for j := range stat.SubStats {
760 a.processWebApplication(node, server, &stat.SubStats[j], selectors)
761 }
762 handled = true
763 case "Portlet Application":
764 a.processPortletApplication(node, server, stat)
765 handled = true
766 case "Portlets":
767 for j := range stat.SubStats {
768 a.processPortlet(node, server, &stat.SubStats[j])
769 }
770 handled = true
771 case "WIM Group Management":
772 a.processPortlet(node, server, stat)
773 handled = true
774 case "WIM User Management":
775 a.processPortlet(node, server, stat)
776 handled = true
777 case "URLs":
778 if !a.collectServletMetricsEnabled() {
779 a.coverage.Handle(stat)
780 continue
781 }
782 for j := range stat.SubStats {
783 a.processURLMetric(node, server, &stat.SubStats[j], selectors)
784 }
785 handled = true
786 case "Servlet Session Manager":
787 if !a.collectSessionMetricsEnabled() {
788 a.coverage.Handle(stat)
789 continue
790 }
791 for j := range stat.SubStats {
792 a.processSessionManager(node, server, &stat.SubStats[j], selectors)
793 }
794 handled = true
795 case "Dynamic Caching":
796 if !a.collectDynamicCacheMetricsEnabled() {
797 a.coverage.Handle(stat)
798 continue
799 }
800 for j := range stat.SubStats {
801 a.processDynamicCache(node, server, &stat.SubStats[j])
802 }
803 handled = true
804 case "System Data":
805 a.processSystemData(stat)
806 handled = true
807 case "Security Authentication":
808 a.processSecurityAuthentication(node, server, stat)
809 handled = true
810 case "ORB":
811 a.processORB(node, server, stat)
812 handled = true
813 case "Object Request Broker":
814 a.processORB(node, server, stat)
815 handled = true
816 case "Security Authorization":
817 a.processSecurityAuthorization(node, server, stat)
818 handled = true
819 case "HAManager":
820 a.processHAManager(node, server, stat)
821 handled = true
822 case "Alarm Manager":
823 a.processAlarmManager(node, server, stat)
824 handled = true
825 case "Schedulers":
826 a.processSchedulers(node, server, stat)
827 handled = true
828 case "Object Pool":
829 a.processObjectPool(node, server, stat)
830 handled = true
831 case "Enterprise Beans":
832 a.processEnterpriseBeans(node, server, stat, selectors)
833 handled = true
834 case "Web services":
835 a.processWebServices(node, server, stat)
836 handled = true
837 case "Web services Gateway":
838 a.processWebServicesGateway(node, server, stat)
839 handled = true
840 case "pmiWebServiceModule":
841 a.processPMIWebServiceModule(node, server, stat)
842 handled = true
843 case "ExtensionRegistryStats.name":
844 a.processExtensionRegistry(node, server, stat)
845 handled = true
846 case "SIB Service":
847 if !a.collectJMSMetricsEnabled() {
848 a.coverage.Handle(stat)
849 continue
850 }
851 a.processSIBService(node, server, stat, selectors)
852 handled = true
853 }
854
855 if handled {
856 a.coverage.Handle(stat)
857 continue
858 }
859 if len(stat.SubStats) > 0 {
860 a.processStats(node, server, stat.SubStats, selectors)
861 a.coverage.Handle(stat)
862 }
863 }
864 }
865
866 func (a *aggregator) processJVMRuntime(stat *pmiproto.Stat) {
867 if stat == nil {
868 return
869 }
870 a.coverage.Handle(stat)
871
872 for _, cs := range stat.CountStatistics {
873 switch strings.ToLower(cs.Name) {
874 case "freememory":
875 if v, ok := parseCount(cs.Count); ok {
876 a.system.heapFree = convertUnits(v, cs.Unit, unitBytes)
877 }
878 case "usedmemory":
879 if v, ok := parseCount(cs.Count); ok {
880 a.system.heapUsed = convertUnits(v, cs.Unit, unitBytes)
881 }
882 case "heap":
883 if v, ok := parseCount(cs.Count); ok {
884 a.system.heapCommitted = convertUnits(v, cs.Unit, unitBytes)
885 }
886 case "uptime":
887 if v, ok := parseCount(cs.Count); ok {
888 a.system.uptimeSeconds = convertUnits(v, cs.Unit, unitSeconds)
889 }
890 case "processcpuusage":
891 if v, ok := parseFloat(cs.Count); ok {
892 a.system.cpuUtilization = int64(math.Round(v * 1000))
893 }
894 }
895 }
896
897 for _, ds := range stat.DoubleStatistics {
898 switch strings.ToLower(ds.Name) {
899 case "processcpuusage":
900 if v, ok := parseFloat(ds.Double); ok {
901 a.system.cpuUtilization = int64(math.Round(v * 1000))
902 }
903 }
904 }
905
906 for _, ts := range stat.TimeStatistics {
907 if strings.EqualFold(ts.Name, "CPUUsage") {
908 if v, err := strconv.ParseFloat(ts.Mean, 64); err == nil {
909 a.system.cpuUtilization = int64(math.Round(v * 1000))
910 }
911 }
912 }
913 }
914
915 func (a *aggregator) processJVMMemory(stat *pmiproto.Stat) {
916 if stat == nil {
917 return
918 }
919 a.coverage.Handle(stat)
920
921 for _, rs := range stat.RangeStatistics {
922 switch strings.ToLower(rs.Name) {
923 case "heapbytesused":
924 if v, ok := parseFloat(rs.Current); ok {
925 a.system.heapUsed = int64(v)
926 }
927 case "heapbytesmax":
928 if v, ok := parseFloat(rs.Current); ok {
929 a.system.heapMax = int64(v)
930 }
931 case "heapbytescommitted":
932 if v, ok := parseFloat(rs.Current); ok {
933 a.system.heapCommitted = int64(v)
934 }
935 }
936 }
937 }
938
939 func (a *aggregator) processJVMThreads(stat *pmiproto.Stat) {
940 if stat == nil {
941 return
942 }
943 a.coverage.Handle(stat)
944
945 var total, daemon int64
946 for _, rs := range stat.RangeStatistics {
947 switch strings.ToLower(rs.Name) {
948 case "livethreadcount":
949 if v, ok := parseFloat(rs.Current); ok {
950 total = int64(v)
951 }
952 case "daemonthreadcount":
953 if v, ok := parseFloat(rs.Current); ok {
954 daemon = int64(v)
955 }
956 case "peakthreadcount":
957 if v, ok := parseFloat(rs.Current); ok {
958 a.system.threadPeak = int64(v)
959 }
960 }
961 }
962 if daemon < 0 {
963 daemon = 0
964 }
965 a.system.threadDaemon = daemon
966 if total < daemon {
967 total = daemon
968 }
969 a.system.threadOther = total - daemon
970 }
971
972 func (a *aggregator) processJVMGC(stat *pmiproto.Stat) {
973 if stat == nil {
974 return
975 }
976 a.coverage.Handle(stat)
977
978 for _, cs := range stat.CountStatistics {
979 switch strings.ToLower(cs.Name) {
980 case "collectioncount":
981 if v, ok := parseCount(cs.Count); ok {
982 a.system.gcCollections = v
983 }
984 case "collectiontime":
985 if v, ok := parseCount(cs.Count); ok {
986 a.system.gcTimeMs = convertUnits(v, cs.Unit, unitMilliseconds)
987 }
988 }
989 }
990 }
991
992 func (a *aggregator) processThreadPool(stat *pmiproto.Stat) {
993 if stat == nil {
994 return
995 }
996 a.coverage.Handle(stat)
997
998 metrics := a.threadPools[stat.Name]
999 for _, rs := range stat.RangeStatistics {
1000 switch strings.ToLower(rs.Name) {
1001 case "currentthreadsbusy", "currentthreadsbusycount":
1002 if v, ok := parseFloat(rs.Current); ok {
1003 metrics.active = int64(v)
1004 }
1005 case "currentthreadspoolsize", "currentthreadspoolsizecount":
1006 if v, ok := parseFloat(rs.Current); ok {
1007 metrics.size = int64(v)
1008 }
1009 }
1010 }
1011 a.threadPools[stat.Name] = metrics
1012 }
1013
1014 func (a *aggregator) processTransactionManager(node, server string, stat *pmiproto.Stat) {
1015 if stat == nil {
1016 return
1017 }
1018 a.coverage.Handle(stat)
1019
1020 key := common.InstanceKey(node, server, "transaction_manager")
1021 metrics := a.transactions[key]
1022 if metrics == nil {
1023 metrics = &transactionMetrics{node: node, server: server}
1024 a.transactions[key] = metrics
1025 }
1026
1027 for _, cs := range stat.CountStatistics {
1028 value, ok := parseCount(cs.Count)
1029 if !ok {
1030 continue
1031 }
1032 switch strings.ToLower(cs.Name) {
1033 case "globalbeguncount":
1034 metrics.globalBegun = value
1035 case "globalcommittedcount", "committedcount":
1036 metrics.globalCommitted = value
1037 case "globalrolledbackcount", "rolledbackcount":
1038 metrics.globalRolledBack = value
1039 case "globaltimeoutcount":
1040 metrics.globalTimeout = value
1041 case "globalinvolvedcount":
1042 metrics.globalInvolved = value
1043 case "optimizationcount":
1044 metrics.optimizations = value
1045 case "localbeguncount":
1046 metrics.localBegun = value
1047 case "localcommittedcount":
1048 metrics.localCommitted = value
1049 case "localrolledbackcount":
1050 metrics.localRolledBack = value
1051 case "localtimeoutcount":
1052 metrics.localTimeout = value
1053 case "activecount":
1054 metrics.activeGlobal = value
1055 case "localactivecount":
1056 metrics.activeLocal = value
1057 }
1058 }
1059
1060 for _, ts := range stat.TimeStatistics {
1061 val, ok := parseFloat(ts.TotalTime)
1062 if !ok {
1063 continue
1064 }
1065 ms := convertUnits(int64(math.Round(val)), ts.Unit, unitMilliseconds)
1066 switch strings.ToLower(ts.Name) {
1067 case "globaltrantime":
1068 metrics.globalTotalMs = ms
1069 case "globalpreparetime":
1070 metrics.globalPrepareMs = ms
1071 case "globalcommittime":
1072 metrics.globalCommitMs = ms
1073 case "globalbeforecompletiontime":
1074 metrics.globalBeforeCompletionMs = ms
1075 case "localtrantime":
1076 metrics.localTotalMs = ms
1077 case "localcommittime":
1078 metrics.localCommitMs = ms
1079 case "localbeforecompletiontime":
1080 metrics.localBeforeCompletionMs = ms
1081 }
1082 }
1083 }
1084
1085 func (a *aggregator) processJDBCPool(node, server, provider string, stat *pmiproto.Stat, selectors selectorBundle) {
1086 if stat == nil {
1087 return
1088 }
1089 a.coverage.Handle(stat)
1090 poolName := stat.Name
1091 if poolName == "" {
1092 poolName = provider
1093 }
1094 if poolName == "" {
1095 return
1096 }
1097 target := poolName
1098 if provider != "" {
1099 target = provider + "/" + poolName
1100 }
1101 if selectors.pool != nil && !selectors.pool.MatchString(target) {
1102 return
1103 }
1104
1105 key := common.InstanceKey(node, server, poolName)
1106 metrics := a.jdbcPools[key]
1107 if metrics == nil {
1108 if a.cfg.MaxJDBCPools > 0 && len(a.jdbcPools) >= a.cfg.MaxJDBCPools {
1109 return
1110 }
1111 metrics = &jdbcPoolMetrics{node: node, server: server, name: poolName, provider: provider}
1112 a.jdbcPools[key] = metrics
1113 }
1114
1115 for _, rs := range stat.RangeStatistics {
1116 value, ok := parseFloat(rs.Current)
1117 if !ok {
1118 continue
1119 }
1120 switch strings.ToLower(rs.Name) {
1121 case "waitingthreadcount":
1122 metrics.waitingThreads = int64(math.Round(value))
1123 case "percentused":
1124 metrics.percentUsed = common.FormatPercent(value / 100.0)
1125 case "percentmaxed":
1126 metrics.percentMaxed = common.FormatPercent(value / 100.0)
1127 }
1128 }
1129
1130 for _, cs := range stat.CountStatistics {
1131 value, ok := parseCount(cs.Count)
1132 if !ok {
1133 continue
1134 }
1135 switch strings.ToLower(cs.Name) {
1136 case "createcount":
1137 metrics.createCount = value
1138 case "closecount":
1139 metrics.closeCount = value
1140 case "allocatecount":
1141 metrics.allocateCount = value
1142 case "returncount", "freedcount":
1143 metrics.returnCount = value
1144 case "faultcount":
1145 metrics.faultCount = value
1146 case "managedconnectioncount":
1147 metrics.managedConnections = value
1148 case "connectionhandlecount":
1149 metrics.connectionHandles = value
1150 case "prepstmtcachediscardcount":
1151 metrics.prepDiscardCount = value
1152 }
1153 }
1154
1155 for _, ts := range stat.TimeStatistics {
1156 val, ok := parseFloat(ts.TotalTime)
1157 if !ok {
1158 continue
1159 }
1160 ms := convertUnits(int64(math.Round(val)), ts.Unit, unitMilliseconds)
1161 switch strings.ToLower(ts.Name) {
1162 case "usetime":
1163 metrics.useTimeMs = ms
1164 case "waittime":
1165 metrics.waitTimeMs = ms
1166 case "jdbctime":
1167 metrics.jdbcTimeMs = ms
1168 }
1169 }
1170 }
1171
1172 func (a *aggregator) processJCAPool(node, server, provider string, stat *pmiproto.Stat, selectors selectorBundle) {
1173 if stat == nil {
1174 return
1175 }
1176 a.coverage.Handle(stat)
1177 poolName := stat.Name
1178 if poolName == "" {
1179 poolName = provider
1180 }
1181 if poolName == "" {
1182 return
1183 }
1184
1185 target := poolName
1186 if provider != "" {
1187 target = provider + "/" + poolName
1188 }
1189 if selectors.pool != nil && !selectors.pool.MatchString(target) {
1190 return
1191 }
1192
1193 key := common.InstanceKey(node, server, provider, poolName)
1194 metrics := a.jcaPools[key]
1195 if metrics == nil {
1196 if a.cfg.MaxJCAPools > 0 && len(a.jcaPools) >= a.cfg.MaxJCAPools {
1197 return
1198 }
1199 metrics = &jcaPoolMetrics{node: node, server: server, provider: provider, name: poolName}
1200 a.jcaPools[key] = metrics
1201 }
1202
1203 for _, rs := range stat.RangeStatistics {
1204 value, ok := parseFloat(rs.Current)
1205 if !ok {
1206 continue
1207 }
1208 name := strings.ToLower(rs.Name)
1209 switch name {
1210 case "percentused":
1211 metrics.percentUsed = common.FormatPercent(value / 100.0)
1212 case "percentmaxed":
1213 metrics.percentMaxed = common.FormatPercent(value / 100.0)
1214 case "waitingthreadcount":
1215 metrics.waitingThreads = int64(math.Round(value))
1216 }
1217 }
1218
1219 for _, cs := range stat.CountStatistics {
1220 value, ok := parseCount(cs.Count)
1221 if !ok {
1222 continue
1223 }
1224 name := strings.ToLower(cs.Name)
1225 switch name {
1226 case "createcount":
1227 metrics.createCount = value
1228 case "closecount":
1229 metrics.closeCount = value
1230 case "allocatecount":
1231 metrics.allocateCount = value
1232 case "freedcount":
1233 metrics.freedCount = value
1234 case "faultcount":
1235 metrics.faultCount = value
1236 case "managedconnectioncount":
1237 metrics.managedConnections = value
1238 case "connectionhandlecount":
1239 metrics.connectionHandles = value
1240 }
1241 }
1242 }
1243
1244 func (a *aggregator) processWebApplication(node, server string, stat *pmiproto.Stat, selectors selectorBundle) {
1245 if stat == nil {
1246 return
1247 }
1248 a.coverage.Handle(stat)
1249 name := stat.Name
1250 if name == "" {
1251 name = "unknown"
1252 }
1253 if selectors.app != nil && !selectors.app.MatchString(name) {
1254 return
1255 }
1256
1257 key := common.InstanceKey(node, server, name)
1258 metrics := a.webApps[key]
1259 if metrics == nil {
1260 if a.cfg.MaxApplications > 0 && len(a.webApps) >= a.cfg.MaxApplications {
1261 return
1262 }
1263 metrics = &webAppMetrics{node: node, server: server, name: name}
1264 a.webApps[key] = metrics
1265 }
1266
1267 for _, cs := range stat.CountStatistics {
1268 value, ok := parseCount(cs.Count)
1269 if !ok {
1270 continue
1271 }
1272 switch strings.ToLower(cs.Name) {
1273 case "loadedservletcount":
1274 metrics.loadedServlets = value
1275 case "reloadcount":
1276 metrics.reloads = value
1277 }
1278 }
1279
1280 if len(stat.SubStats) > 0 {
1281 a.processStats(node, server, stat.SubStats, selectors)
1282 }
1283
1284 a.markNestedStatsSlice(stat.SubStats)
1285 }
1286
1287 func (a *aggregator) processPortletApplication(node, server string, stat *pmiproto.Stat) {
1288 if stat == nil {
1289 return
1290 }
1291 a.coverage.Handle(stat)
1292 key := common.InstanceKey(node, server, "portlet_application")
1293 metrics := a.portletApps[key]
1294 if metrics == nil {
1295 metrics = &portletAppMetrics{node: node, server: server}
1296 a.portletApps[key] = metrics
1297 }
1298
1299 for _, cs := range stat.CountStatistics {
1300 value, ok := parseCount(cs.Count)
1301 if !ok {
1302 continue
1303 }
1304 switch strings.ToLower(cs.Name) {
1305 case "number of loaded portlets":
1306 metrics.loadedPortlets = value
1307 }
1308 }
1309 }
1310
1311 func (a *aggregator) processPortlet(node, server string, stat *pmiproto.Stat) {
1312 if stat == nil {
1313 return
1314 }
1315 a.coverage.Handle(stat)
1316 name := stat.Name
1317 if name == "" {
1318 name = "unknown"
1319 }
1320
1321 key := common.InstanceKey(node, server, name)
1322 metrics := a.portlets[key]
1323 if metrics == nil {
1324 metrics = &portletMetrics{node: node, server: server, name: name}
1325 a.portlets[key] = metrics
1326 }
1327
1328 for _, cs := range stat.CountStatistics {
1329 value, ok := parseCount(cs.Count)
1330 if !ok {
1331 continue
1332 }
1333 switch strings.ToLower(cs.Name) {
1334 case "number of portlet requests":
1335 metrics.requestCount = value
1336 case "number of portlet errors":
1337 metrics.errors = value
1338 }
1339 }
1340
1341 for _, rs := range stat.RangeStatistics {
1342 val, ok := parseFloat(rs.Current)
1343 if !ok {
1344 continue
1345 }
1346 switch strings.ToLower(rs.Name) {
1347 case "number of concurrent portlet requests":
1348 metrics.concurrent = int64(math.Round(val))
1349 }
1350 }
1351
1352 for _, ts := range stat.TimeStatistics {
1353 val, ok := parseFloat(ts.TotalTime)
1354 if !ok {
1355 continue
1356 }
1357 ms := convertUnits(int64(math.Round(val)), ts.Unit, unitMilliseconds)
1358 switch strings.ToLower(ts.Name) {
1359 case "response time of portlet render":
1360 metrics.renderTimeMs = ms
1361 case "response time of portlet action":
1362 metrics.actionTimeMs = ms
1363 case "response time of a portlet processevent request":
1364 metrics.processEventMs = ms
1365 case "response time of a portlet serveresource request":
1366 metrics.serveResourceMs = ms
1367 }
1368 }
1369 }
1370
1371 func (a *aggregator) processSessionManager(node, server string, stat *pmiproto.Stat, selectors selectorBundle) {
1372 if stat == nil {
1373 return
1374 }
1375 a.coverage.Handle(stat)
1376 appName := stat.Name
1377 if appName == "" {
1378 appName = "unknown"
1379 }
1380 if selectors.app != nil && !selectors.app.MatchString(appName) {
1381 return
1382 }
1383
1384 key := common.InstanceKey(node, server, appName, "sessions")
1385 metrics := a.sessions[key]
1386 if metrics == nil {
1387 if a.cfg.MaxApplications > 0 && len(a.sessions) >= a.cfg.MaxApplications {
1388 return
1389 }
1390 metrics = &sessionMetrics{node: node, server: server, app: appName}
1391 a.sessions[key] = metrics
1392 }
1393
1394 for _, rs := range stat.RangeStatistics {
1395 value, ok := parseFloat(rs.Current)
1396 if !ok {
1397 continue
1398 }
1399 switch strings.ToLower(rs.Name) {
1400 case "activecount":
1401 metrics.active = int64(math.Round(value))
1402 case "livecount":
1403 metrics.live = int64(math.Round(value))
1404 }
1405 }
1406
1407 for _, cs := range stat.CountStatistics {
1408 value, ok := parseCount(cs.Count)
1409 if !ok {
1410 continue
1411 }
1412 switch strings.ToLower(cs.Name) {
1413 case "createcount":
1414 metrics.createCount = value
1415 case "invalidatecount":
1416 metrics.invalidateCount = value
1417 case "timeoutinvalidationcount":
1418 metrics.timeoutInvalidations = value
1419 case "affinitybreakcount":
1420 metrics.affinityBreaks = value
1421 case "cachediscardcount":
1422 metrics.cacheDiscards = value
1423 case "noroomfornewsessioncount":
1424 metrics.noRoomCount = value
1425 case "activatenonexistsessioncount":
1426 metrics.activateNonExistCount = value
1427 }
1428 }
1429 }
1430
1431 func (a *aggregator) processDynamicCache(node, server string, stat *pmiproto.Stat) {
1432 if stat == nil {
1433 return
1434 }
1435 a.coverage.Handle(stat)
1436 cacheName := stat.Name
1437 if cacheName == "" {
1438 cacheName = "default"
1439 }
1440
1441 key := common.InstanceKey(node, server, cacheName)
1442 metrics := a.dynamicCaches[key]
1443 if metrics == nil {
1444 metrics = &dynamicCacheMetrics{node: node, server: server, cache: cacheName}
1445 a.dynamicCaches[key] = metrics
1446 }
1447
1448 for _, cs := range stat.CountStatistics {
1449 value, ok := parseCount(cs.Count)
1450 if !ok {
1451 continue
1452 }
1453 switch strings.ToLower(cs.Name) {
1454 case "maxinmemorycacheentrycount":
1455 metrics.maxEntries = value
1456 case "inmemorycacheentrycount":
1457 metrics.entries = value
1458 }
1459 }
1460
1461 for i := range stat.SubStats {
1462 sub := &stat.SubStats[i]
1463 a.coverage.Handle(sub)
1464 for j := range sub.SubStats {
1465 a.coverage.Handle(&sub.SubStats[j])
1466 }
1467 }
1468 }
1469
1470 func (a *aggregator) processSystemData(stat *pmiproto.Stat) {
1471 if stat == nil {
1472 return
1473 }
1474 a.coverage.Handle(stat)
1475
1476 for _, cs := range stat.CountStatistics {
1477 value, ok := parseCount(cs.Count)
1478 if !ok {
1479 continue
1480 }
1481 switch strings.ToLower(cs.Name) {
1482 case "cpuusagesincelastmeasurement":
1483 a.systemData.cpuUsageSinceLast = value
1484 case "freememory":
1485 a.systemData.freeMemoryBytes = convertUnits(value, cs.Unit, unitBytes)
1486 }
1487 }
1488
1489 for _, rs := range stat.RangeStatistics {
1490 value, ok := parseFloat(rs.Current)
1491 if !ok {
1492 continue
1493 }
1494 switch strings.ToLower(rs.Name) {
1495 case "freememory":
1496 a.systemData.freeMemoryBytes = convertUnits(int64(math.Round(value)), rs.Unit, unitBytes)
1497 }
1498 }
1499 }
1500
1501 func (a *aggregator) processURLMetric(node, server string, stat *pmiproto.Stat, selectors selectorBundle) {
1502 if stat == nil {
1503 return
1504 }
1505 a.coverage.Handle(stat)
1506 urlName := stat.Name
1507 if urlName == "" {
1508 urlName = "unknown"
1509 }
1510 if selectors.servlet != nil && !selectors.servlet.MatchString(urlName) {
1511 return
1512 }
1513
1514 key := common.InstanceKey(node, server, urlName)
1515 metrics := a.urls[key]
1516 if metrics == nil {
1517 metrics = &urlMetrics{node: node, server: server, url: urlName}
1518 a.urls[key] = metrics
1519 }
1520
1521 for _, cs := range stat.CountStatistics {
1522 value, ok := parseCount(cs.Count)
1523 if !ok {
1524 continue
1525 }
1526 switch strings.ToLower(cs.Name) {
1527 case "urirequestcount":
1528 metrics.requestCount = value
1529 }
1530 }
1531
1532 for _, ts := range stat.TimeStatistics {
1533 val, ok := parseFloat(ts.TotalTime)
1534 if !ok {
1535 continue
1536 }
1537 ms := convertUnits(int64(math.Round(val)), ts.Unit, unitMilliseconds)
1538 switch strings.ToLower(ts.Name) {
1539 case "uriservicetime":
1540 metrics.serviceTimeMs = ms
1541 case "url asynccontext response time":
1542 metrics.asyncResponseMs = ms
1543 }
1544 }
1545 }
1546
1547 func (a *aggregator) processSecurityAuthentication(node, server string, stat *pmiproto.Stat) {
1548 if stat == nil {
1549 return
1550 }
1551 a.coverage.Handle(stat)
1552 key := common.InstanceKey(node, server, "security_auth")
1553 metrics := a.securityAuth[key]
1554 if metrics == nil {
1555 metrics = &securityAuthMetrics{node: node, server: server}
1556 a.securityAuth[key] = metrics
1557 }
1558
1559 for _, cs := range stat.CountStatistics {
1560 value, ok := parseCount(cs.Count)
1561 if !ok {
1562 continue
1563 }
1564 switch strings.ToLower(cs.Name) {
1565 case "webauthenticationcount":
1566 metrics.webAuth = value
1567 case "tairequestcount":
1568 metrics.taiRequests = value
1569 case "identityassertioncount":
1570 metrics.identityAssertions = value
1571 case "basicauthenticationcount":
1572 metrics.basicAuth = value
1573 case "tokenauthenticationcount":
1574 metrics.tokenAuth = value
1575 case "jaasidentityassertioncount":
1576 metrics.jaasIdentity = value
1577 case "jaasbasicauthenticationcount":
1578 metrics.jaasBasic = value
1579 case "jaastokenauthenticationcount":
1580 metrics.jaasToken = value
1581 case "rmiauthenticationcount":
1582 metrics.rmiAuth = value
1583 }
1584 }
1585 }
1586
1587 func (a *aggregator) processSecurityAuthorization(node, server string, stat *pmiproto.Stat) {
1588 if stat == nil {
1589 return
1590 }
1591 a.coverage.Handle(stat)
1592 key := common.InstanceKey(node, server, "security_authz")
1593 metrics := a.securityAuthz[key]
1594 if metrics == nil {
1595 metrics = &securityAuthorizationMetrics{node: node, server: server}
1596 a.securityAuthz[key] = metrics
1597 }
1598
1599 for _, ts := range stat.TimeStatistics {
1600 val, ok := parseFloat(ts.TotalTime)
1601 if !ok {
1602 continue
1603 }
1604 ms := convertUnits(int64(math.Round(val)), ts.Unit, unitMilliseconds)
1605 switch strings.ToLower(ts.Name) {
1606 case "webauthorizationtime":
1607 metrics.webMs = ms
1608 case "ejbauthorizationtime":
1609 metrics.ejbMs = ms
1610 case "adminauthorizationtime":
1611 metrics.adminMs = ms
1612 case "cwwjaauthorizationtime":
1613 metrics.cwwjaMs = ms
1614 }
1615 }
1616 }
1617
1618 func (a *aggregator) processORB(node, server string, stat *pmiproto.Stat) {
1619 if stat == nil {
1620 return
1621 }
1622 a.coverage.Handle(stat)
1623 key := common.InstanceKey(node, server, "orb")
1624 metrics := a.orb[key]
1625 if metrics == nil {
1626 metrics = &orbMetrics{node: node, server: server}
1627 a.orb[key] = metrics
1628 }
1629
1630 for _, rs := range stat.RangeStatistics {
1631 value, ok := parseFloat(rs.Current)
1632 if !ok {
1633 continue
1634 }
1635 switch strings.ToLower(rs.Name) {
1636 case "concurrentrequestcount":
1637 metrics.concurrentRequests = int64(math.Round(value))
1638 }
1639 }
1640
1641 for _, cs := range stat.CountStatistics {
1642 value, ok := parseCount(cs.Count)
1643 if !ok {
1644 continue
1645 }
1646 switch strings.ToLower(cs.Name) {
1647 case "requestcount":
1648 metrics.requestCount = value
1649 }
1650 }
1651
1652 for i := range stat.SubStats {
1653 sub := &stat.SubStats[i]
1654 a.coverage.Handle(sub)
1655 if strings.EqualFold(sub.Name, "Interceptors") {
1656 for j := range sub.SubStats {
1657 interceptor := &sub.SubStats[j]
1658 a.coverage.Handle(interceptor)
1659 for k := range interceptor.CountStatistics {
1660 cs := interceptor.CountStatistics[k]
1661 if strings.EqualFold(cs.Name, "requestcount") {
1662 if value, ok := parseCount(cs.Count); ok {
1663 metrics.requestCount = value
1664 }
1665 }
1666 }
1667 }
1668 }
1669 }
1670 }
1671
1672 func (a *aggregator) processHAManager(node, server string, stat *pmiproto.Stat) {
1673 if stat == nil {
1674 return
1675 }
1676 a.coverage.Handle(stat)
1677 key := common.InstanceKey(node, server, "ha_manager")
1678 metrics := a.haManager[key]
1679 if metrics == nil {
1680 metrics = &haManagerMetrics{node: node, server: server}
1681 a.haManager[key] = metrics
1682 }
1683
1684 updateCount := func(name string, value int64) {
1685 switch name {
1686 case "localgroupcount":
1687 metrics.localGroups = value
1688 case "bulletinboardsubjectcount":
1689 metrics.bBoardSubjects = value
1690 case "bulletinboardsubcriptioncount":
1691 metrics.bBoardSubscriptions = value
1692 case "localbulletinboardsubjectcount":
1693 metrics.localSubjects = value
1694 case "localbulletinboardsubcriptioncount":
1695 metrics.localSubscriptions = value
1696 }
1697 }
1698
1699 for _, rs := range stat.RangeStatistics {
1700 if val, ok := parseFloat(rs.Current); ok {
1701 updateCount(strings.ToLower(rs.Name), int64(math.Round(val)))
1702 }
1703 }
1704
1705 for _, br := range stat.BoundedRangeStatistics {
1706 if val, ok := parseFloat(br.Current); ok {
1707 updateCount(strings.ToLower(br.Name), int64(math.Round(val)))
1708 }
1709 }
1710
1711 for _, ts := range stat.TimeStatistics {
1712 val, ok := parseFloat(ts.TotalTime)
1713 if !ok {
1714 continue
1715 }
1716 ms := convertUnits(int64(math.Round(val)), ts.Unit, unitMilliseconds)
1717 switch strings.ToLower(ts.Name) {
1718 case "groupstaterebuildtime":
1719 metrics.groupStateRebuildMs = ms
1720 case "bulletinboardrebuildtime":
1721 metrics.bBoardRebuildMs = ms
1722 }
1723 }
1724
1725 for i := range stat.SubStats {
1726 a.coverage.Handle(&stat.SubStats[i])
1727 }
1728 }
1729
1730 func (a *aggregator) processAlarmManager(node, server string, stat *pmiproto.Stat) {
1731 if stat == nil {
1732 return
1733 }
1734 a.coverage.Handle(stat)
1735 for i := range stat.SubStats {
1736 manager := &stat.SubStats[i]
1737 a.coverage.Handle(manager)
1738
1739 name := manager.Name
1740 if name == "" {
1741 name = "default"
1742 }
1743 key := common.InstanceKey(node, server, name)
1744 metrics := a.alarmManagers[key]
1745 if metrics == nil {
1746 metrics = &alarmManagerMetrics{node: node, server: server, name: name}
1747 a.alarmManagers[key] = metrics
1748 }
1749 for _, cs := range manager.CountStatistics {
1750 value, ok := parseCount(cs.Count)
1751 if !ok {
1752 continue
1753 }
1754 switch strings.ToLower(cs.Name) {
1755 case "alarmscreatedcount":
1756 metrics.created = value
1757 case "alarmscancelledcount":
1758 metrics.cancelled = value
1759 case "alarmsfiredcount":
1760 metrics.fired = value
1761 }
1762 }
1763 }
1764 }
1765
1766 func (a *aggregator) processSchedulers(node, server string, stat *pmiproto.Stat) {
1767 if stat == nil {
1768 return
1769 }
1770 a.coverage.Handle(stat)
1771 for i := range stat.SubStats {
1772 scheduler := &stat.SubStats[i]
1773 a.coverage.Handle(scheduler)
1774
1775 name := scheduler.Name
1776 if name == "" {
1777 name = "default"
1778 }
1779 key := common.InstanceKey(node, server, name)
1780 metrics := a.schedulers[key]
1781 if metrics == nil {
1782 metrics = &schedulerMetrics{node: node, server: server, name: name}
1783 a.schedulers[key] = metrics
1784 }
1785 for _, cs := range scheduler.CountStatistics {
1786 value, ok := parseCount(cs.Count)
1787 if !ok {
1788 continue
1789 }
1790 switch strings.ToLower(cs.Name) {
1791 case "taskfinishcount":
1792 metrics.finished = value
1793 case "taskfailurecount":
1794 metrics.failures = value
1795 case "pollcount":
1796 metrics.polls = value
1797 }
1798 }
1799 }
1800 }
1801
1802 func (a *aggregator) processSIBService(node, server string, stat *pmiproto.Stat, selectors selectorBundle) {
1803 if stat == nil {
1804 return
1805 }
1806 a.coverage.Handle(stat)
1807 for i := range stat.SubStats {
1808 sub := &stat.SubStats[i]
1809 a.coverage.Handle(sub)
1810 if !strings.EqualFold(sub.Name, "SIB Messaging Engines") {
1811 continue
1812 }
1813 for j := range sub.SubStats {
1814 engine := &sub.SubStats[j]
1815 a.coverage.Handle(engine)
1816 engineName := engine.Name
1817 if engineName == "" {
1818 engineName = "engine"
1819 }
1820 a.processSIBMessagingEngine(node, server, engineName, engine, selectors)
1821 }
1822 }
1823
1824 for i := range stat.SubStats {
1825 s := &stat.SubStats[i]
1826 for j := range s.SubStats {
1827 child := &s.SubStats[j]
1828 a.coverage.Handle(child)
1829 for k := range child.SubStats {
1830 a.coverage.Handle(&child.SubStats[k])
1831 }
1832 }
1833 }
1834 }
1835
1836 func (a *aggregator) processSIBMessagingEngine(node, server, engine string, stat *pmiproto.Stat, selectors selectorBundle) {
1837 if stat == nil {
1838 return
1839 }
1840 a.coverage.Handle(stat)
1841 for i := range stat.SubStats {
1842 sub := &stat.SubStats[i]
1843 a.coverage.Handle(sub)
1844 switch sub.Name {
1845 case "Destinations":
1846 for j := range sub.SubStats {
1847 destGroup := &sub.SubStats[j]
1848 a.coverage.Handle(destGroup)
1849 switch destGroup.Name {
1850 case "Queues":
1851 for k := range destGroup.SubStats {
1852 queue := &destGroup.SubStats[k]
1853 a.coverage.Handle(queue)
1854 a.processSIBQueue(node, server, engine, queue, selectors)
1855 }
1856 case "Topicspaces":
1857 for k := range destGroup.SubStats {
1858 topic := &destGroup.SubStats[k]
1859 a.coverage.Handle(topic)
1860 a.processSIBTopicSpace(node, server, engine, topic, selectors)
1861 }
1862 }
1863 }
1864 case "MessageStoreStats.group":
1865 for j := range sub.SubStats {
1866 section := &sub.SubStats[j]
1867 a.coverage.Handle(section)
1868 sectionName := section.Name
1869 if sectionName == "" {
1870 continue
1871 }
1872 a.processSIBMessageStoreSection(node, server, engine, sectionName, section)
1873 }
1874 }
1875 }
1876 }
1877
1878 func (a *aggregator) processSIBQueue(node, server, engine string, stat *pmiproto.Stat, selectors selectorBundle) {
1879 if stat == nil {
1880 return
1881 }
1882 a.coverage.Handle(stat)
1883 queueName := stat.Name
1884 if queueName == "" {
1885 queueName = "queue"
1886 }
1887 if selectors.jms != nil {
1888 candidate := engine + "/" + queueName
1889 if !selectors.jms.MatchString(candidate) && !selectors.jms.MatchString(queueName) {
1890 return
1891 }
1892 }
1893 key := common.InstanceKey(node, server, engine, queueName)
1894 metrics := a.jmsQueues[key]
1895 if metrics == nil {
1896 if a.cfg.MaxJMSDestinations > 0 && len(a.jmsQueues) >= a.cfg.MaxJMSDestinations {
1897 return
1898 }
1899 metrics = &jmsQueueMetrics{node: node, server: server, engine: engine, name: queueName}
1900 a.jmsQueues[key] = metrics
1901 }
1902
1903 for _, cs := range stat.CountStatistics {
1904 value, ok := parseCount(cs.Count)
1905 if !ok {
1906 continue
1907 }
1908 name := strings.ToLower(cs.Name)
1909 switch name {
1910 case "queuestats.totalmessagesproducedcount":
1911 metrics.totalProduced = value
1912 case "queuestats.besteffortnonpersistentmessagesproducedcount":
1913 metrics.bestEffortProduced = value
1914 case "queuestats.expressnonpersistentmessagesproducedcount":
1915 metrics.expressProduced = value
1916 case "queuestats.reliablenonpersistentmessagesproducedcount":
1917 metrics.reliableNonPersistentProduced = value
1918 case "queuestats.reliablepersistentmessagesproducedcount":
1919 metrics.reliablePersistentProduced = value
1920 case "queuestats.assuredpersistentmessagesproducedcount":
1921 metrics.assuredPersistentProduced = value
1922 case "queuestats.totalmessagesconsumedcount":
1923 metrics.totalConsumed = value
1924 case "queuestats.besteffortnonpersistentmessagesconsumedcount":
1925 metrics.bestEffortConsumed = value
1926 case "queuestats.expressnonpersistentmessagesconsumedcount":
1927 metrics.expressConsumed = value
1928 case "queuestats.reliablenonpersistentmessagesconsumedcount":
1929 metrics.reliableNonPersistentConsumed = value
1930 case "queuestats.reliablepersistentmessagesconsumedcount":
1931 metrics.reliablePersistentConsumed = value
1932 case "queuestats.assuredpersistentmessagesconsumedcount":
1933 metrics.assuredPersistentConsumed = value
1934 case "queuestats.localproducerattachescount":
1935 metrics.localProducerAttaches = value
1936 case "queuestats.localproducercount":
1937 metrics.localProducerCount = value
1938 case "queuestats.localconsumerattachescount":
1939 metrics.localConsumerAttaches = value
1940 case "queuestats.localconsumercount":
1941 metrics.localConsumerCount = value
1942 case "queuestats.availablemessagecount":
1943 metrics.availableMessages = value
1944 case "queuestats.unavailablemessagecount":
1945 metrics.unavailableMessages = value
1946 case "queuestats.localoldestmessageage":
1947 metrics.oldestMessageAgeMs = convertUnits(value, cs.Unit, unitMilliseconds)
1948 case "queuestats.reportenabledmessagesexpiredcount":
1949 metrics.reportEnabledExpired = value
1950 }
1951 }
1952
1953 for _, ts := range stat.TimeStatistics {
1954 val, ok := parseFloat(ts.TotalTime)
1955 if !ok {
1956 continue
1957 }
1958 ms := convertUnits(int64(math.Round(val)), ts.Unit, unitMilliseconds)
1959 name := strings.ToLower(ts.Name)
1960 switch name {
1961 case "queuestats.aggregatemessagewaittime":
1962 metrics.aggregateWaitMs = ms
1963 case "queuestats.localmessagewaittime":
1964 metrics.localWaitMs = ms
1965 }
1966 }
1967 }
1968
1969 func (a *aggregator) processSIBTopicSpace(node, server, engine string, stat *pmiproto.Stat, selectors selectorBundle) {
1970 if stat == nil {
1971 return
1972 }
1973 a.coverage.Handle(stat)
1974 topicName := stat.Name
1975 if topicName == "" {
1976 topicName = "topicspace"
1977 }
1978 if selectors.jms != nil {
1979 candidate := engine + "/" + topicName
1980 if !selectors.jms.MatchString(candidate) && !selectors.jms.MatchString(topicName) {
1981 return
1982 }
1983 }
1984 key := common.InstanceKey(node, server, engine, topicName)
1985 metrics := a.jmsTopics[key]
1986 if metrics == nil {
1987 if a.cfg.MaxJMSDestinations > 0 && len(a.jmsTopics) >= a.cfg.MaxJMSDestinations {
1988 return
1989 }
1990 metrics = &jmsTopicMetrics{node: node, server: server, engine: engine, name: topicName}
1991 a.jmsTopics[key] = metrics
1992 }
1993
1994 for _, cs := range stat.CountStatistics {
1995 value, ok := parseCount(cs.Count)
1996 if !ok {
1997 continue
1998 }
1999 name := strings.ToLower(cs.Name)
2000 switch name {
2001 case "topicspacestats.assuredpersistentlocalsubscriptionhitcount":
2002 metrics.assuredHits = value
2003 case "topicspacestats.besteffortnonpersistentlocalsubscriptionhitcount":
2004 metrics.bestEffortHits = value
2005 case "topicspacestats.expressnonpersistentlocalsubscriptionhitcount":
2006 metrics.expressHits = value
2007 case "topicspacestats.assuredpersistentmessagespublishedcount":
2008 metrics.assuredPublished = value
2009 case "topicspacestats.besteffortnonpersistentmessagespublishedcount":
2010 metrics.bestEffortPublished = value
2011 case "topicspacestats.expressnonpersistentmessagespublishedcount":
2012 metrics.expressPublished = value
2013 case "topicspacestats.durablelocalsubscriptioncount":
2014 metrics.durableLocalSubscriptions = value
2015 case "topicspacestats.incompletepublicationcount":
2016 metrics.incompletePublications = value
2017 case "topicspacestats.localoldestpublicationage":
2018 metrics.localOldestPublicationMs = convertUnits(value, cs.Unit, unitMilliseconds)
2019 case "topicspacestats.localpublisherattachescount":
2020 metrics.localPublisherAttaches = value
2021 case "topicspacestats.localsubscriberattachescount":
2022 metrics.localSubscriberAttaches = value
2023 }
2024 }
2025
2026 a.markNestedStatsSlice(stat.SubStats)
2027 }
2028
2029 func (a *aggregator) processSIBMessageStoreSection(node, server, engine, section string, stat *pmiproto.Stat) {
2030 if stat == nil {
2031 return
2032 }
2033 a.coverage.Handle(stat)
2034 lowerSection := strings.ToLower(section)
2035 sectionLabel := section
2036 if strings.HasPrefix(lowerSection, "messagestorestats.") {
2037 sectionLabel = section[len("MessageStoreStats."):]
2038 lowerSection = strings.ToLower(sectionLabel)
2039 }
2040 key := common.InstanceKey(node, server, engine, sectionLabel)
2041 metrics := a.jmsStores[key]
2042 if metrics == nil {
2043 metrics = &jmsStoreSectionMetrics{node: node, server: server, engine: engine, section: sectionLabel}
2044 a.jmsStores[key] = metrics
2045 }
2046
2047 for _, cs := range stat.CountStatistics {
2048 value, ok := parseCount(cs.Count)
2049 if !ok {
2050 continue
2051 }
2052 name := strings.ToLower(cs.Name)
2053 switch lowerSection {
2054 case "cache":
2055 switch name {
2056 case "messagestorestats.cacheaddstoredcount":
2057 metrics.cacheAddStored = value
2058 case "messagestorestats.cacheaddnotstoredcount":
2059 metrics.cacheAddNotStored = value
2060 case "messagestorestats.cachecurrentstoredcount":
2061 metrics.cacheCurrentStoredCount = value
2062 case "messagestorestats.cachecurrentstoredbytecount":
2063 metrics.cacheCurrentStoredBytes = value
2064 case "messagestorestats.cachecurrentnotstoredcount":
2065 metrics.cacheCurrentNotStoredCount = value
2066 case "messagestorestats.cachecurrentnotstoredbytecount":
2067 metrics.cacheCurrentNotStoredBytes = value
2068 case "messagestorestats.cachenotstoreddiscardcount":
2069 metrics.cacheDiscardCount = value
2070 case "messagestorestats.cachenotstoreddiscardbytecount":
2071 metrics.cacheDiscardBytes = value
2072 }
2073 case "datastore":
2074 switch name {
2075 case "messagestorestats.iteminsertbatchcount":
2076 metrics.datastoreInsertBatches = value
2077 case "messagestorestats.itemupdatebatchcount":
2078 metrics.datastoreUpdateBatches = value
2079 case "messagestorestats.itemdeletebatchcount":
2080 metrics.datastoreDeleteBatches = value
2081 case "messagestorestats.jdbciteminsertcount":
2082 metrics.datastoreInsertCount = value
2083 case "messagestorestats.jdbcitemupdatecount":
2084 metrics.datastoreUpdateCount = value
2085 case "messagestorestats.jdbcitemdeletecount":
2086 metrics.datastoreDeleteCount = value
2087 case "messagestorestats.jdbcopencount":
2088 metrics.datastoreOpenCount = value
2089 case "messagestorestats.jdbctransactionabortcount":
2090 metrics.datastoreAbortCount = value
2091 }
2092 case "expiry":
2093 switch name {
2094 case "messagestorestats.expiryindexitemcount":
2095 metrics.expiryIndexItemCount = value
2096 }
2097 case "transactions":
2098 switch name {
2099 case "messagestorestats.globaltransactionstartcount":
2100 metrics.globalTxnStart = value
2101 case "messagestorestats.globaltransactioncommitcount":
2102 metrics.globalTxnCommit = value
2103 case "messagestorestats.globaltransactionabortcount":
2104 metrics.globalTxnAbort = value
2105 case "messagestorestats.globaltransactionindoubtcount":
2106 metrics.globalTxnInDoubt = value
2107 case "messagestorestats.localtransactionstartcount":
2108 metrics.localTxnStart = value
2109 case "messagestorestats.localtransactioncommitcount":
2110 metrics.localTxnCommit = value
2111 case "messagestorestats.localtransactionabortcount":
2112 metrics.localTxnAbort = value
2113 }
2114 }
2115 }
2116
2117 for _, ts := range stat.TimeStatistics {
2118 val, ok := parseFloat(ts.TotalTime)
2119 if !ok {
2120 continue
2121 }
2122 ms := convertUnits(int64(math.Round(val)), ts.Unit, unitMilliseconds)
2123 name := strings.ToLower(ts.Name)
2124 if lowerSection == "datastore" && name == "messagestorestats.jdbctransactiontime" {
2125 metrics.datastoreTransactionMs = ms
2126 }
2127 }
2128 }
2129
2130 func (a *aggregator) processObjectPool(node, server string, stat *pmiproto.Stat) {
2131 if stat == nil {
2132 return
2133 }
2134 a.coverage.Handle(stat)
2135 for i := range stat.SubStats {
2136 pool := &stat.SubStats[i]
2137 a.coverage.Handle(pool)
2138
2139 name := pool.Name
2140 if name == "" {
2141 name = "default"
2142 }
2143 key := common.InstanceKey(node, server, name)
2144 metrics := a.objectPools[key]
2145 if metrics == nil {
2146 metrics = &objectPoolMetrics{node: node, server: server, name: name}
2147 a.objectPools[key] = metrics
2148 }
2149
2150 for _, cs := range pool.CountStatistics {
2151 value, ok := parseCount(cs.Count)
2152 if !ok {
2153 continue
2154 }
2155 switch strings.ToLower(cs.Name) {
2156 case "objectscreatedcount":
2157 metrics.created = value
2158 }
2159 }
2160
2161 for _, rs := range pool.BoundedRangeStatistics {
2162 value, ok := parseFloat(rs.Current)
2163 if !ok {
2164 continue
2165 }
2166 rounded := int64(math.Round(value))
2167 switch strings.ToLower(rs.Name) {
2168 case "objectsallocatedcount":
2169 metrics.allocated = rounded
2170 case "objectsreturnedcount":
2171 metrics.returned = rounded
2172 case "idleobjectssize":
2173 metrics.idle = rounded
2174 }
2175 }
2176
2177 for _, rs := range pool.RangeStatistics {
2178 value, ok := parseFloat(rs.Current)
2179 if !ok {
2180 continue
2181 }
2182 rounded := int64(math.Round(value))
2183 switch strings.ToLower(rs.Name) {
2184 case "objectsallocatedcount":
2185 metrics.allocated = rounded
2186 case "objectsreturnedcount":
2187 metrics.returned = rounded
2188 case "idleobjectssize":
2189 metrics.idle = rounded
2190 }
2191 }
2192 }
2193 }
2194
2195 func (a *aggregator) processEnterpriseBeans(node, server string, stat *pmiproto.Stat, selectors selectorBundle) {
2196 if stat == nil {
2197 return
2198 }
2199 a.coverage.Handle(stat)
2200 if !a.cfg.CollectEJBMetrics.IsEnabled() {
2201 return
2202 }
2203
2204 for i := range stat.SubStats {
2205 category := &stat.SubStats[i]
2206 a.coverage.Handle(category)
2207
2208 if len(category.SubStats) == 0 {
2209 a.processEnterpriseBeanInstance(node, server, category.Name, category, selectors)
2210 continue
2211 }
2212
2213 for j := range category.SubStats {
2214 bean := &category.SubStats[j]
2215 a.processEnterpriseBeanInstance(node, server, bean.Name, bean, selectors)
2216 a.markNestedStatsSlice(bean.SubStats)
2217 }
2218 }
2219 }
2220
2221 func (a *aggregator) processEnterpriseBeanInstance(node, server, rawName string, bean *pmiproto.Stat, selectors selectorBundle) {
2222 if bean == nil {
2223 return
2224 }
2225 a.coverage.Handle(bean)
2226
2227 name := rawName
2228 if name == "" {
2229 name = bean.Name
2230 }
2231 if name == "" {
2232 name = "unknown"
2233 }
2234
2235 if selectors.ejb != nil && !selectors.ejb.MatchString(name) {
2236 return
2237 }
2238
2239 key := common.InstanceKey(node, server, name)
2240 metrics := a.enterpriseEJB[key]
2241 if metrics == nil {
2242 if a.cfg.MaxEJBs > 0 && len(a.enterpriseEJB) >= a.cfg.MaxEJBs {
2243 return
2244 }
2245 metrics = &enterpriseBeanMetrics{node: node, server: server, name: name}
2246 a.enterpriseEJB[key] = metrics
2247 }
2248
2249 for _, cs := range bean.CountStatistics {
2250 value, ok := parseCount(cs.Count)
2251 if !ok {
2252 continue
2253 }
2254 switch strings.ToLower(cs.Name) {
2255 case "createcount":
2256 metrics.createCount = value
2257 case "removecount":
2258 metrics.removeCount = value
2259 case "activatecount":
2260 metrics.activateCount = value
2261 case "passivatecount":
2262 metrics.passivateCount = value
2263 case "instantiatecount":
2264 metrics.instantiateCount = value
2265 case "storecount":
2266 metrics.storeCount = value
2267 case "loadcount":
2268 metrics.loadCount = value
2269 case "messagecount":
2270 metrics.messageCount = value
2271 case "messagebackoutcount":
2272 metrics.messageBackoutCnt = value
2273 }
2274 }
2275
2276 for _, rs := range bean.RangeStatistics {
2277 value, ok := parseFloat(rs.Current)
2278 if !ok {
2279 continue
2280 }
2281 rounded := int64(math.Round(value))
2282 switch strings.ToLower(rs.Name) {
2283 case "readycount":
2284 metrics.readyCount = rounded
2285 case "livecount":
2286 metrics.liveCount = rounded
2287 case "pooledcount":
2288 metrics.pooledCount = rounded
2289 case "activemethodcount":
2290 metrics.activeMethodCount = rounded
2291 case "passivecount":
2292 metrics.passiveCount = rounded
2293 case "serversessionpoolusage":
2294 metrics.serverSessionPoolUsage = rounded
2295 case "methodreadycount":
2296 metrics.methodReadyCount = rounded
2297 case "asyncqsize":
2298 metrics.asyncQueueSize = rounded
2299 }
2300 }
2301
2302 for _, ts := range bean.TimeStatistics {
2303 value, ok := parseFloat(ts.TotalTime)
2304 if !ok {
2305 continue
2306 }
2307 ms := convertUnits(int64(math.Round(value)), ts.Unit, unitMilliseconds)
2308 switch strings.ToLower(ts.Name) {
2309 case "activationtime":
2310 metrics.activationTimeMs = ms
2311 case "passivationtime":
2312 metrics.passivationTimeMs = ms
2313 case "createtime":
2314 metrics.createTimeMs = ms
2315 case "removetime":
2316 metrics.removeTimeMs = ms
2317 case "loadtime":
2318 metrics.loadTimeMs = ms
2319 case "storetime":
2320 metrics.storeTimeMs = ms
2321 case "methodresponsetime":
2322 metrics.methodResponseTimeMs = ms
2323 case "waittime":
2324 metrics.waitTimeMs = ms
2325 case "asyncwaittime":
2326 metrics.asyncWaitTimeMs = ms
2327 case "readlocktime":
2328 metrics.readLockTimeMs = ms
2329 case "writelocktime":
2330 metrics.writeLockTimeMs = ms
2331 }
2332 }
2333
2334 a.markNestedStatsSlice(bean.SubStats)
2335 }
2336
2337 func (a *aggregator) processWebServices(node, server string, stat *pmiproto.Stat) {
2338 if stat == nil {
2339 return
2340 }
2341 a.coverage.Handle(stat)
2342 for i := range stat.SubStats {
2343 svc := &stat.SubStats[i]
2344 a.coverage.Handle(svc)
2345 name := svc.Name
2346 if name == "" {
2347 name = "default"
2348 }
2349 key := common.InstanceKey(node, server, name)
2350 metrics := a.webServices[key]
2351 if metrics == nil {
2352 metrics = &webServiceMetrics{node: node, server: server, service: name}
2353 a.webServices[key] = metrics
2354 }
2355 for _, cs := range svc.CountStatistics {
2356 value, ok := parseCount(cs.Count)
2357 if !ok {
2358 continue
2359 }
2360 switch strings.ToLower(cs.Name) {
2361 case "loadedwebservicecount":
2362 metrics.loaded = value
2363 }
2364 }
2365
2366 for j := range svc.SubStats {
2367 a.coverage.Handle(&svc.SubStats[j])
2368 }
2369 }
2370 }
2371
2372 func (a *aggregator) processWebServicesGateway(node, server string, stat *pmiproto.Stat) {
2373 if stat == nil {
2374 return
2375 }
2376 a.coverage.Handle(stat)
2377 for i := range stat.SubStats {
2378 gateway := &stat.SubStats[i]
2379 a.coverage.Handle(gateway)
2380 name := gateway.Name
2381 if name == "" {
2382 name = "gateway"
2383 }
2384 key := common.InstanceKey(node, server, name)
2385 metrics := a.webGateway[key]
2386 if metrics == nil {
2387 metrics = &webServiceGatewayMetrics{node: node, server: server, name: name}
2388 a.webGateway[key] = metrics
2389 }
2390 for _, cs := range gateway.CountStatistics {
2391 value, ok := parseCount(cs.Count)
2392 if !ok {
2393 continue
2394 }
2395 switch strings.ToLower(cs.Name) {
2396 case "synchronousrequestcount":
2397 metrics.syncRequests = value
2398 case "synchronousresponsecount":
2399 metrics.syncResponses = value
2400 case "asynchronousrequestcount":
2401 metrics.asyncRequests = value
2402 case "asynchronousresponsecount":
2403 metrics.asyncResponses = value
2404 }
2405 }
2406
2407 for j := range gateway.SubStats {
2408 a.coverage.Handle(&gateway.SubStats[j])
2409 }
2410 }
2411 }
2412
2413 func (a *aggregator) processPMIWebServiceModule(node, server string, stat *pmiproto.Stat) {
2414 if stat == nil {
2415 return
2416 }
2417 a.coverage.Handle(stat)
2418 for i := range stat.SubStats {
2419 module := &stat.SubStats[i]
2420 a.coverage.Handle(module)
2421 name := module.Name
2422 if name == "" {
2423 name = "module"
2424 }
2425 key := common.InstanceKey(node, server, name)
2426 metrics := a.pmiModules[key]
2427 if metrics == nil {
2428 metrics = &pmiWebServiceModuleMetrics{node: node, server: server, name: name}
2429 a.pmiModules[key] = metrics
2430 }
2431 for _, cs := range module.CountStatistics {
2432 value, ok := parseCount(cs.Count)
2433 if !ok {
2434 continue
2435 }
2436 switch strings.ToLower(cs.Name) {
2437 case "servicesloaded":
2438 metrics.loaded = value
2439 }
2440 }
2441
2442 for j := range module.SubStats {
2443 a.coverage.Handle(&module.SubStats[j])
2444 }
2445 }
2446 }
2447
2448 func (a *aggregator) processExtensionRegistry(node, server string, stat *pmiproto.Stat) {
2449 if stat == nil {
2450 return
2451 }
2452 a.coverage.Handle(stat)
2453 metrics := a.extensionReg
2454 metrics.node = node
2455 metrics.server = server
2456
2457 for _, cs := range stat.CountStatistics {
2458 value, ok := parseCount(cs.Count)
2459 if !ok {
2460 continue
2461 }
2462 switch strings.ToLower(cs.Name) {
2463 case "requestcount":
2464 metrics.requests = value
2465 case "hitcount":
2466 metrics.hits = value
2467 case "displacementcount":
2468 metrics.displacements = value
2469 }
2470 }
2471
2472 for _, ds := range stat.DoubleStatistics {
2473 value, ok := parseFloat(ds.Double)
2474 if !ok {
2475 continue
2476 }
2477 if strings.EqualFold(ds.Name, "HitRate") {
2478 metrics.hitRate = int64(math.Round(value * 1000))
2479 }
2480 }
2481
2482 a.extensionReg = metrics
2483 }
2484
2485 func (a *aggregator) exportMetrics(state *framework.CollectorState) {
2486 contexts.System.CPU.Set(state, contexts.EmptyLabels{}, contexts.SystemCPUValues{
2487 Utilization: a.system.cpuUtilization,
2488 })
2489
2490 used := a.system.heapUsed
2491 free := a.system.heapFree
2492 if free == 0 && a.system.heapCommitted > 0 && used > 0 {
2493 if calculated := a.system.heapCommitted - used; calculated > 0 {
2494 free = calculated
2495 }
2496 }
2497 contexts.JVM.HeapUsage.Set(state, contexts.EmptyLabels{}, contexts.JVMHeapUsageValues{
2498 Used: used,
2499 Free: free,
2500 })
2501 if a.system.heapCommitted > 0 {
2502 contexts.JVM.HeapCommitted.Set(state, contexts.EmptyLabels{}, contexts.JVMHeapCommittedValues{
2503 Committed: a.system.heapCommitted,
2504 })
2505 }
2506 if a.system.heapMax > 0 {
2507 contexts.JVM.HeapMax.Set(state, contexts.EmptyLabels{}, contexts.JVMHeapMaxValues{
2508 Limit: a.system.heapMax,
2509 })
2510 }
2511 if a.system.uptimeSeconds > 0 {
2512 contexts.JVM.Uptime.Set(state, contexts.EmptyLabels{}, contexts.JVMUptimeValues{
2513 Uptime: a.system.uptimeSeconds,
2514 })
2515 }
2516 contexts.JVM.CPU.Set(state, contexts.EmptyLabels{}, contexts.JVMCPUValues{
2517 Usage: a.system.cpuUtilization,
2518 })
2519 if a.system.gcCollections > 0 {
2520 contexts.JVM.GCCollections.Set(state, contexts.EmptyLabels{}, contexts.JVMGCCollectionsValues{
2521 Collections: a.system.gcCollections,
2522 })
2523 }
2524 if a.system.gcTimeMs > 0 {
2525 contexts.JVM.GCTime.Set(state, contexts.EmptyLabels{}, contexts.JVMGCTimeValues{
2526 Total: a.system.gcTimeMs,
2527 })
2528 }
2529 contexts.JVM.Threads.Set(state, contexts.EmptyLabels{}, contexts.JVMThreadsValues{
2530 Daemon: a.system.threadDaemon,
2531 Other: a.system.threadOther,
2532 })
2533 if a.system.threadPeak > 0 {
2534 contexts.JVM.ThreadPeak.Set(state, contexts.EmptyLabels{}, contexts.JVMThreadPeakValues{
2535 Peak: a.system.threadPeak,
2536 })
2537 }
2538
2539 for name, tp := range a.threadPools {
2540 labels := contexts.ThreadPoolLabels{Name: name}
2541 contexts.ThreadPool.Usage.Set(state, labels, contexts.ThreadPoolUsageValues{
2542 Active: tp.active,
2543 Size: tp.size,
2544 })
2545 }
2546
2547 for _, tx := range a.transactions {
2548 labels := contexts.TransactionManagerLabels{Node: tx.node, Server: tx.server}
2549 contexts.TransactionManager.Counts.Set(state, labels, contexts.TransactionManagerCountsValues{
2550 Global_begun: tx.globalBegun,
2551 Global_committed: tx.globalCommitted,
2552 Global_rolled_back: tx.globalRolledBack,
2553 Global_timeout: tx.globalTimeout,
2554 Global_involved: tx.globalInvolved,
2555 Optimizations: tx.optimizations,
2556 Local_begun: tx.localBegun,
2557 Local_committed: tx.localCommitted,
2558 Local_rolled_back: tx.localRolledBack,
2559 Local_timeout: tx.localTimeout,
2560 })
2561 contexts.TransactionManager.Active.Set(state, labels, contexts.TransactionManagerActiveValues{
2562 Global: tx.activeGlobal,
2563 Local: tx.activeLocal,
2564 })
2565 contexts.TransactionManager.Time.Set(state, labels, contexts.TransactionManagerTimeValues{
2566 Global_total: tx.globalTotalMs,
2567 Global_prepare: tx.globalPrepareMs,
2568 Global_commit: tx.globalCommitMs,
2569 Global_before_completion: tx.globalBeforeCompletionMs,
2570 Local_total: tx.localTotalMs,
2571 Local_commit: tx.localCommitMs,
2572 Local_before_completion: tx.localBeforeCompletionMs,
2573 })
2574 }
2575
2576 for _, pool := range a.jdbcPools {
2577 labels := contexts.JDBCPoolLabels{Node: pool.node, Server: pool.server, Pool: pool.name}
2578 contexts.JDBCPool.Usage.Set(state, labels, contexts.JDBCPoolUsageValues{
2579 Percent_used: pool.percentUsed,
2580 Percent_maxed: pool.percentMaxed,
2581 })
2582 contexts.JDBCPool.Waiting.Set(state, labels, contexts.JDBCPoolWaitingValues{
2583 Waiting_threads: pool.waitingThreads,
2584 })
2585 contexts.JDBCPool.Connections.Set(state, labels, contexts.JDBCPoolConnectionsValues{
2586 Managed: pool.managedConnections,
2587 Handles: pool.connectionHandles,
2588 })
2589 contexts.JDBCPool.Operations.Set(state, labels, contexts.JDBCPoolOperationsValues{
2590 Created: pool.createCount,
2591 Closed: pool.closeCount,
2592 Allocated: pool.allocateCount,
2593 Returned: pool.returnCount,
2594 Faults: pool.faultCount,
2595 Prep_stmt_cache_discard: pool.prepDiscardCount,
2596 })
2597 contexts.JDBCPool.Time.Set(state, labels, contexts.JDBCPoolTimeValues{
2598 Use: pool.useTimeMs,
2599 Wait: pool.waitTimeMs,
2600 Jdbc: pool.jdbcTimeMs,
2601 })
2602 }
2603
2604 for _, dc := range a.dynamicCaches {
2605 labels := contexts.DynamicCacheLabels{Node: dc.node, Server: dc.server, Cache: dc.cache}
2606 contexts.DynamicCache.InMemory.Set(state, labels, contexts.DynamicCacheInMemoryValues{
2607 Entries: dc.entries,
2608 })
2609 contexts.DynamicCache.Capacity.Set(state, labels, contexts.DynamicCacheCapacityValues{
2610 Max_entries: dc.maxEntries,
2611 })
2612 }
2613
2614 for _, url := range a.urls {
2615 labels := contexts.URLLabels{Node: url.node, Server: url.server, Url: url.url}
2616 contexts.URL.Requests.Set(state, labels, contexts.URLRequestsValues{
2617 Requests: url.requestCount,
2618 })
2619 contexts.URL.Time.Set(state, labels, contexts.URLTimeValues{
2620 Service: url.serviceTimeMs,
2621 Async: url.asyncResponseMs,
2622 })
2623 }
2624
2625 for _, auth := range a.securityAuth {
2626 labels := contexts.SecurityAuthLabels{Node: auth.node, Server: auth.server}
2627 contexts.SecurityAuth.Counts.Set(state, labels, contexts.SecurityAuthCountsValues{
2628 Web: auth.webAuth,
2629 Tai: auth.taiRequests,
2630 Identity: auth.identityAssertions,
2631 Basic: auth.basicAuth,
2632 Token: auth.tokenAuth,
2633 Jaas_identity: auth.jaasIdentity,
2634 Jaas_basic: auth.jaasBasic,
2635 Jaas_token: auth.jaasToken,
2636 Rmi: auth.rmiAuth,
2637 })
2638 }
2639
2640 for _, orb := range a.orb {
2641 labels := contexts.ORBLabels{Node: orb.node, Server: orb.server}
2642 contexts.ORB.Concurrent.Set(state, labels, contexts.ORBConcurrentValues{
2643 Concurrent_requests: orb.concurrentRequests,
2644 })
2645 contexts.ORB.Requests.Set(state, labels, contexts.ORBRequestsValues{
2646 Requests: orb.requestCount,
2647 })
2648 }
2649
2650 for _, app := range a.webApps {
2651 labels := contexts.WebAppLabels{Node: app.node, Server: app.server, App: app.name}
2652 contexts.WebApp.Load.Set(state, labels, contexts.WebAppLoadValues{
2653 Loaded_servlets: app.loadedServlets,
2654 Reloads: app.reloads,
2655 })
2656 }
2657
2658 for _, sess := range a.sessions {
2659 labels := contexts.SessionManagerLabels{Node: sess.node, Server: sess.server, App: sess.app}
2660 contexts.SessionManager.Active.Set(state, labels, contexts.SessionManagerActiveValues{
2661 Active: sess.active,
2662 Live: sess.live,
2663 })
2664 contexts.SessionManager.Events.Set(state, labels, contexts.SessionManagerEventsValues{
2665 Created: sess.createCount,
2666 Invalidated: sess.invalidateCount,
2667 Timeout_invalidations: sess.timeoutInvalidations,
2668 Affinity_breaks: sess.affinityBreaks,
2669 Cache_discards: sess.cacheDiscards,
2670 No_room: sess.noRoomCount,
2671 Activate_non_exist: sess.activateNonExistCount,
2672 })
2673 }
2674
2675 for _, dc := range a.dynamicCaches {
2676 labels := contexts.DynamicCacheLabels{Node: dc.node, Server: dc.server, Cache: dc.cache}
2677 contexts.DynamicCache.InMemory.Set(state, labels, contexts.DynamicCacheInMemoryValues{
2678 Entries: dc.entries,
2679 })
2680 contexts.DynamicCache.Capacity.Set(state, labels, contexts.DynamicCacheCapacityValues{
2681 Max_entries: dc.maxEntries,
2682 })
2683 }
2684
2685 for _, url := range a.urls {
2686 labels := contexts.URLLabels{Node: url.node, Server: url.server, Url: url.url}
2687 contexts.URL.Requests.Set(state, labels, contexts.URLRequestsValues{
2688 Requests: url.requestCount,
2689 })
2690 contexts.URL.Time.Set(state, labels, contexts.URLTimeValues{
2691 Service: url.serviceTimeMs,
2692 Async: url.asyncResponseMs,
2693 })
2694 }
2695
2696 for _, auth := range a.securityAuth {
2697 labels := contexts.SecurityAuthLabels{Node: auth.node, Server: auth.server}
2698 contexts.SecurityAuth.Counts.Set(state, labels, contexts.SecurityAuthCountsValues{
2699 Web: auth.webAuth,
2700 Tai: auth.taiRequests,
2701 Identity: auth.identityAssertions,
2702 Basic: auth.basicAuth,
2703 Token: auth.tokenAuth,
2704 Jaas_identity: auth.jaasIdentity,
2705 Jaas_basic: auth.jaasBasic,
2706 Jaas_token: auth.jaasToken,
2707 Rmi: auth.rmiAuth,
2708 })
2709 }
2710
2711 for _, authz := range a.securityAuthz {
2712 labels := contexts.SecurityAuthzLabels{Node: authz.node, Server: authz.server}
2713 contexts.SecurityAuthz.Time.Set(state, labels, contexts.SecurityAuthzTimeValues{
2714 Web: authz.webMs,
2715 Ejb: authz.ejbMs,
2716 Admin: authz.adminMs,
2717 Cwwja: authz.cwwjaMs,
2718 })
2719 }
2720
2721 for _, ha := range a.haManager {
2722 labels := contexts.HAManagerLabels{Node: ha.node, Server: ha.server}
2723 contexts.HAManager.Groups.Set(state, labels, contexts.HAManagerGroupsValues{
2724 Local: ha.localGroups,
2725 })
2726 contexts.HAManager.BulletinBoard.Set(state, labels, contexts.HAManagerBulletinBoardValues{
2727 Subjects: ha.bBoardSubjects,
2728 Subscriptions: ha.bBoardSubscriptions,
2729 Local_subjects: ha.localSubjects,
2730 Local_subscriptions: ha.localSubscriptions,
2731 })
2732 contexts.HAManager.RebuildTime.Set(state, labels, contexts.HAManagerRebuildTimeValues{
2733 Group_state: ha.groupStateRebuildMs,
2734 Bulletin_board: ha.bBoardRebuildMs,
2735 })
2736 }
2737
2738 for _, alarm := range a.alarmManagers {
2739 labels := contexts.AlarmManagerLabels{Node: alarm.node, Server: alarm.server, Manager: alarm.name}
2740 contexts.AlarmManager.Events.Set(state, labels, contexts.AlarmManagerEventsValues{
2741 Created: alarm.created,
2742 Cancelled: alarm.cancelled,
2743 Fired: alarm.fired,
2744 })
2745 }
2746
2747 for _, scheduler := range a.schedulers {
2748 labels := contexts.SchedulersLabels{Node: scheduler.node, Server: scheduler.server, Scheduler: scheduler.name}
2749 contexts.Schedulers.Activity.Set(state, labels, contexts.SchedulersActivityValues{
2750 Finished: scheduler.finished,
2751 Failures: scheduler.failures,
2752 Polls: scheduler.polls,
2753 })
2754 }
2755
2756 for _, pool := range a.objectPools {
2757 labels := contexts.ObjectPoolLabels{Node: pool.node, Server: pool.server, Pool: pool.name}
2758 contexts.ObjectPool.Operations.Set(state, labels, contexts.ObjectPoolOperationsValues{
2759 Created: pool.created,
2760 })
2761 contexts.ObjectPool.Size.Set(state, labels, contexts.ObjectPoolSizeValues{
2762 Allocated: pool.allocated,
2763 Returned: pool.returned,
2764 Idle: pool.idle,
2765 })
2766 }
2767
2768 for _, pool := range a.jcaPools {
2769 labels := contexts.JCAPoolLabels{Node: pool.node, Server: pool.server, Provider: pool.provider, Pool: pool.name}
2770 contexts.JCAPool.Operations.Set(state, labels, contexts.JCAPoolOperationsValues{
2771 Create: pool.createCount,
2772 Close: pool.closeCount,
2773 Allocate: pool.allocateCount,
2774 Freed: pool.freedCount,
2775 Faults: pool.faultCount,
2776 })
2777 contexts.JCAPool.Managed.Set(state, labels, contexts.JCAPoolManagedValues{
2778 Managed_connections: pool.managedConnections,
2779 Connection_handles: pool.connectionHandles,
2780 })
2781 contexts.JCAPool.Utilization.Set(state, labels, contexts.JCAPoolUtilizationValues{
2782 Percent_used: pool.percentUsed,
2783 Percent_maxed: pool.percentMaxed,
2784 })
2785 contexts.JCAPool.Waiting.Set(state, labels, contexts.JCAPoolWaitingValues{
2786 Waiting_threads: pool.waitingThreads,
2787 })
2788 }
2789
2790 for _, queue := range a.jmsQueues {
2791 labels := contexts.JMSQueueLabels{Node: queue.node, Server: queue.server, Engine: queue.engine, Destination: queue.name}
2792 contexts.JMSQueue.MessagesProduced.Set(state, labels, contexts.JMSQueueMessagesProducedValues{
2793 Total: queue.totalProduced,
2794 Best_effort: queue.bestEffortProduced,
2795 Express: queue.expressProduced,
2796 Reliable_nonpersistent: queue.reliableNonPersistentProduced,
2797 Reliable_persistent: queue.reliablePersistentProduced,
2798 Assured_persistent: queue.assuredPersistentProduced,
2799 })
2800 contexts.JMSQueue.MessagesConsumed.Set(state, labels, contexts.JMSQueueMessagesConsumedValues{
2801 Total: queue.totalConsumed,
2802 Best_effort: queue.bestEffortConsumed,
2803 Express: queue.expressConsumed,
2804 Reliable_nonpersistent: queue.reliableNonPersistentConsumed,
2805 Reliable_persistent: queue.reliablePersistentConsumed,
2806 Assured_persistent: queue.assuredPersistentConsumed,
2807 Expired: queue.reportEnabledExpired,
2808 })
2809 contexts.JMSQueue.Clients.Set(state, labels, contexts.JMSQueueClientsValues{
2810 Local_producers: queue.localProducerCount,
2811 Local_producer_attaches: queue.localProducerAttaches,
2812 Local_consumers: queue.localConsumerCount,
2813 Local_consumer_attaches: queue.localConsumerAttaches,
2814 })
2815 contexts.JMSQueue.Storage.Set(state, labels, contexts.JMSQueueStorageValues{
2816 Available: queue.availableMessages,
2817 Unavailable: queue.unavailableMessages,
2818 Oldest_age: queue.oldestMessageAgeMs,
2819 })
2820 contexts.JMSQueue.WaitTime.Set(state, labels, contexts.JMSQueueWaitTimeValues{
2821 Aggregate: queue.aggregateWaitMs,
2822 Local: queue.localWaitMs,
2823 })
2824 }
2825
2826 for _, topic := range a.jmsTopics {
2827 labels := contexts.JMSTopicLabels{Node: topic.node, Server: topic.server, Engine: topic.engine, Destination: topic.name}
2828 contexts.JMSTopic.Publications.Set(state, labels, contexts.JMSTopicPublicationsValues{
2829 Assured: topic.assuredPublished,
2830 Best_effort: topic.bestEffortPublished,
2831 Express: topic.expressPublished,
2832 })
2833 contexts.JMSTopic.SubscriptionHits.Set(state, labels, contexts.JMSTopicSubscriptionHitsValues{
2834 Assured: topic.assuredHits,
2835 Best_effort: topic.bestEffortHits,
2836 Express: topic.expressHits,
2837 })
2838 contexts.JMSTopic.Subscriptions.Set(state, labels, contexts.JMSTopicSubscriptionsValues{
2839 Durable_local: topic.durableLocalSubscriptions,
2840 })
2841 contexts.JMSTopic.Events.Set(state, labels, contexts.JMSTopicEventsValues{
2842 Incomplete_publications: topic.incompletePublications,
2843 Publisher_attaches: topic.localPublisherAttaches,
2844 Subscriber_attaches: topic.localSubscriberAttaches,
2845 })
2846 contexts.JMSTopic.Age.Set(state, labels, contexts.JMSTopicAgeValues{
2847 Local_oldest: topic.localOldestPublicationMs,
2848 })
2849 }
2850
2851 for _, store := range a.jmsStores {
2852 labels := contexts.JMSStoreLabels{Node: store.node, Server: store.server, Engine: store.engine, Section: store.section}
2853 switch strings.ToLower(store.section) {
2854 case "cache":
2855 contexts.JMSStore.Cache.Set(state, labels, contexts.JMSStoreCacheValues{
2856 Add_stored: store.cacheAddStored,
2857 Add_not_stored: store.cacheAddNotStored,
2858 Stored_current: store.cacheCurrentStoredCount,
2859 Stored_bytes: store.cacheCurrentStoredBytes,
2860 Not_stored_current: store.cacheCurrentNotStoredCount,
2861 Not_stored_bytes: store.cacheCurrentNotStoredBytes,
2862 Discard_count: store.cacheDiscardCount,
2863 Discard_bytes: store.cacheDiscardBytes,
2864 })
2865 case "datastore":
2866 contexts.JMSStore.Datastore.Set(state, labels, contexts.JMSStoreDatastoreValues{
2867 Insert_batches: store.datastoreInsertBatches,
2868 Update_batches: store.datastoreUpdateBatches,
2869 Delete_batches: store.datastoreDeleteBatches,
2870 Insert_count: store.datastoreInsertCount,
2871 Update_count: store.datastoreUpdateCount,
2872 Delete_count: store.datastoreDeleteCount,
2873 Open_count: store.datastoreOpenCount,
2874 Abort_count: store.datastoreAbortCount,
2875 Transaction_ms: store.datastoreTransactionMs,
2876 })
2877 case "transactions":
2878 contexts.JMSStore.Transactions.Set(state, labels, contexts.JMSStoreTransactionsValues{
2879 Global_start: store.globalTxnStart,
2880 Global_commit: store.globalTxnCommit,
2881 Global_abort: store.globalTxnAbort,
2882 Global_indoubt: store.globalTxnInDoubt,
2883 Local_start: store.localTxnStart,
2884 Local_commit: store.localTxnCommit,
2885 Local_abort: store.localTxnAbort,
2886 })
2887 case "expiry":
2888 contexts.JMSStore.Expiry.Set(state, labels, contexts.JMSStoreExpiryValues{
2889 Index_items: store.expiryIndexItemCount,
2890 })
2891 }
2892 }
2893
2894 for _, app := range a.portletApps {
2895 labels := contexts.PortletApplicationLabels{Node: app.node, Server: app.server}
2896 contexts.PortletApplication.Loaded.Set(state, labels, contexts.PortletApplicationLoadedValues{
2897 Loaded: app.loadedPortlets,
2898 })
2899 }
2900
2901 for _, portlet := range a.portlets {
2902 labels := contexts.PortletLabels{Node: portlet.node, Server: portlet.server, Portlet: portlet.name}
2903 contexts.Portlet.Requests.Set(state, labels, contexts.PortletRequestsValues{
2904 Requests: portlet.requestCount,
2905 })
2906 contexts.Portlet.Concurrent.Set(state, labels, contexts.PortletConcurrentValues{
2907 Concurrent: portlet.concurrent,
2908 })
2909 contexts.Portlet.Errors.Set(state, labels, contexts.PortletErrorsValues{
2910 Errors: portlet.errors,
2911 })
2912 contexts.Portlet.ResponseTime.Set(state, labels, contexts.PortletResponseTimeValues{
2913 Render: portlet.renderTimeMs,
2914 Action: portlet.actionTimeMs,
2915 Process_event: portlet.processEventMs,
2916 Serve_resource: portlet.serveResourceMs,
2917 })
2918 }
2919
2920 for _, bean := range a.enterpriseEJB {
2921 labels := contexts.EnterpriseBeansLabels{Node: bean.node, Server: bean.server, Bean: bean.name}
2922 contexts.EnterpriseBeans.Operations.Set(state, labels, contexts.EnterpriseBeansOperationsValues{
2923 Create: bean.createCount,
2924 Remove: bean.removeCount,
2925 Activate: bean.activateCount,
2926 Passivate: bean.passivateCount,
2927 Instantiate: bean.instantiateCount,
2928 Store: bean.storeCount,
2929 Load: bean.loadCount,
2930 })
2931 contexts.EnterpriseBeans.Messages.Set(state, labels, contexts.EnterpriseBeansMessagesValues{
2932 Received: bean.messageCount,
2933 Backout: bean.messageBackoutCnt,
2934 })
2935 contexts.EnterpriseBeans.Pool.Set(state, labels, contexts.EnterpriseBeansPoolValues{
2936 Ready: bean.readyCount,
2937 Live: bean.liveCount,
2938 Pooled: bean.pooledCount,
2939 Active_method: bean.activeMethodCount,
2940 Passive: bean.passiveCount,
2941 Server_session_pool: bean.serverSessionPoolUsage,
2942 Method_ready: bean.methodReadyCount,
2943 Async_queue: bean.asyncQueueSize,
2944 })
2945 contexts.EnterpriseBeans.Time.Set(state, labels, contexts.EnterpriseBeansTimeValues{
2946 Activation: bean.activationTimeMs,
2947 Passivation: bean.passivationTimeMs,
2948 Create: bean.createTimeMs,
2949 Remove: bean.removeTimeMs,
2950 Load: bean.loadTimeMs,
2951 Store: bean.storeTimeMs,
2952 Method_response: bean.methodResponseTimeMs,
2953 Wait: bean.waitTimeMs,
2954 Async_wait: bean.asyncWaitTimeMs,
2955 Read_lock: bean.readLockTimeMs,
2956 Write_lock: bean.writeLockTimeMs,
2957 })
2958 }
2959
2960 for _, svc := range a.webServices {
2961 labels := contexts.WebServicesLabels{Node: svc.node, Server: svc.server, Service: svc.service}
2962 contexts.WebServices.Loaded.Set(state, labels, contexts.WebServicesLoadedValues{
2963 Loaded: svc.loaded,
2964 })
2965 }
2966
2967 for _, gw := range a.webGateway {
2968 labels := contexts.WebServicesGatewayLabels{Node: gw.node, Server: gw.server, Gateway: gw.name}
2969 contexts.WebServicesGateway.Requests.Set(state, labels, contexts.WebServicesGatewayRequestsValues{
2970 Synchronous: gw.syncRequests,
2971 Synchronous_responses: gw.syncResponses,
2972 Asynchronous: gw.asyncRequests,
2973 Asynchronous_responses: gw.asyncResponses,
2974 })
2975 }
2976
2977 for _, module := range a.pmiModules {
2978 labels := contexts.PMIWebServiceModuleLabels{Node: module.node, Server: module.server, Module: module.name}
2979 contexts.PMIWebServiceModule.Services.Set(state, labels, contexts.PMIWebServiceModuleServicesValues{
2980 Loaded: module.loaded,
2981 })
2982 }
2983
2984 if a.extensionReg.node != "" || a.extensionReg.requests != 0 || a.extensionReg.hitRate != 0 {
2985 labels := contexts.ExtensionRegistryLabels{Node: a.extensionReg.node, Server: a.extensionReg.server}
2986 contexts.ExtensionRegistry.Requests.Set(state, labels, contexts.ExtensionRegistryRequestsValues{
2987 Requests: a.extensionReg.requests,
2988 Hits: a.extensionReg.hits,
2989 Displacements: a.extensionReg.displacements,
2990 })
2991 contexts.ExtensionRegistry.HitRate.Set(state, labels, contexts.ExtensionRegistryHitRateValues{
2992 Hit_rate: a.extensionReg.hitRate,
2993 })
2994 }
2995
2996 contexts.SystemData.Usage.Set(state, contexts.EmptyLabels{}, contexts.SystemDataUsageValues{
2997 Cpu_since_last: a.systemData.cpuUsageSinceLast,
2998 Free_memory: a.systemData.freeMemoryBytes,
2999 })
3000 }
3001
3002 func (a *aggregator) collectJDBCMetricsEnabled() bool {
3003 return a.cfg.CollectJDBCMetrics.IsEnabled()
3004 }
3005
3006 func (a *aggregator) collectWebAppMetricsEnabled() bool {
3007 return a.cfg.CollectWebAppMetrics.IsEnabled()
3008 }
3009
3010 func (a *aggregator) collectSessionMetricsEnabled() bool {
3011 return a.cfg.CollectSessionMetrics.IsEnabled()
3012 }
3013
3014 func (a *aggregator) collectDynamicCacheMetricsEnabled() bool {
3015 return a.cfg.CollectWebAppMetrics.IsEnabled()
3016 }
3017
3018 func (a *aggregator) collectSystemDataEnabled() bool {
3019 return true
3020 }
3021
3022 func (a *aggregator) collectServletMetricsEnabled() bool {
3023 return a.cfg.CollectServletMetrics.IsEnabled()
3024 }
3025
3026 func (a *aggregator) collectJCAMetricsEnabled() bool {
3027 return a.cfg.CollectJCAMetrics.IsEnabled()
3028 }
3029
3030 func (a *aggregator) collectJMSMetricsEnabled() bool {
3031 return a.cfg.CollectJMSMetrics.IsEnabled()
3032 }
3033
3034 func parseCount(value string) (int64, bool) {
3035 if value == "" {
3036 return 0, false
3037 }
3038 v, err := strconv.ParseInt(value, 10, 64)
3039 if err == nil {
3040 return v, true
3041 }
3042 floatVal, ferr := strconv.ParseFloat(value, 64)
3043 if ferr != nil {
3044 return 0, false
3045 }
3046 return int64(math.Round(floatVal)), true
3047 }
3048
3049 func parseFloat(value string) (float64, bool) {
3050 if value == "" {
3051 return 0, false
3052 }
3053 v, err := strconv.ParseFloat(value, 64)
3054 if err != nil {
3055 return 0, false
3056 }
3057 return v, true
3058 }
3059
3060 const (
3061 unitBytes = "BYTES"
3062 unitMilliseconds = "MILLISECONDS"
3063 unitSeconds = "SECONDS"
3064 )
3065
3066 func convertUnits(value int64, unit string, target string) int64 {
3067 unit = strings.TrimSpace(strings.ToUpper(unit))
3068 if unit == "" {
3069 unit = unitBytes
3070 }
3071 switch target {
3072 case unitBytes:
3073 return convertToBytes(value, unit)
3074 case unitMilliseconds:
3075 return convertToMilliseconds(value, unit)
3076 case unitSeconds:
3077 return convertToSeconds(value, unit)
3078 default:
3079 return value
3080 }
3081 }
3082
3083 func (a *aggregator) coverageMissing() []string {
3084 if a.coverage == nil {
3085 return nil
3086 }
3087 return a.coverage.Missing()
3088 }
3089
3090 func convertToBytes(value int64, unit string) int64 {
3091 switch unit {
3092 case "BYTE", "BYTES", "N/A", "NONE", "COUNT":
3093 return value
3094 case "KILOBYTE", "KB":
3095 return value * 1024
3096 case "MEGABYTE", "MB":
3097 return value * 1024 * 1024
3098 case "GIGABYTE", "GB":
3099 return value * 1024 * 1024 * 1024
3100 default:
3101 return value
3102 }
3103 }
3104
3105 func convertToMilliseconds(value int64, unit string) int64 {
3106 switch unit {
3107 case "MILLISECOND", "MILLISECONDS":
3108 return value
3109 case "SECOND", "SECONDS":
3110 return value * 1000
3111 case "MICROSECOND":
3112 return value / 1000
3113 default:
3114 return value
3115 }
3116 }
3117
3118 func convertToSeconds(value int64, unit string) int64 {
3119 switch unit {
3120 case "SECOND", "SECONDS":
3121 return value
3122 case "MILLISECOND", "MILLISECONDS":
3123 return value / 1000
3124 case "MICROSECOND":
3125 return value / 1_000_000
3126 case "MINUTE", "MINUTES":
3127 return value * 60
3128 case "HOUR", "HOURS":
3129 return value * 3600
3130 default:
3131 return value
3132 }
3133 }