mirror of
				https://github.com/ClusterCockpit/cc-metric-collector.git
				synced 2025-11-04 10:45:06 +01:00 
			
		
		
		
	Send all metrics with same time stamp
calcGlobalMetrics does only computiation, counter measurement is done before
This commit is contained in:
		@@ -554,14 +554,16 @@ func (m *LikwidCollector) calcEventsetMetrics(evset LikwidEventsetConfig, interv
 | 
				
			|||||||
				// Now we have the result, send it with the proper tags
 | 
									// Now we have the result, send it with the proper tags
 | 
				
			||||||
				if !math.IsNaN(value) && metric.Publish {
 | 
									if !math.IsNaN(value) && metric.Publish {
 | 
				
			||||||
					fields := map[string]interface{}{"value": value}
 | 
										fields := map[string]interface{}{"value": value}
 | 
				
			||||||
					y, err := lp.New(
 | 
										y, err :=
 | 
				
			||||||
						metric.Name,
 | 
											lp.New(
 | 
				
			||||||
						map[string]string{
 | 
												metric.Name,
 | 
				
			||||||
							"type": metric.Type,
 | 
												map[string]string{
 | 
				
			||||||
						},
 | 
													"type": metric.Type,
 | 
				
			||||||
						m.meta,
 | 
												},
 | 
				
			||||||
						fields,
 | 
												m.meta,
 | 
				
			||||||
						now)
 | 
												fields,
 | 
				
			||||||
 | 
												now,
 | 
				
			||||||
 | 
											)
 | 
				
			||||||
					if err == nil {
 | 
										if err == nil {
 | 
				
			||||||
						if metric.Type != "node" {
 | 
											if metric.Type != "node" {
 | 
				
			||||||
							y.AddTag("type-id", fmt.Sprintf("%d", domain))
 | 
												y.AddTag("type-id", fmt.Sprintf("%d", domain))
 | 
				
			||||||
@@ -589,18 +591,19 @@ func (m *LikwidCollector) calcEventsetMetrics(evset LikwidEventsetConfig, interv
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			for coreID, value := range totalCoreValues {
 | 
								for coreID, value := range totalCoreValues {
 | 
				
			||||||
				y, err := lp.New(
 | 
									y, err :=
 | 
				
			||||||
					metric.Name,
 | 
										lp.New(
 | 
				
			||||||
					map[string]string{
 | 
											metric.Name,
 | 
				
			||||||
						"type":    "core",
 | 
											map[string]string{
 | 
				
			||||||
						"type-id": fmt.Sprintf("%d", coreID),
 | 
												"type":    "core",
 | 
				
			||||||
					},
 | 
												"type-id": fmt.Sprintf("%d", coreID),
 | 
				
			||||||
					m.meta,
 | 
											},
 | 
				
			||||||
					map[string]interface{}{
 | 
											m.meta,
 | 
				
			||||||
						"value": value,
 | 
											map[string]interface{}{
 | 
				
			||||||
					},
 | 
												"value": value,
 | 
				
			||||||
					now,
 | 
											},
 | 
				
			||||||
				)
 | 
											now,
 | 
				
			||||||
 | 
										)
 | 
				
			||||||
				if err != nil {
 | 
									if err != nil {
 | 
				
			||||||
					continue
 | 
										continue
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
@@ -625,18 +628,19 @@ func (m *LikwidCollector) calcEventsetMetrics(evset LikwidEventsetConfig, interv
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			for socketID, value := range totalSocketValues {
 | 
								for socketID, value := range totalSocketValues {
 | 
				
			||||||
				y, err := lp.New(
 | 
									y, err :=
 | 
				
			||||||
					metric.Name,
 | 
										lp.New(
 | 
				
			||||||
					map[string]string{
 | 
											metric.Name,
 | 
				
			||||||
						"type":    "socket",
 | 
											map[string]string{
 | 
				
			||||||
						"type-id": fmt.Sprintf("%d", socketID),
 | 
												"type":    "socket",
 | 
				
			||||||
					},
 | 
												"type-id": fmt.Sprintf("%d", socketID),
 | 
				
			||||||
					m.meta,
 | 
											},
 | 
				
			||||||
					map[string]interface{}{
 | 
											m.meta,
 | 
				
			||||||
						"value": value,
 | 
											map[string]interface{}{
 | 
				
			||||||
					},
 | 
												"value": value,
 | 
				
			||||||
					now,
 | 
											},
 | 
				
			||||||
				)
 | 
											now,
 | 
				
			||||||
 | 
										)
 | 
				
			||||||
				if err != nil {
 | 
									if err != nil {
 | 
				
			||||||
					continue
 | 
										continue
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
@@ -659,17 +663,18 @@ func (m *LikwidCollector) calcEventsetMetrics(evset LikwidEventsetConfig, interv
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			y, err := lp.New(
 | 
								y, err :=
 | 
				
			||||||
				metric.Name,
 | 
									lp.New(
 | 
				
			||||||
				map[string]string{
 | 
										metric.Name,
 | 
				
			||||||
					"type": "node",
 | 
										map[string]string{
 | 
				
			||||||
				},
 | 
											"type": "node",
 | 
				
			||||||
				m.meta,
 | 
										},
 | 
				
			||||||
				map[string]interface{}{
 | 
										m.meta,
 | 
				
			||||||
					"value": totalNodeValue,
 | 
										map[string]interface{}{
 | 
				
			||||||
				},
 | 
											"value": totalNodeValue,
 | 
				
			||||||
				now,
 | 
										},
 | 
				
			||||||
			)
 | 
										now,
 | 
				
			||||||
 | 
									)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				continue
 | 
									continue
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -685,7 +690,13 @@ func (m *LikwidCollector) calcEventsetMetrics(evset LikwidEventsetConfig, interv
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Go over the global metrics, derive the value out of the event sets' metric values and send it
 | 
					// Go over the global metrics, derive the value out of the event sets' metric values and send it
 | 
				
			||||||
func (m *LikwidCollector) calcGlobalMetrics(groups []LikwidEventsetConfig, interval time.Duration, output chan lp.CCMetric) error {
 | 
					func (m *LikwidCollector) calcGlobalMetrics(groups []LikwidEventsetConfig, interval time.Duration, output chan lp.CCMetric) error {
 | 
				
			||||||
 | 
						// Send all metrics with same time stamp
 | 
				
			||||||
 | 
						// This function does only computiation, counter measurement is done before
 | 
				
			||||||
 | 
						now := time.Now()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, metric := range m.config.Metrics {
 | 
						for _, metric := range m.config.Metrics {
 | 
				
			||||||
 | 
							// The metric scope is determined in the Init() function
 | 
				
			||||||
 | 
							// Get the map scope-id -> tids
 | 
				
			||||||
		scopemap := m.cpu2tid
 | 
							scopemap := m.cpu2tid
 | 
				
			||||||
		if metric.Type == "socket" {
 | 
							if metric.Type == "socket" {
 | 
				
			||||||
			scopemap = m.sock2tid
 | 
								scopemap = m.sock2tid
 | 
				
			||||||
@@ -712,9 +723,18 @@ func (m *LikwidCollector) calcGlobalMetrics(groups []LikwidEventsetConfig, inter
 | 
				
			|||||||
				// Now we have the result, send it with the proper tags
 | 
									// Now we have the result, send it with the proper tags
 | 
				
			||||||
				if !math.IsNaN(value) {
 | 
									if !math.IsNaN(value) {
 | 
				
			||||||
					if metric.Publish {
 | 
										if metric.Publish {
 | 
				
			||||||
						tags := map[string]string{"type": metric.Type}
 | 
											y, err :=
 | 
				
			||||||
						fields := map[string]interface{}{"value": value}
 | 
												lp.New(
 | 
				
			||||||
						y, err := lp.New(metric.Name, tags, m.meta, fields, time.Now())
 | 
													metric.Name,
 | 
				
			||||||
 | 
													map[string]string{
 | 
				
			||||||
 | 
														"type": metric.Type,
 | 
				
			||||||
 | 
													},
 | 
				
			||||||
 | 
													m.meta,
 | 
				
			||||||
 | 
													map[string]interface{}{
 | 
				
			||||||
 | 
														"value": value,
 | 
				
			||||||
 | 
													},
 | 
				
			||||||
 | 
													now,
 | 
				
			||||||
 | 
												)
 | 
				
			||||||
						if err == nil {
 | 
											if err == nil {
 | 
				
			||||||
							if metric.Type != "node" {
 | 
												if metric.Type != "node" {
 | 
				
			||||||
								y.AddTag("type-id", fmt.Sprintf("%d", domain))
 | 
													y.AddTag("type-id", fmt.Sprintf("%d", domain))
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user