mirror of
				https://github.com/ClusterCockpit/cc-metric-collector.git
				synced 2025-11-04 10:45:06 +01:00 
			
		
		
		
	Skip non existing processor metrics URLs
This commit is contained in:
		@@ -30,6 +30,8 @@ type RedfishReceiverClientConfig struct {
 | 
				
			|||||||
	doProcessorMetrics bool
 | 
						doProcessorMetrics bool
 | 
				
			||||||
	doThermalMetrics   bool
 | 
						doThermalMetrics   bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						skipProcessorMetricsURL map[string]bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	gofish gofish.ClientConfig
 | 
						gofish gofish.ClientConfig
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -314,14 +316,25 @@ func (r *RedfishReceiver) readProcessorMetrics(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	timestamp := time.Now()
 | 
						timestamp := time.Now()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Golang 1.19: URL, _ := url.JoinPath(processor.ODataID, "ProcessorMetrics")
 | 
						// URL to processor metrics
 | 
				
			||||||
	URL := processor.ODataID + "/ProcessorMetrics"
 | 
						URL := processor.ODataID + "/ProcessorMetrics"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Skip previously detected non existing URLs
 | 
				
			||||||
 | 
						if clientConfig.skipProcessorMetricsURL[URL] {
 | 
				
			||||||
 | 
							return nil
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp, err := processor.Client.Get(URL)
 | 
						resp, err := processor.Client.Get(URL)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		// Skip non existing URLs
 | 
							// Skip non existing URLs
 | 
				
			||||||
 | 
							if statusCode := err.(*common.Error).HTTPReturnedStatusCode; statusCode == http.StatusNotFound {
 | 
				
			||||||
 | 
								clientConfig.skipProcessorMetricsURL[URL] = true
 | 
				
			||||||
			return nil
 | 
								return nil
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return fmt.Errorf("processor.Client.Get(%v) failed: %+w", URL, err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var processorMetrics struct {
 | 
						var processorMetrics struct {
 | 
				
			||||||
		common.Entity
 | 
							common.Entity
 | 
				
			||||||
		ODataType   string `json:"@odata.type"`
 | 
							ODataType   string `json:"@odata.type"`
 | 
				
			||||||
@@ -741,6 +754,8 @@ func NewRedfishReceiver(name string, config json.RawMessage) (Receiver, error) {
 | 
				
			|||||||
			!(configJSON.DisableThermalMetrics ||
 | 
								!(configJSON.DisableThermalMetrics ||
 | 
				
			||||||
				clientConfigJSON.DisableThermalMetrics)
 | 
									clientConfigJSON.DisableThermalMetrics)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							clientConfig.skipProcessorMetricsURL = make(map[string]bool)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Is metrics excluded globally or per client
 | 
							// Is metrics excluded globally or per client
 | 
				
			||||||
		clientConfig.isExcluded = make(map[string]bool)
 | 
							clientConfig.isExcluded = make(map[string]bool)
 | 
				
			||||||
		for _, key := range clientConfigJSON.ExcludeMetrics {
 | 
							for _, key := range clientConfigJSON.ExcludeMetrics {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user