mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-10-05 22:04:31 +02:00
Merge branch 'hotfix' into add_detailed_nodelist
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
} from "@urql/svelte";
|
||||
import { setContext, getContext, hasContext, onDestroy, tick } from "svelte";
|
||||
import { readable } from "svelte/store";
|
||||
import { round } from "mathjs";
|
||||
|
||||
/*
|
||||
* Call this function only at component initialization time!
|
||||
@@ -318,23 +319,34 @@ export function checkMetricsDisabled(ma, c, s) { // [m]etric[a]rray, [c]luster,
|
||||
return result
|
||||
}
|
||||
|
||||
export function getStatsItems() {
|
||||
export function getStatsItems(presetStats = []) {
|
||||
// console.time('stats')
|
||||
const globalMetrics = getContext("globalMetrics")
|
||||
const result = globalMetrics.map((gm) => {
|
||||
if (gm?.footprint) {
|
||||
// console.time('deep')
|
||||
const mc = getMetricConfigDeep(gm.name, null, null)
|
||||
// console.timeEnd('deep')
|
||||
if (mc) {
|
||||
return {
|
||||
field: gm.name + '_' + gm.footprint,
|
||||
text: gm.name + ' (' + gm.footprint + ')',
|
||||
metric: gm.name,
|
||||
from: 0,
|
||||
to: mc.peak,
|
||||
peak: mc.peak,
|
||||
enabled: false
|
||||
const presetEntry = presetStats.find((s) => s?.field === (gm.name + '_' + gm.footprint))
|
||||
if (presetEntry) {
|
||||
return {
|
||||
field: gm.name + '_' + gm.footprint,
|
||||
text: gm.name + ' (' + gm.footprint + ')',
|
||||
metric: gm.name,
|
||||
from: presetEntry.from,
|
||||
to: presetEntry.to,
|
||||
peak: mc.peak,
|
||||
enabled: true
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
field: gm.name + '_' + gm.footprint,
|
||||
text: gm.name + ' (' + gm.footprint + ')',
|
||||
metric: gm.name,
|
||||
from: 0,
|
||||
to: mc.peak,
|
||||
peak: mc.peak,
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -344,6 +356,38 @@ export function getStatsItems() {
|
||||
return [...result];
|
||||
};
|
||||
|
||||
export function findJobFootprintThresholds(job, stat, metricConfig) {
|
||||
if (!job || !metricConfig || !stat) {
|
||||
console.warn("Argument missing for findJobThresholds!");
|
||||
return null;
|
||||
}
|
||||
// metricConfig is on subCluster-Level
|
||||
const defaultThresholds = {
|
||||
peak: metricConfig.peak,
|
||||
normal: metricConfig.normal,
|
||||
caution: metricConfig.caution,
|
||||
alert: metricConfig.alert
|
||||
};
|
||||
/*
|
||||
Footprints should be comparable:
|
||||
Always use unchanged single node thresholds for exclusive jobs and "avg" Footprints.
|
||||
For shared jobs, scale thresholds by the fraction of the job's HWThreads to the node's HWThreads.
|
||||
'stat' is one of: avg, min, max
|
||||
*/
|
||||
if (job.exclusive === 1 || stat === "avg") {
|
||||
return defaultThresholds
|
||||
} else {
|
||||
const topol = getContext("getHardwareTopology")(job.cluster, job.subCluster)
|
||||
const jobFraction = job.numHWThreads / topol.node.length;
|
||||
return {
|
||||
peak: round(defaultThresholds.peak * jobFraction, 0),
|
||||
normal: round(defaultThresholds.normal * jobFraction, 0),
|
||||
caution: round(defaultThresholds.caution * jobFraction, 0),
|
||||
alert: round(defaultThresholds.alert * jobFraction, 0),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function getSortItems() {
|
||||
//console.time('sort')
|
||||
const globalMetrics = getContext("globalMetrics")
|
||||
|
Reference in New Issue
Block a user