mirror of https://github.com/halo-dev/halo-admin
refactor: runtime logs page.
parent
9856b27a1a
commit
1bed506ff7
|
@ -18,4 +18,67 @@ actuatorApi.env = () => {
|
|||
})
|
||||
}
|
||||
|
||||
actuatorApi.getSystemCpuCount = () => {
|
||||
return service({
|
||||
url: `${baseUrl}/metrics/system.cpu.count`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
actuatorApi.getSystemCpuUsage = () => {
|
||||
return service({
|
||||
url: `${baseUrl}/metrics/system.cpu.usage`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
actuatorApi.getProcessUptime = () => {
|
||||
return service({
|
||||
url: `${baseUrl}/metrics/process.uptime`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
actuatorApi.getProcessStartTime = () => {
|
||||
return service({
|
||||
url: `${baseUrl}/metrics/process.start.time`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
actuatorApi.getProcessCpuUsage = () => {
|
||||
return service({
|
||||
url: `${baseUrl}/metrics/process.cpu.usage`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
actuatorApi.getJvmMemoryMax = () => {
|
||||
return service({
|
||||
url: `${baseUrl}/metrics/jvm.memory.max`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
actuatorApi.getJvmMemoryCommitted = () => {
|
||||
return service({
|
||||
url: `${baseUrl}/metrics/jvm.memory.committed`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
actuatorApi.getJvmMemoryUsed = () => {
|
||||
return service({
|
||||
url: `${baseUrl}/metrics/jvm.memory.used`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
actuatorApi.getJvmGcPause = () => {
|
||||
return service({
|
||||
url: `${baseUrl}/metrics/jvm.gc.pause`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export default actuatorApi
|
||||
|
|
|
@ -106,4 +106,14 @@ adminApi.restartApplication = () => {
|
|||
})
|
||||
}
|
||||
|
||||
adminApi.getLogFiles = lines => {
|
||||
return service({
|
||||
url: `${baseUrl}/halo/logfile`,
|
||||
params: {
|
||||
lines: lines
|
||||
},
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export default adminApi
|
||||
|
|
|
@ -21,7 +21,15 @@
|
|||
label="网站地址:"
|
||||
help="* 需要加上 http://"
|
||||
>
|
||||
<a-input v-model="link.url" />
|
||||
<a-input v-model="link.url">
|
||||
<a
|
||||
href="javascript:void(0);"
|
||||
slot="addonAfter"
|
||||
@click="handleParseUrl"
|
||||
>
|
||||
<a-icon type="sync" />
|
||||
</a>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
<a-form-item label="Logo:">
|
||||
<a-input v-model="link.logo" />
|
||||
|
@ -276,6 +284,11 @@ export default {
|
|||
this.loadTeams()
|
||||
})
|
||||
},
|
||||
handleParseUrl() {
|
||||
linkApi.getByParse(this.link.url).then(response => {
|
||||
this.link = response.data.data
|
||||
})
|
||||
},
|
||||
createOrUpdateLink() {
|
||||
if (!this.link.name) {
|
||||
this.$notification['error']({
|
||||
|
|
|
@ -19,27 +19,27 @@
|
|||
<tbody class="ant-table-tbody">
|
||||
<tr>
|
||||
<td>系统</td>
|
||||
<td>{{ systemProperties.properties['os.name'].value }} {{ systemProperties.properties['os.version'].value }}</td>
|
||||
<td>{{ systemProperties['os.name'].value }} {{ systemProperties['os.version'].value }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>平台</td>
|
||||
<td>{{ systemProperties.properties['os.arch'].value }}</td>
|
||||
<td>{{ systemProperties['os.arch'].value }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>语言</td>
|
||||
<td>{{ systemProperties.properties['user.language'].value }}</td>
|
||||
<td>{{ systemProperties['user.language'].value }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>时区</td>
|
||||
<td>{{ systemProperties.properties['user.timezone'].value }}</td>
|
||||
<td>{{ systemProperties['user.timezone'].value }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>当前用户</td>
|
||||
<td>{{ systemProperties.properties['user.name'].value }}</td>
|
||||
<td>{{ systemProperties['user.name'].value }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>用户目录</td>
|
||||
<td>{{ systemProperties.properties['user.home'].value }}</td>
|
||||
<td>{{ systemProperties['user.home'].value }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -109,11 +109,11 @@
|
|||
<tbody class="ant-table-tbody">
|
||||
<tr>
|
||||
<td>Java 名称</td>
|
||||
<td>{{ systemProperties.properties['java.vm.name'].value }}</td>
|
||||
<td>{{ systemProperties['java.vm.name'].value }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Java 版本</td>
|
||||
<td>{{ systemProperties.properties['java.version'].value }}</td>
|
||||
<td>{{ systemProperties['java.version'].value }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Java Home</td>
|
||||
|
@ -122,7 +122,7 @@
|
|||
:length="isMobile() ? 50 : 256"
|
||||
tooltip
|
||||
>
|
||||
{{ systemProperties.properties['java.home'].value }}
|
||||
{{ systemProperties['java.home'].value }}
|
||||
</ellipsis>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -149,15 +149,11 @@
|
|||
<tbody class="ant-table-tbody">
|
||||
<tr>
|
||||
<td>端口</td>
|
||||
<td>{{ propertiesSourcesMap['server.ports'].properties['local.server.port'].value }}</td>
|
||||
<td>{{ propertiesSourcesMap['server.ports']['local.server.port'].value }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PID</td>
|
||||
<td>{{ systemProperties.properties['PID'].value }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>启动模式</td>
|
||||
<td>{{ systemProperties.properties['spring.profiles.active'].value }}</td>
|
||||
<td>{{ systemProperties['PID'].value }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>启动时间</td>
|
||||
|
@ -174,7 +170,7 @@
|
|||
:length="isMobile() ? 50 : 256"
|
||||
tooltip
|
||||
>
|
||||
{{ systemProperties.properties['user.dir'].value }}
|
||||
{{ systemProperties['user.dir'].value }}
|
||||
</ellipsis>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -185,7 +181,7 @@
|
|||
:length="isMobile() ? 50 : 256"
|
||||
tooltip
|
||||
>
|
||||
{{ systemProperties.properties['LOG_FILE'].value }}
|
||||
{{ systemProperties['LOG_FILE'].value }}
|
||||
</ellipsis>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -207,8 +203,6 @@
|
|||
</template>
|
||||
<script>
|
||||
import { mixin, mixinDevice } from '@/utils/mixin.js'
|
||||
import { mapGetters } from 'vuex'
|
||||
import axios from 'axios'
|
||||
import actuatorApi from '@/api/actuator'
|
||||
export default {
|
||||
name: 'Environment',
|
||||
|
@ -216,7 +210,7 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
propertiesSourcesMap: {},
|
||||
systemProperties: {},
|
||||
systemProperties: [],
|
||||
interval: null,
|
||||
system: {
|
||||
cpu: {
|
||||
|
@ -248,57 +242,46 @@ export default {
|
|||
this.loadSystemInfo()
|
||||
this.loadJvmInfo()
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['options'])
|
||||
},
|
||||
methods: {
|
||||
loadEnv() {
|
||||
actuatorApi.env().then(response => {
|
||||
const propertiesSources = response.data.propertySources
|
||||
propertiesSources.forEach(item => {
|
||||
this.propertiesSourcesMap[item.name] = item
|
||||
this.systemProperties = this.propertiesSourcesMap['systemProperties']
|
||||
this.propertiesSourcesMap[item.name] = item.properties
|
||||
})
|
||||
this.systemProperties = this.propertiesSourcesMap['systemProperties']
|
||||
})
|
||||
},
|
||||
loadSystemInfo() {
|
||||
axios
|
||||
.all([
|
||||
axios.get(this.options.blog_url + '/api/admin/actuator/metrics/system.cpu.count'),
|
||||
axios.get(this.options.blog_url + '/api/admin/actuator/metrics/system.cpu.usage'),
|
||||
axios.get(this.options.blog_url + '/api/admin/actuator/metrics/process.uptime'),
|
||||
axios.get(this.options.blog_url + '/api/admin/actuator/metrics/process.start.time'),
|
||||
axios.get(this.options.blog_url + '/api/admin/actuator/metrics/process.cpu.usage')
|
||||
])
|
||||
.then(response => {
|
||||
this.system.cpu.count = response[0].data.measurements[0].value
|
||||
this.system.cpu.usage = Number(response[1].data.measurements[0].value * 100).toFixed(2)
|
||||
this.system.process.uptime = response[2].data.measurements[0].value
|
||||
this.system.process.startTime = response[3].data.measurements[0].value * 1000
|
||||
this.system.process.cpuUsage = response[4].data.measurements[0].value
|
||||
})
|
||||
.catch(response => {
|
||||
this.$message.error('获取服务器系统信息失败!')
|
||||
})
|
||||
actuatorApi.getSystemCpuCount().then(response => {
|
||||
this.system.cpu.count = response.data.measurements[0].value
|
||||
})
|
||||
actuatorApi.getSystemCpuUsage().then(response => {
|
||||
this.system.cpu.usage = Number(response.data.measurements[0].value * 100).toFixed(2)
|
||||
})
|
||||
actuatorApi.getProcessUptime().then(response => {
|
||||
this.system.process.uptime = response.data.measurements[0].value
|
||||
})
|
||||
actuatorApi.getProcessStartTime().then(response => {
|
||||
this.system.process.startTime = response.data.measurements[0].value * 1000
|
||||
})
|
||||
actuatorApi.getProcessCpuUsage().then(response => {
|
||||
this.system.process.cpuUsage = response.data.measurements[0].value
|
||||
})
|
||||
},
|
||||
loadJvmInfo() {
|
||||
axios
|
||||
.all([
|
||||
axios.get(this.options.blog_url + '/api/admin/actuator/metrics/jvm.memory.max'),
|
||||
axios.get(this.options.blog_url + '/api/admin/actuator/metrics/jvm.memory.committed'),
|
||||
axios.get(this.options.blog_url + '/api/admin/actuator/metrics/jvm.memory.used'),
|
||||
axios.get(this.options.blog_url + '/api/admin/actuator/metrics/jvm.gc.pause')
|
||||
])
|
||||
.then(r => {
|
||||
this.jvm.memory.max = r[0].data.measurements[0].value
|
||||
this.jvm.memory.committed = r[1].data.measurements[0].value
|
||||
this.jvm.memory.used = r[2].data.measurements[0].value
|
||||
this.jvm.gc.pause.count = r[3].data.measurements[0].value
|
||||
})
|
||||
.catch(r => {
|
||||
console.error(r)
|
||||
this.$message.error('获取 JVM 信息失败!')
|
||||
})
|
||||
actuatorApi.getJvmMemoryMax().then(response => {
|
||||
this.jvm.memory.max = response.data.measurements[0].value
|
||||
})
|
||||
actuatorApi.getJvmMemoryCommitted().then(response => {
|
||||
this.jvm.memory.committed = response.data.measurements[0].value
|
||||
})
|
||||
actuatorApi.getJvmMemoryUsed().then(response => {
|
||||
this.jvm.memory.used = response.data.measurements[0].value
|
||||
})
|
||||
actuatorApi.getJvmGcPause().then(response => {
|
||||
this.jvm.gc.pause.count = response.data.measurements[0].value
|
||||
})
|
||||
},
|
||||
handleRefresh() {
|
||||
this.loadSystemInfo()
|
||||
|
|
|
@ -17,6 +17,16 @@
|
|||
type="primary"
|
||||
style="margin-right: 8px;"
|
||||
>下载</a-button>
|
||||
<a-select
|
||||
defaultValue="200"
|
||||
style="margin-right: 8px;width: 100px"
|
||||
@change="handleLinesChange"
|
||||
>
|
||||
<a-select-option value="200">200 行</a-select-option>
|
||||
<a-select-option value="500">500 行</a-select-option>
|
||||
<a-select-option value="800">800 行</a-select-option>
|
||||
<a-select-option value="1000">1000 行</a-select-option>
|
||||
</a-select>
|
||||
<a-button
|
||||
type="dash"
|
||||
@click="()=>this.loadLogs()"
|
||||
|
@ -27,7 +37,7 @@
|
|||
<script>
|
||||
import { codemirror } from 'vue-codemirror-lite'
|
||||
import 'codemirror/mode/shell/shell.js'
|
||||
import actuatorApi from '@/api/actuator'
|
||||
import adminApi from '@/api/admin'
|
||||
export default {
|
||||
name: 'RuntimeLogs',
|
||||
components: {
|
||||
|
@ -42,7 +52,8 @@ export default {
|
|||
line: true
|
||||
},
|
||||
logContent: '',
|
||||
loading: true
|
||||
loading: true,
|
||||
logLines: 200
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
@ -51,10 +62,13 @@ export default {
|
|||
methods: {
|
||||
loadLogs() {
|
||||
this.loading = true
|
||||
actuatorApi.logfile().then(response => {
|
||||
this.logContent = response.data
|
||||
adminApi.getLogFiles(this.logLines).then(response => {
|
||||
this.logContent = response.data.data
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
handleLinesChange(value) {
|
||||
this.logLines = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue