Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
chartData: self.getAmchartConfig('网络流出(KB/s)', formartFlowArr(monitorItem, currentCounterData, 'KB'), 'KB/s'),
tableData: tableData
};
}
});
}
// 主机/容器/实例: 内存使用率数据
if (monitorResult.counterResults['mem.memused.percent'] || monitorResult.counterResults['container.mem.usage.percent']) {
tableData = {
head: [],
item: [],
body: []
};
var usedPercetData, usedTotalData, usedData;
if (monitorResult.counterResults['mem.memused.percent']) {
usedPercetData = monitorResult.counterResults['mem.memused.percent'];
usedTotalData = monitorResult.counterResults['mem.memtotal'];
usedData = monitorResult.counterResults['mem.memused'];
} else {
usedPercetData = monitorResult.counterResults['container.mem.usage.percent'];
usedTotalData = monitorResult.counterResults['container.mem.limit'];
usedData = monitorResult.counterResults['container.mem.usage'];
}
if (singleItemName !== undefined) {
if (monitorResult.counterResults['mem.memused.percent']) {
tableData.head = [tableKeyName, '内存占用量(MB)', '内存总量(MB)', '内存占用率'];
} else {
tableData.head = [tableKeyName, '内存占用量(MB)', '内存限额(MB)', '内存占用率'];
}
tableData.item = ['key', 'memused', 'memtotal', 'mempercent'];
tableData: tableData
};
}
});
}
// 主机/容器/实例: 内存使用率数据
if (monitorResult.counterResults['mem.memused.percent'] || monitorResult.counterResults['container.mem.usage.percent']) {
tableData = {
head: [],
item: [],
body: []
};
var usedPercetData, usedTotalData, usedData;
if (monitorResult.counterResults['mem.memused.percent']) {
usedPercetData = monitorResult.counterResults['mem.memused.percent'];
usedTotalData = monitorResult.counterResults['mem.memtotal'];
usedData = monitorResult.counterResults['mem.memused'];
} else {
usedPercetData = monitorResult.counterResults['container.mem.usage.percent'];
usedTotalData = monitorResult.counterResults['container.mem.limit'];
usedData = monitorResult.counterResults['container.mem.usage'];
}
if (singleItemName !== undefined) {
if (monitorResult.counterResults['mem.memused.percent']) {
tableData.head = [tableKeyName, '内存占用量(MB)', '内存总量(MB)', '内存占用率'];
} else {
tableData.head = [tableKeyName, '内存占用量(MB)', '内存限额(MB)', '内存占用率'];
}
tableData.item = ['key', 'memused', 'memtotal', 'mempercent'];
_monitorCountResult.netIn = {
chartData: self.getAmchartConfig('网络流入(KB/s)', formartFlowArr(monitorItem, currentCounterData, 'KB'), 'KB/s'),
tableData: tableData
};
} else {
_monitorCountResult.netOut = {
chartData: self.getAmchartConfig('网络流出(KB/s)', formartFlowArr(monitorItem, currentCounterData, 'KB'), 'KB/s'),
tableData: tableData
};
}
});
}
// 主机/容器/实例: 内存使用率数据
if (monitorResult.counterResults['mem.memused.percent'] || monitorResult.counterResults['container.mem.usage.percent']) {
tableData = {
head: [],
item: [],
body: []
};
var usedPercetData, usedTotalData, usedData;
if (monitorResult.counterResults['mem.memused.percent']) {
usedPercetData = monitorResult.counterResults['mem.memused.percent'];
usedTotalData = monitorResult.counterResults['mem.memtotal'];
usedData = monitorResult.counterResults['mem.memused'];
} else {
usedPercetData = monitorResult.counterResults['container.mem.usage.percent'];
usedTotalData = monitorResult.counterResults['container.mem.limit'];
usedData = monitorResult.counterResults['container.mem.usage'];
}
}
});
if (unit !== undefined) {
angular.forEach(monitorItemData, function(data) {
if (unit == '%') {
data[countName] = toDecimal(data[countName], 2);
} else {
data[countName] = formartBytesData(data[countName], unit);
}
});
}
}
if (monitorType == 'node') {
cpuBusy = monitorData.counterResults['cpu.busy'].slice(-3, -2)[0];
memPercet = monitorData.counterResults['mem.memused.percent'].slice(-3, -2)[0];
collectMonitorInfo = {
diskUsedMap: {},
diskReadMap: {},
diskWriteMap: {},
netInMap: {},
netOutMap: {}
};
for (i = 0; i < monitorItems.length; i++) {
monitorItemData[monitorItems[i]] = {
diskUsedData: [],
diskUsedCount: 0,
diskReadData: [],
diskReadCount: 0,
diskWriteData: [],
diskWriteCount: 0,
}
});
if (typeof unit !== 'undefined') {
angular.forEach(monitorItemData, function (data) {
if (unit == '%') {
data[countName] = toDecimal(data[countName], 2);
} else {
data[countName] = formartBytesData(data[countName], unit);
}
});
}
}
if (monitorType == 'node') {
cpuBusy = monitorData.counterResults['cpu.busy'].slice(-3, -2)[0];
memPercet = monitorData.counterResults['mem.memused.percent'].slice(-3, -2)[0];
collectMonitorInfo = {
diskUsedMap: {},
diskReadMap: {},
diskWriteMap: {},
netInMap: {},
netOutMap: {}
};
for (i = 0, l = monitorItems.length; i < l; i++) {
monitorItemData[monitorItems[i]] = {
diskUsedData: [],
diskUsedCount: 0,
diskReadData: [],
diskReadCount: 0,
diskWriteData: [],
diskWriteCount: 0,
item: [],
body: []
};
var usedPercetData, usedTotalData, usedData;
if (monitorResult.counterResults['mem.memused.percent']) {
usedPercetData = monitorResult.counterResults['mem.memused.percent'];
usedTotalData = monitorResult.counterResults['mem.memtotal'];
usedData = monitorResult.counterResults['mem.memused'];
} else {
usedPercetData = monitorResult.counterResults['container.mem.usage.percent'];
usedTotalData = monitorResult.counterResults['container.mem.limit'];
usedData = monitorResult.counterResults['container.mem.usage'];
}
if (singleItemName !== undefined) {
if (monitorResult.counterResults['mem.memused.percent']) {
tableData.head = [tableKeyName, '内存占用量(MB)', '内存总量(MB)', '内存占用率'];
} else {
tableData.head = [tableKeyName, '内存占用量(MB)', '内存限额(MB)', '内存占用率'];
}
tableData.item = ['key', 'memused', 'memtotal', 'mempercent'];
if (isShowCountTable) {
counterCountResults = {
memused: getCounterCountResult(usedData, 'MB', singleItemName),
memtotal: getCounterCountResult(usedTotalData, 'MB', singleItemName),
mempercent: getCounterCountResult(usedPercetData, '%', singleItemName)
};
tableData.body = getCounterCountTable(tableData.item, counterCountResults);
} else {
startIndex = getHasDataLastIndex(usedPercetData, singleItemName);
if (startIndex !== -1) {