2020-10-17 14:12:00 +03:00
|
|
|
<template>
|
2021-09-29 18:50:45 +03:00
|
|
|
<div class="_debobigegoItem">
|
|
|
|
<div class="_debobigegoLabel"><i class="fas fa-microchip"></i> {{ $ts.cpuAndMemory }}</div>
|
|
|
|
<div class="_debobigegoPanel xhexznfu">
|
2021-04-22 16:29:33 +03:00
|
|
|
<div>
|
|
|
|
<canvas :ref="cpumem"></canvas>
|
|
|
|
</div>
|
|
|
|
<div v-if="serverInfo">
|
|
|
|
<div class="_table">
|
|
|
|
<div class="_row">
|
|
|
|
<div class="_cell"><div class="_label">MEM total</div>{{ bytes(serverInfo.mem.total) }}</div>
|
|
|
|
<div class="_cell"><div class="_label">MEM used</div>{{ bytes(memUsage) }} ({{ (memUsage / serverInfo.mem.total * 100).toFixed(0) }}%)</div>
|
|
|
|
<div class="_cell"><div class="_label">MEM free</div>{{ bytes(serverInfo.mem.total - memUsage) }} ({{ ((serverInfo.mem.total - memUsage) / serverInfo.mem.total * 100).toFixed(0) }}%)</div>
|
|
|
|
</div>
|
2020-10-17 14:12:00 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-04-22 16:29:33 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-09-29 18:50:45 +03:00
|
|
|
<div class="_debobigegoItem">
|
|
|
|
<div class="_debobigegoLabel"><i class="fas fa-hdd"></i> {{ $ts.disk }}</div>
|
|
|
|
<div class="_debobigegoPanel xhexznfu">
|
2021-04-22 16:29:33 +03:00
|
|
|
<div>
|
|
|
|
<canvas :ref="disk"></canvas>
|
|
|
|
</div>
|
|
|
|
<div v-if="serverInfo">
|
|
|
|
<div class="_table">
|
|
|
|
<div class="_row">
|
|
|
|
<div class="_cell"><div class="_label">Disk total</div>{{ bytes(serverInfo.fs.total) }}</div>
|
|
|
|
<div class="_cell"><div class="_label">Disk used</div>{{ bytes(serverInfo.fs.used) }} ({{ (serverInfo.fs.used / serverInfo.fs.total * 100).toFixed(0) }}%)</div>
|
|
|
|
<div class="_cell"><div class="_label">Disk free</div>{{ bytes(serverInfo.fs.total - serverInfo.fs.used) }} ({{ ((serverInfo.fs.total - serverInfo.fs.used) / serverInfo.fs.total * 100).toFixed(0) }}%)</div>
|
2020-10-17 14:12:00 +03:00
|
|
|
</div>
|
2021-04-22 16:29:33 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-09-29 18:50:45 +03:00
|
|
|
<div class="_debobigegoItem">
|
|
|
|
<div class="_debobigegoLabel"><i class="fas fa-exchange-alt"></i> {{ $ts.network }}</div>
|
|
|
|
<div class="_debobigegoPanel xhexznfu">
|
2021-04-22 16:29:33 +03:00
|
|
|
<div>
|
|
|
|
<canvas :ref="net"></canvas>
|
|
|
|
</div>
|
|
|
|
<div v-if="serverInfo">
|
|
|
|
<div class="_table">
|
|
|
|
<div class="_row">
|
|
|
|
<div class="_cell"><div class="_label">Interface</div>{{ serverInfo.net.interface }}</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-10-17 14:12:00 +03:00
|
|
|
</div>
|
2021-04-22 16:29:33 +03:00
|
|
|
</div>
|
2020-10-17 14:12:00 +03:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent, markRaw } from 'vue';
|
2021-10-21 23:36:48 +03:00
|
|
|
import {
|
|
|
|
Chart,
|
|
|
|
ArcElement,
|
|
|
|
LineElement,
|
|
|
|
BarElement,
|
|
|
|
PointElement,
|
|
|
|
BarController,
|
|
|
|
LineController,
|
|
|
|
CategoryScale,
|
|
|
|
LinearScale,
|
|
|
|
Legend,
|
|
|
|
Title,
|
|
|
|
Tooltip,
|
|
|
|
SubTitle
|
|
|
|
} from 'chart.js';
|
2021-11-11 19:02:25 +02:00
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import MkSelect from '@/components/form/select.vue';
|
|
|
|
import MkInput from '@/components/form/input.vue';
|
|
|
|
import MkContainer from '@/components/ui/container.vue';
|
|
|
|
import MkFolder from '@/components/ui/folder.vue';
|
2020-10-17 14:12:00 +03:00
|
|
|
import MkwFederation from '../../widgets/federation.vue';
|
2021-11-11 19:02:25 +02:00
|
|
|
import { version, url } from '@/config';
|
|
|
|
import bytes from '@/filters/bytes';
|
|
|
|
import number from '@/filters/number';
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2021-10-21 23:36:48 +03:00
|
|
|
Chart.register(
|
|
|
|
ArcElement,
|
|
|
|
LineElement,
|
|
|
|
BarElement,
|
|
|
|
PointElement,
|
|
|
|
BarController,
|
|
|
|
LineController,
|
|
|
|
CategoryScale,
|
|
|
|
LinearScale,
|
|
|
|
Legend,
|
|
|
|
Title,
|
|
|
|
Tooltip,
|
|
|
|
SubTitle
|
|
|
|
);
|
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
const alpha = (hex, a) => {
|
|
|
|
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)!;
|
|
|
|
const r = parseInt(result[1], 16);
|
|
|
|
const g = parseInt(result[2], 16);
|
|
|
|
const b = parseInt(result[3], 16);
|
|
|
|
return `rgba(${r}, ${g}, ${b}, ${a})`;
|
|
|
|
};
|
2021-11-11 19:02:25 +02:00
|
|
|
import * as os from '@/os';
|
2021-12-29 15:13:09 +02:00
|
|
|
import { stream } from '@/stream';
|
2020-10-17 14:12:00 +03:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
|
|
|
MkButton,
|
|
|
|
MkSelect,
|
|
|
|
MkInput,
|
|
|
|
MkContainer,
|
|
|
|
MkFolder,
|
|
|
|
MkwFederation,
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
version,
|
|
|
|
url,
|
|
|
|
stats: null,
|
|
|
|
serverInfo: null,
|
|
|
|
connection: null,
|
2021-12-29 15:13:09 +02:00
|
|
|
queueConnection: markRaw(stream.useChannel('queueStats')),
|
2020-10-17 14:12:00 +03:00
|
|
|
memUsage: 0,
|
|
|
|
chartCpuMem: null,
|
|
|
|
chartNet: null,
|
|
|
|
jobs: [],
|
|
|
|
logs: [],
|
|
|
|
logLevel: 'all',
|
|
|
|
logDomain: '',
|
|
|
|
modLogs: [],
|
|
|
|
dbInfo: null,
|
|
|
|
overviewHeight: '1fr',
|
|
|
|
queueHeight: '1fr',
|
|
|
|
paused: false,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
gridColor() {
|
|
|
|
// TODO: var(--panel)の色が暗いか明るいかで判定する
|
2020-12-19 03:55:52 +02:00
|
|
|
return this.$store.state.darkMode ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.1)';
|
2020-10-17 14:12:00 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.fetchJobs();
|
|
|
|
|
2021-10-21 23:36:48 +03:00
|
|
|
Chart.defaults.color = getComputedStyle(document.documentElement).getPropertyValue('--fg');
|
2020-10-17 14:12:00 +03:00
|
|
|
|
|
|
|
os.api('admin/server-info', {}).then(res => {
|
|
|
|
this.serverInfo = res;
|
|
|
|
|
2021-12-29 15:13:09 +02:00
|
|
|
this.connection = markRaw(stream.useChannel('serverStats'));
|
2020-10-17 14:12:00 +03:00
|
|
|
this.connection.on('stats', this.onStats);
|
|
|
|
this.connection.on('statsLog', this.onStatsLog);
|
|
|
|
this.connection.send('requestLog', {
|
|
|
|
id: Math.random().toString().substr(2, 8),
|
|
|
|
length: 150
|
|
|
|
});
|
|
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.queueConnection.send('requestLog', {
|
|
|
|
id: Math.random().toString().substr(2, 8),
|
|
|
|
length: 200
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
beforeUnmount() {
|
2021-04-22 16:29:33 +03:00
|
|
|
if (this.connection) {
|
|
|
|
this.connection.off('stats', this.onStats);
|
|
|
|
this.connection.off('statsLog', this.onStatsLog);
|
|
|
|
this.connection.dispose();
|
|
|
|
}
|
2020-10-17 14:12:00 +03:00
|
|
|
this.queueConnection.dispose();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
cpumem(el) {
|
|
|
|
if (this.chartCpuMem != null) return;
|
|
|
|
this.chartCpuMem = markRaw(new Chart(el, {
|
|
|
|
type: 'line',
|
|
|
|
data: {
|
|
|
|
labels: [],
|
|
|
|
datasets: [{
|
|
|
|
label: 'CPU',
|
|
|
|
pointRadius: 0,
|
2021-10-21 23:36:48 +03:00
|
|
|
tension: 0,
|
2020-10-17 14:12:00 +03:00
|
|
|
borderWidth: 2,
|
|
|
|
borderColor: '#86b300',
|
|
|
|
backgroundColor: alpha('#86b300', 0.1),
|
|
|
|
data: []
|
|
|
|
}, {
|
|
|
|
label: 'MEM (active)',
|
|
|
|
pointRadius: 0,
|
2021-10-21 23:36:48 +03:00
|
|
|
tension: 0,
|
2020-10-17 14:12:00 +03:00
|
|
|
borderWidth: 2,
|
|
|
|
borderColor: '#935dbf',
|
|
|
|
backgroundColor: alpha('#935dbf', 0.02),
|
|
|
|
data: []
|
|
|
|
}, {
|
|
|
|
label: 'MEM (used)',
|
|
|
|
pointRadius: 0,
|
2021-10-21 23:36:48 +03:00
|
|
|
tension: 0,
|
2020-10-17 14:12:00 +03:00
|
|
|
borderWidth: 2,
|
|
|
|
borderColor: '#935dbf',
|
|
|
|
borderDash: [5, 5],
|
|
|
|
fill: false,
|
|
|
|
data: []
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
options: {
|
|
|
|
aspectRatio: 3,
|
|
|
|
layout: {
|
|
|
|
padding: {
|
2021-04-22 16:29:33 +03:00
|
|
|
left: 16,
|
|
|
|
right: 16,
|
|
|
|
top: 16,
|
2020-10-17 14:12:00 +03:00
|
|
|
bottom: 0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
legend: {
|
|
|
|
position: 'bottom',
|
|
|
|
labels: {
|
|
|
|
boxWidth: 16,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
scales: {
|
2021-10-21 23:36:48 +03:00
|
|
|
x: {
|
2020-10-17 14:12:00 +03:00
|
|
|
gridLines: {
|
|
|
|
display: false,
|
|
|
|
color: this.gridColor,
|
|
|
|
zeroLineColor: this.gridColor,
|
|
|
|
},
|
|
|
|
ticks: {
|
|
|
|
display: false,
|
|
|
|
}
|
2021-10-21 23:36:48 +03:00
|
|
|
},
|
|
|
|
y: {
|
2020-10-17 14:12:00 +03:00
|
|
|
position: 'right',
|
|
|
|
gridLines: {
|
|
|
|
display: true,
|
|
|
|
color: this.gridColor,
|
|
|
|
zeroLineColor: this.gridColor,
|
|
|
|
},
|
|
|
|
ticks: {
|
|
|
|
display: false,
|
|
|
|
max: 100
|
|
|
|
}
|
2021-10-21 23:36:48 +03:00
|
|
|
}
|
2020-10-17 14:12:00 +03:00
|
|
|
},
|
|
|
|
tooltips: {
|
|
|
|
intersect: false,
|
|
|
|
mode: 'index',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
|
|
|
net(el) {
|
|
|
|
if (this.chartNet != null) return;
|
|
|
|
this.chartNet = markRaw(new Chart(el, {
|
|
|
|
type: 'line',
|
|
|
|
data: {
|
|
|
|
labels: [],
|
|
|
|
datasets: [{
|
|
|
|
label: 'In',
|
|
|
|
pointRadius: 0,
|
2021-10-21 23:36:48 +03:00
|
|
|
tension: 0,
|
2020-10-17 14:12:00 +03:00
|
|
|
borderWidth: 2,
|
|
|
|
borderColor: '#94a029',
|
|
|
|
backgroundColor: alpha('#94a029', 0.1),
|
|
|
|
data: []
|
|
|
|
}, {
|
|
|
|
label: 'Out',
|
|
|
|
pointRadius: 0,
|
2021-10-21 23:36:48 +03:00
|
|
|
tension: 0,
|
2020-10-17 14:12:00 +03:00
|
|
|
borderWidth: 2,
|
|
|
|
borderColor: '#ff9156',
|
|
|
|
backgroundColor: alpha('#ff9156', 0.1),
|
|
|
|
data: []
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
options: {
|
|
|
|
aspectRatio: 3,
|
|
|
|
layout: {
|
|
|
|
padding: {
|
2021-04-22 16:29:33 +03:00
|
|
|
left: 16,
|
|
|
|
right: 16,
|
|
|
|
top: 16,
|
2020-10-17 14:12:00 +03:00
|
|
|
bottom: 0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
legend: {
|
|
|
|
position: 'bottom',
|
|
|
|
labels: {
|
|
|
|
boxWidth: 16,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
scales: {
|
2021-10-21 23:36:48 +03:00
|
|
|
x: {
|
2020-10-17 14:12:00 +03:00
|
|
|
gridLines: {
|
|
|
|
display: false,
|
|
|
|
color: this.gridColor,
|
|
|
|
zeroLineColor: this.gridColor,
|
|
|
|
},
|
|
|
|
ticks: {
|
|
|
|
display: false
|
|
|
|
}
|
2021-10-21 23:36:48 +03:00
|
|
|
},
|
|
|
|
y: {
|
2020-10-17 14:12:00 +03:00
|
|
|
position: 'right',
|
|
|
|
gridLines: {
|
|
|
|
display: true,
|
|
|
|
color: this.gridColor,
|
|
|
|
zeroLineColor: this.gridColor,
|
|
|
|
},
|
|
|
|
ticks: {
|
|
|
|
display: false,
|
|
|
|
}
|
2021-10-21 23:36:48 +03:00
|
|
|
}
|
2020-10-17 14:12:00 +03:00
|
|
|
},
|
|
|
|
tooltips: {
|
|
|
|
intersect: false,
|
|
|
|
mode: 'index',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
|
|
|
disk(el) {
|
|
|
|
if (this.chartDisk != null) return;
|
|
|
|
this.chartDisk = markRaw(new Chart(el, {
|
|
|
|
type: 'line',
|
|
|
|
data: {
|
|
|
|
labels: [],
|
|
|
|
datasets: [{
|
|
|
|
label: 'Read',
|
|
|
|
pointRadius: 0,
|
2021-10-21 23:36:48 +03:00
|
|
|
tension: 0,
|
2020-10-17 14:12:00 +03:00
|
|
|
borderWidth: 2,
|
|
|
|
borderColor: '#94a029',
|
|
|
|
backgroundColor: alpha('#94a029', 0.1),
|
|
|
|
data: []
|
|
|
|
}, {
|
|
|
|
label: 'Write',
|
|
|
|
pointRadius: 0,
|
2021-10-21 23:36:48 +03:00
|
|
|
tension: 0,
|
2020-10-17 14:12:00 +03:00
|
|
|
borderWidth: 2,
|
|
|
|
borderColor: '#ff9156',
|
|
|
|
backgroundColor: alpha('#ff9156', 0.1),
|
|
|
|
data: []
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
options: {
|
|
|
|
aspectRatio: 3,
|
|
|
|
layout: {
|
|
|
|
padding: {
|
2021-04-22 16:29:33 +03:00
|
|
|
left: 16,
|
|
|
|
right: 16,
|
|
|
|
top: 16,
|
2020-10-17 14:12:00 +03:00
|
|
|
bottom: 0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
legend: {
|
|
|
|
position: 'bottom',
|
|
|
|
labels: {
|
|
|
|
boxWidth: 16,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
scales: {
|
2021-10-21 23:36:48 +03:00
|
|
|
x: {
|
2020-10-17 14:12:00 +03:00
|
|
|
gridLines: {
|
|
|
|
display: false,
|
|
|
|
color: this.gridColor,
|
|
|
|
zeroLineColor: this.gridColor,
|
|
|
|
},
|
|
|
|
ticks: {
|
|
|
|
display: false
|
|
|
|
}
|
2021-10-21 23:36:48 +03:00
|
|
|
},
|
|
|
|
y: {
|
2020-10-17 14:12:00 +03:00
|
|
|
position: 'right',
|
|
|
|
gridLines: {
|
|
|
|
display: true,
|
|
|
|
color: this.gridColor,
|
|
|
|
zeroLineColor: this.gridColor,
|
|
|
|
},
|
|
|
|
ticks: {
|
|
|
|
display: false,
|
|
|
|
}
|
2021-10-21 23:36:48 +03:00
|
|
|
}
|
2020-10-17 14:12:00 +03:00
|
|
|
},
|
|
|
|
tooltips: {
|
|
|
|
intersect: false,
|
|
|
|
mode: 'index',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
|
|
|
fetchJobs() {
|
|
|
|
os.api('admin/queue/deliver-delayed', {}).then(jobs => {
|
|
|
|
this.jobs = jobs;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
onStats(stats) {
|
|
|
|
if (this.paused) return;
|
|
|
|
|
|
|
|
const cpu = (stats.cpu * 100).toFixed(0);
|
|
|
|
const memActive = (stats.mem.active / this.serverInfo.mem.total * 100).toFixed(0);
|
|
|
|
const memUsed = (stats.mem.used / this.serverInfo.mem.total * 100).toFixed(0);
|
|
|
|
this.memUsage = stats.mem.active;
|
|
|
|
|
|
|
|
this.chartCpuMem.data.labels.push('');
|
|
|
|
this.chartCpuMem.data.datasets[0].data.push(cpu);
|
|
|
|
this.chartCpuMem.data.datasets[1].data.push(memActive);
|
|
|
|
this.chartCpuMem.data.datasets[2].data.push(memUsed);
|
|
|
|
this.chartNet.data.labels.push('');
|
|
|
|
this.chartNet.data.datasets[0].data.push(stats.net.rx);
|
|
|
|
this.chartNet.data.datasets[1].data.push(stats.net.tx);
|
|
|
|
this.chartDisk.data.labels.push('');
|
|
|
|
this.chartDisk.data.datasets[0].data.push(stats.fs.r);
|
|
|
|
this.chartDisk.data.datasets[1].data.push(stats.fs.w);
|
|
|
|
if (this.chartCpuMem.data.datasets[0].data.length > 150) {
|
|
|
|
this.chartCpuMem.data.labels.shift();
|
|
|
|
this.chartCpuMem.data.datasets[0].data.shift();
|
|
|
|
this.chartCpuMem.data.datasets[1].data.shift();
|
|
|
|
this.chartCpuMem.data.datasets[2].data.shift();
|
|
|
|
this.chartNet.data.labels.shift();
|
|
|
|
this.chartNet.data.datasets[0].data.shift();
|
|
|
|
this.chartNet.data.datasets[1].data.shift();
|
|
|
|
this.chartDisk.data.labels.shift();
|
|
|
|
this.chartDisk.data.datasets[0].data.shift();
|
|
|
|
this.chartDisk.data.datasets[1].data.shift();
|
|
|
|
}
|
|
|
|
this.chartCpuMem.update();
|
|
|
|
this.chartNet.update();
|
|
|
|
this.chartDisk.update();
|
|
|
|
},
|
|
|
|
|
|
|
|
onStatsLog(statsLog) {
|
|
|
|
for (const stats of [...statsLog].reverse()) {
|
|
|
|
this.onStats(stats);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
bytes,
|
|
|
|
|
|
|
|
number,
|
|
|
|
|
|
|
|
pause() {
|
|
|
|
this.paused = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
resume() {
|
|
|
|
this.paused = false;
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.xhexznfu {
|
2021-04-22 16:29:33 +03:00
|
|
|
> div:nth-child(2) {
|
|
|
|
padding: 16px;
|
|
|
|
border-top: solid 0.5px var(--divider);
|
2020-10-17 14:12:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|