From cc015bad61a64ff2ee3e8d6349d159163b1f74d9 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Fri, 10 May 2024 14:35:51 +0800 Subject: [PATCH] update --- route/static/app/index.js | 51 ++++++++++++++++++++++++++++---------- route/static/app/public.js | 11 ++++++++ 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/route/static/app/index.js b/route/static/app/index.js index c5ea45107..6bd11f50e 100755 --- a/route/static/app/index.js +++ b/route/static/app/index.js @@ -1171,15 +1171,18 @@ var index = { data: { xData: [], yData: [], - zData: [] + zData: [], + tipsData: [] }, init_select:false, + default_unit : 'MB/s', init:function(){ for (var i = 8; i >= 0; i--) { var time = (new Date()).getTime(); index.iostat.data.xData.push(index.common.format(time - (i * 3 * 1000))); index.iostat.data.yData.push(0); index.iostat.data.zData.push(0); + index.iostat.data.tipsData.push({}); } index.iostat.table = echarts.init(document.getElementById('ioStat')); @@ -1195,7 +1198,31 @@ var index = { index.iostat.table.setOption({ tooltip: { trigger: 'axis', - // formatter :function (config) {} + formatter :function (config) { + var _config = config, _tips = "时间:" + _config[0].axisValue + "
", options = { + read_bytes: '读取字节数', + read_count: '读取次数 ', + read_merged_count: '合并读取次数', + read_time: '读取延迟', + write_bytes: '写入字节数', + write_count: '写入次数', + write_merged_count: '合并写入次数', + write_time: '写入延迟', + }, data = index.iostat.data.tipsData[config[0].dataIndex], list = ['read_count', 'write_count', 'read_merged_count', 'write_merged_count', 'read_time', 'write_time',]; + for (var i = 0; i < config.length; i++) { + if (typeof config[i].data == "undefined") { + return false; + } + _tips += '  ' + config[i].seriesName + ':' + config[i].data + ' MB/s' + '
' + } + $.each(list, function (index, item) { + + if (typeof data[item] != 'undefined'){ + _tips += '  ' + options[item] + ':' + data[item] + (item.indexOf('time') > -1 ? ' ms' : ' 次/秒') + '
'; + } + }) + return _tips; + } }, yAxis: { name: '单位 '+ index.iostat.default_unit, @@ -1322,26 +1349,24 @@ var index = { index.iostat.init_select = true; } }, - add: function (up, down) { + add: function (read, write, data) { var _iostat = this; var limit = 8; var d = new Date() if (_iostat.data.xData.length >= limit) _iostat.data.xData.splice(0, 1); if (_iostat.data.yData.length >= limit) _iostat.data.yData.splice(0, 1); if (_iostat.data.zData.length >= limit) _iostat.data.zData.splice(0, 1); + if (_iostat.data.tipsData.length >= limit) _iostat.data.tipsData.splice(0, 1); - var upTmpSize = toSize(up).split(' ')[0]; - var downTmpSize = toSize(down).split(' ')[0]; + var readTmpSize = toSizeMB(read).split(' ')[0]; + var writeTmpSize = toSizeMB(write).split(' ')[0]; - var tmp = up; - if (down>up){ - tmp = down; - } - index.iostat.default_unit = toSize(tmp).split(' ')[1] + '/s'; + // console.log(readTmpSize,writeTmpSize); - _iostat.data.zData.push(downTmpSize); - _iostat.data.yData.push(upTmpSize); + _iostat.data.zData.push(writeTmpSize); + _iostat.data.yData.push(readTmpSize); + _iostat.data.tipsData.push(data); _iostat.data.xData.push(d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds()); }, @@ -1379,7 +1404,7 @@ var index = { iostat_select = iostat_data[disk_io_key]; } - index.iostat.add(iostat_select.read_bytes,iostat_select.write_bytes); + index.iostat.add(iostat_select.read_bytes,iostat_select.write_bytes, iostat_select); index.iostat.render(); index.iostat.renderSelect(net); diff --git a/route/static/app/public.js b/route/static/app/public.js index 421eff99e..5b3e886a1 100755 --- a/route/static/app/public.js +++ b/route/static/app/public.js @@ -16,6 +16,17 @@ function toSize(a) { } } +function toSizeMB(a) { + var d = [" KB", " MB"]; + var e = 1024; + var i = 0; + for(var b = 0; b < d.length; b++) { + a /= e; + i = b; + } + return a.toFixed(2) + d[i] +} + function toTrim(x) { return x.replace(/^\s+|\s+$/gm,''); }