2021-07-28 18:03:19 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div>
|
2022-12-16 23:14:00 +08:00
|
|
|
|
<el-dialog :title="title" v-model="dialogVisible" :show-close="true" width="1000px" @close="close()">
|
|
|
|
|
|
|
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
|
<el-col :lg="16" :md="16">
|
|
|
|
|
|
<el-descriptions class="redis-info info-server" title="Redis服务器信息" :column="3" size="small" border>
|
|
|
|
|
|
<el-descriptions-item label="版本">{{ info.Server.redis_version }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="端口">{{ info.Server.tcp_port }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="PID">{{ info.Server.process_id }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="模式">{{ info.Server.redis_mode }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="操作系统">{{ info.Server.os }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="运行天数">{{ info.Server.uptime_in_days }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="可执行文件路径">{{ info.Server.executable }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="配置文件路径">{{ info.Server.config_file }}</el-descriptions-item>
|
|
|
|
|
|
</el-descriptions>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :lg="8" :md="8" class="redis-info">
|
|
|
|
|
|
<div class="info-memory-chart" ref="memRef"></div>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
|
<el-col :lg="12" :md="12">
|
|
|
|
|
|
<el-descriptions class="redis-info info-cluster" title="节点信息" :column="3" size="small" border>
|
|
|
|
|
|
<el-descriptions-item label="是否启用集群模式">{{ info.Cluster.cluster_enabled }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="DB总数">{{ info.Cluster.databases }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="节点总数">{{ info.Cluster.nodecount }}</el-descriptions-item>
|
|
|
|
|
|
</el-descriptions>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
|
|
|
|
<el-col :lg="12" :md="12">
|
|
|
|
|
|
<el-descriptions class="redis-info info-client" title="客户端连接" :column="3" size="small" border>
|
|
|
|
|
|
<el-descriptions-item label="已连接客户端数">{{ info.Clients.connected_clients
|
|
|
|
|
|
}}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="正在等待阻塞命令客户端数">{{ info.Clients.blocked_clients
|
|
|
|
|
|
}}</el-descriptions-item>
|
|
|
|
|
|
</el-descriptions>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
|
|
|
|
<el-descriptions class="redis-info info-memory" title="CPU" :column="2" size="small" border>
|
|
|
|
|
|
<el-descriptions-item label="系统CPU">{{ info.CPU.used_cpu_sys }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="用户CPU">{{ info.CPU.used_cpu_user }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="后台系统CPU">{{ info.CPU.used_cpu_sys_children }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="后台用户CPU">{{ info.CPU.used_cpu_user_children }}</el-descriptions-item>
|
|
|
|
|
|
</el-descriptions>
|
|
|
|
|
|
|
|
|
|
|
|
<el-row :gutter="20" class="redis-info">
|
|
|
|
|
|
<el-col :lg="24" :md="24">
|
|
|
|
|
|
<span style="font-size: 14px; font-weight: 700">键值统计</span>
|
|
|
|
|
|
<el-table :data="Keyspace" stripe max-height="250" style="width: 100%" border>
|
|
|
|
|
|
<el-table-column prop="db" label="数据库" min-width="100" show-overflow-tooltip>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column prop="keys" label="keys" min-width="70" show-overflow-tooltip>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column prop="expires" label="expires" min-width="70" show-overflow-tooltip>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column prop="avg_ttl" label="avg_ttl" min-width="70" show-overflow-tooltip>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
|
|
|
|
<el-descriptions class="redis-info info-state" title="统计信息" :column="3" size="small" border>
|
|
|
|
|
|
<el-descriptions-item label="总处理命令数">{{ info.Stats.total_commands_processed }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="当前qps">{{ info.Stats.instantaneous_ops_per_sec }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="过期key的总数量">{{ info.Stats.expired_keys }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="网络入口流量字节数">{{ info.Stats.total_net_input_bytes }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="网络出口流量字节数">{{ info.Stats.total_net_output_bytes }}</el-descriptions-item>
|
|
|
|
|
|
</el-descriptions>
|
|
|
|
|
|
|
|
|
|
|
|
<el-descriptions class="redis-info info-persistence" title="持久化" :column="3" size="small" border>
|
|
|
|
|
|
<el-descriptions-item label="是否启用aof">{{ info.Persistence?.aof_enabled || false
|
|
|
|
|
|
}}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="是否正在载入持久化文件">{{ info.Persistence?.loading || false
|
|
|
|
|
|
}}</el-descriptions-item>
|
|
|
|
|
|
</el-descriptions>
|
2022-12-16 11:09:35 +08:00
|
|
|
|
|
2021-07-28 18:03:19 +08:00
|
|
|
|
</el-dialog>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
2022-10-29 20:08:15 +08:00
|
|
|
|
<script lang="ts" setup>
|
2022-12-16 23:14:00 +08:00
|
|
|
|
import { reactive, watch, toRefs, ref, nextTick } from 'vue';
|
|
|
|
|
|
import { formatByteSize } from '@/common/utils/format';
|
2022-12-16 11:09:35 +08:00
|
|
|
|
import useEcharts from '@/common/echarts/useEcharts';
|
|
|
|
|
|
import tdTheme from '@/common/echarts/theme.json';
|
2021-07-28 18:03:19 +08:00
|
|
|
|
|
2022-10-29 20:08:15 +08:00
|
|
|
|
const props = defineProps({
|
|
|
|
|
|
visible: {
|
|
|
|
|
|
type: Boolean,
|
2021-07-28 18:03:19 +08:00
|
|
|
|
},
|
2022-10-29 20:08:15 +08:00
|
|
|
|
title: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
},
|
|
|
|
|
|
info: {
|
|
|
|
|
|
type: [Boolean, Object],
|
|
|
|
|
|
},
|
|
|
|
|
|
})
|
2021-07-28 18:03:19 +08:00
|
|
|
|
|
2022-10-29 20:08:15 +08:00
|
|
|
|
const emit = defineEmits(['update:visible', 'close'])
|
2021-07-28 18:03:19 +08:00
|
|
|
|
|
2022-10-29 20:08:15 +08:00
|
|
|
|
const state = reactive({
|
|
|
|
|
|
dialogVisible: false,
|
2022-12-16 11:09:35 +08:00
|
|
|
|
memInfo: {} as any,
|
|
|
|
|
|
Keyspace: [] as any[],
|
2022-12-16 23:14:00 +08:00
|
|
|
|
|
2021-07-28 18:03:19 +08:00
|
|
|
|
});
|
2022-10-29 20:08:15 +08:00
|
|
|
|
|
2022-12-16 11:09:35 +08:00
|
|
|
|
let memChart: any = null;
|
|
|
|
|
|
let memRef = ref(null);
|
|
|
|
|
|
|
2022-10-29 20:08:15 +08:00
|
|
|
|
const {
|
|
|
|
|
|
dialogVisible,
|
2022-12-16 11:09:35 +08:00
|
|
|
|
Keyspace,
|
2022-10-29 20:08:15 +08:00
|
|
|
|
} = toRefs(state)
|
|
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
|
() => props.visible,
|
|
|
|
|
|
(val) => {
|
|
|
|
|
|
state.dialogVisible = val;
|
|
|
|
|
|
}
|
|
|
|
|
|
);
|
2022-12-16 11:09:35 +08:00
|
|
|
|
watch(
|
|
|
|
|
|
() => props.info,
|
|
|
|
|
|
(info: any) => {
|
|
|
|
|
|
state.memInfo = info['Memory'];
|
|
|
|
|
|
if (state.memInfo) {
|
2022-12-16 23:14:00 +08:00
|
|
|
|
initCharts();
|
2022-12-16 11:09:35 +08:00
|
|
|
|
}
|
2022-12-16 23:14:00 +08:00
|
|
|
|
if (info['Keyspace']) {
|
|
|
|
|
|
let arr = [];
|
|
|
|
|
|
for (let k in info['Keyspace']) {
|
|
|
|
|
|
let data = { db: k }
|
|
|
|
|
|
let d = info['Keyspace'][k].split(',')
|
|
|
|
|
|
for (let f of d) {
|
|
|
|
|
|
let v = f.split('=')
|
|
|
|
|
|
data[v[0]] = v[1]
|
|
|
|
|
|
}
|
|
|
|
|
|
arr.push(data)
|
2022-12-16 11:09:35 +08:00
|
|
|
|
}
|
2022-12-16 23:14:00 +08:00
|
|
|
|
state.Keyspace = arr
|
2022-12-16 11:09:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const initCharts = () => {
|
2022-12-16 23:14:00 +08:00
|
|
|
|
nextTick(() => {
|
|
|
|
|
|
initMemStats();
|
|
|
|
|
|
});
|
2022-12-16 11:09:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const initMemStats = () => {
|
2022-12-16 23:14:00 +08:00
|
|
|
|
let maxMem = state.memInfo.maxmemory === '0' ? state.memInfo.total_system_memory : state.memInfo.maxmemory
|
|
|
|
|
|
const data = [
|
|
|
|
|
|
{ name: '可用内存:', value: maxMem - state.memInfo.used_memory },
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '已用内存:',
|
|
|
|
|
|
value: state.memInfo.used_memory,
|
2022-12-16 11:09:35 +08:00
|
|
|
|
},
|
2022-12-16 23:14:00 +08:00
|
|
|
|
];
|
|
|
|
|
|
const option = {
|
|
|
|
|
|
title: {
|
|
|
|
|
|
text: '内存',
|
|
|
|
|
|
x: 'left',
|
|
|
|
|
|
textStyle: { fontSize: 14 },
|
2022-12-16 11:09:35 +08:00
|
|
|
|
},
|
2022-12-16 23:14:00 +08:00
|
|
|
|
tooltip: {
|
|
|
|
|
|
trigger: 'item',
|
|
|
|
|
|
valueFormatter: formatByteSize,
|
2022-12-16 11:09:35 +08:00
|
|
|
|
},
|
2022-12-16 23:14:00 +08:00
|
|
|
|
legend: {
|
|
|
|
|
|
top: '15%',
|
|
|
|
|
|
orient: 'vertical',
|
|
|
|
|
|
left: 'left',
|
|
|
|
|
|
textStyle: { fontSize: 12 },
|
|
|
|
|
|
},
|
|
|
|
|
|
series: [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '内存',
|
|
|
|
|
|
type: 'pie',
|
|
|
|
|
|
radius: ['30%', '60%'], // 饼图内圈和外圈大小
|
|
|
|
|
|
center: ['40%', '50%'], // 饼图位置,0: 左右;1: 上下
|
|
|
|
|
|
avoidLabelOverlap: false,
|
|
|
|
|
|
label: {
|
|
|
|
|
|
show: false,
|
|
|
|
|
|
position: 'center',
|
|
|
|
|
|
},
|
|
|
|
|
|
emphasis: {
|
|
|
|
|
|
label: {
|
|
|
|
|
|
fontSize: '15',
|
|
|
|
|
|
fontWeight: 'bold',
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
labelLine: {
|
|
|
|
|
|
show: false,
|
|
|
|
|
|
},
|
|
|
|
|
|
data: data,
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
};
|
|
|
|
|
|
if (memChart) {
|
|
|
|
|
|
memChart.setOption(option, true);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
memChart = useEcharts(memRef.value, tdTheme, option);
|
2022-12-16 11:09:35 +08:00
|
|
|
|
}
|
2022-10-29 20:08:15 +08:00
|
|
|
|
|
|
|
|
|
|
const close = () => {
|
|
|
|
|
|
emit('update:visible', false);
|
|
|
|
|
|
emit('close');
|
|
|
|
|
|
};
|
2021-07-28 18:03:19 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
2022-12-16 11:09:35 +08:00
|
|
|
|
<style lang="scss">
|
2022-12-16 23:14:00 +08:00
|
|
|
|
.redis-info {
|
|
|
|
|
|
margin-top: 12px;
|
2022-12-16 11:09:35 +08:00
|
|
|
|
|
2022-12-16 23:14:00 +08:00
|
|
|
|
.info-memory-chart {
|
|
|
|
|
|
width: 360px;
|
|
|
|
|
|
height: 150px;
|
|
|
|
|
|
}
|
2022-12-16 11:09:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-28 18:03:19 +08:00
|
|
|
|
.row .title {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: #8492a6;
|
|
|
|
|
|
margin-right: 6px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.row .value {
|
|
|
|
|
|
font-size: 12px;
|
2022-12-16 11:09:35 +08:00
|
|
|
|
color: var(--el-color-success);
|
2021-07-28 18:03:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
</style>
|