添加95计费出入去大带宽
This commit is contained in:
1961
server/index.js
1961
server/index.js
File diff suppressed because it is too large
Load Diff
@@ -626,7 +626,7 @@ async function getServerDetails(baseUrl, instance, job) {
|
||||
/**
|
||||
* Get historical metrics for a specific server (node)
|
||||
*/
|
||||
async function getServerHistory(baseUrl, instance, job, metric, range = '1h', start = null, end = null) {
|
||||
async function getServerHistory(baseUrl, instance, job, metric, range = '1h', start = null, end = null, p95Type = 'tx') {
|
||||
const url = normalizeUrl(baseUrl);
|
||||
const node = resolveToken(instance);
|
||||
|
||||
@@ -681,9 +681,22 @@ async function getServerHistory(baseUrl, instance, job, metric, range = '1h', st
|
||||
txTotal += (tx[i] || 0) * duration;
|
||||
}
|
||||
|
||||
const sortedTx = [...tx].sort((a, b) => a - b);
|
||||
const p95Idx = Math.floor(sortedTx.length * 0.95);
|
||||
const p95 = sortedTx.length > 0 ? sortedTx[p95Idx] : 0;
|
||||
// Calculate P95 based on p95Type
|
||||
let combined = [];
|
||||
if (p95Type === 'rx') {
|
||||
combined = [...rx];
|
||||
} else if (p95Type === 'both') {
|
||||
combined = tx.map((t, i) => (t || 0) + (rx[i] || 0));
|
||||
} else if (p95Type === 'max') {
|
||||
combined = tx.map((t, i) => Math.max(t || 0, rx[i] || 0));
|
||||
} else {
|
||||
// Default to tx
|
||||
combined = [...tx];
|
||||
}
|
||||
|
||||
const sorted = combined.sort((a, b) => a - b);
|
||||
const p95Idx = Math.floor(sorted.length * 0.95);
|
||||
const p95 = sorted.length > 0 ? sorted[p95Idx] : 0;
|
||||
|
||||
return {
|
||||
timestamps,
|
||||
|
||||
Reference in New Issue
Block a user