|
@@ -84,12 +84,12 @@ func calculateWeightedAverage(response *client.Response,
|
|
return metrics, nil
|
|
return metrics, nil
|
|
}
|
|
}
|
|
|
|
|
|
-func queryInfluxDB(metrics []string, uuid string, socket,
|
|
+func customScoreInfluxDB(metrics []string, uuid string, socket,
|
|
- time int, cfg Config, c client.Client) (map[string]float64, error) {
|
|
+ numberOfRows int, cfg Config, c client.Client) (map[string]float64, error) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- numberOfRows := int(float32(time) / cfg.MonitoringSpecs.TimeInterval)
|
|
+
|
|
|
|
|
|
columns := strings.Join(metrics, ", ")
|
|
columns := strings.Join(metrics, ", ")
|
|
|
|
|
|
@@ -131,17 +131,36 @@ func customResourceScorer(nodeName string) (float64, error) {
|
|
|
|
|
|
curr_uuid, ok := nodes[nodeName]
|
|
curr_uuid, ok := nodes[nodeName]
|
|
socket, _ := sockets[nodeName]
|
|
socket, _ := sockets[nodeName]
|
|
|
|
+ cores, _ := cores[nodeName]
|
|
|
|
|
|
if ok {
|
|
if ok {
|
|
|
|
|
|
|
|
+ metrics := []string{"c6res"}
|
|
|
|
+ time := 20
|
|
|
|
+
|
|
|
|
+ numberOfRows := int(float32(time) / cfg.MonitoringSpecs.TimeInterval)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ r, err := queryInfluxDbCores(metrics, curr_uuid, socket, numberOfRows, cfg, c, cores)
|
|
|
|
+ if err != nil {
|
|
|
|
+ klog.Infof("Error in querying or calculating core availability in the first stage: %v", err.Error())
|
|
|
|
+ }
|
|
|
|
+ average, err := calculateWeightedAverageCores(r, numberOfRows, len(metrics), len(cores))
|
|
|
|
+ if err != nil {
|
|
|
|
+ klog.Infof("Error defining core availability")
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
- results, err := queryInfluxDB([]string{"ipc", "mem_read", "mem_write"}, curr_uuid, socket, 20, cfg, c)
|
|
+ results, err := customScoreInfluxDB([]string{"ipc", "mem_read", "mem_write"}, curr_uuid, socket, numberOfRows, cfg, c)
|
|
if err != nil {
|
|
if err != nil {
|
|
- klog.Infof("Error in querying or calculating average: %v", err.Error())
|
|
+ klog.Infof("Error in querying or calculating average for the custom score in the first stage: %v", err.Error())
|
|
return 0, nil
|
|
return 0, nil
|
|
}
|
|
}
|
|
res := calculateScore(scorerInput{metrics: results}, customScoreFn)
|
|
res := calculateScore(scorerInput{metrics: results}, customScoreFn)
|
|
|
|
|
|
|
|
+ if sum := average["c6res"] * float64(len(cores)); sum > 1 {
|
|
|
|
+ res = res * sum
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
klog.Infof("Node name %s, has score %v\n", nodeName, res)
|
|
klog.Infof("Node name %s, has score %v\n", nodeName, res)
|
|
@@ -150,4 +169,42 @@ func customResourceScorer(nodeName string) (float64, error) {
|
|
klog.Infof("Error finding the uuid: %v", ok)
|
|
klog.Infof("Error finding the uuid: %v", ok)
|
|
return 0, nil
|
|
return 0, nil
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|