mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-30 23:49:10 +08:00
fix: 概览界面增加启动时间运行时间
This commit is contained in:
parent
c1b7e5edd7
commit
89b96a5b75
@ -23,6 +23,8 @@ type DashboardBase struct {
|
||||
KernelArch string `json:"kernelArch"`
|
||||
KernelVersion string `json:"kernelVersion"`
|
||||
VirtualizationSystem string `json:"virtualizationSystem"`
|
||||
Uptime string `json:"uptime"`
|
||||
TimeSinceUptime string `json:"timeSinceUptime"`
|
||||
|
||||
CPUCores int `json:"cpuCores"`
|
||||
CPULogicalCores int `json:"cpuLogicalCores"`
|
||||
|
@ -2,6 +2,8 @@ package service
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"time"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||
@ -39,6 +41,18 @@ func (u *DashboardService) LoadBaseInfo(ioOption string, netOption string) (*dto
|
||||
ss, _ := json.Marshal(hostInfo)
|
||||
baseInfo.VirtualizationSystem = string(ss)
|
||||
|
||||
cmd := exec.Command("uptime", "-s")
|
||||
stdout, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
baseInfo.Uptime = string(stdout)
|
||||
uptime, err := time.Parse("2006-01-02 15:04:05", string(stdout))
|
||||
if err != nil {
|
||||
hours := int(time.Since(uptime).Hours())
|
||||
minutes := int(time.Since(uptime).Minutes())
|
||||
baseInfo.TimeSinceUptime = fmt.Sprintf("%ddays %dhours %dmimutes", hours/24, hours%24, minutes-hours*60)
|
||||
}
|
||||
}
|
||||
|
||||
apps, err := appRepo.GetBy()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -8,6 +8,13 @@ import (
|
||||
"encoding/pem"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/cmd"
|
||||
"github.com/cenkalti/backoff/v4"
|
||||
"github.com/go-acme/lego/v4/acme"
|
||||
@ -18,12 +25,6 @@ import (
|
||||
"github.com/go-acme/lego/v4/challenge/dns01"
|
||||
"github.com/go-acme/lego/v4/lego"
|
||||
"github.com/go-acme/lego/v4/registration"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
type plainDnsProvider struct {
|
||||
@ -37,11 +38,6 @@ func (p *plainDnsProvider) Present(domain, token, keyAuth string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *plainDnsProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
fmt.Sprintf("%s,%s,%s", domain, token, keyAuth)
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestCreatePrivate(t *testing.T) {
|
||||
priKey, err := rsa.GenerateKey(rand.Reader, 2048)
|
||||
if err != nil {
|
||||
@ -263,10 +259,10 @@ func TestSSL(t *testing.T) {
|
||||
// panic(err)
|
||||
//}
|
||||
|
||||
err = client.Challenge.SetDNS01Provider(&plainDnsProvider{}, dns01.AddDNSTimeout(6*time.Minute))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// err = client.Challenge.SetDNS01Provider(&plainDnsProvider{}, dns01.AddDNSTimeout(6*time.Minute))
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
|
||||
core, err := api.New(config.HTTPClient, config.UserAgent, config.CADirURL, reg.URI, priKey)
|
||||
if err != nil {
|
||||
|
@ -20,6 +20,8 @@ export namespace Dashboard {
|
||||
kernelArch: string;
|
||||
kernelVersion: string;
|
||||
virtualizationSystem: string;
|
||||
uptime: string;
|
||||
timeSinceUptime: string;
|
||||
|
||||
cpuCores: number;
|
||||
cpuLogicalCores: number;
|
||||
|
@ -163,6 +163,8 @@ export default {
|
||||
rwPerSecond: 'RW per second',
|
||||
ioDelay: 'IO delay',
|
||||
time: 'Times',
|
||||
uptime: 'Up Time',
|
||||
runningTime: 'Running Time',
|
||||
|
||||
runSmoothly: 'Run smoothly',
|
||||
runNormal: 'Run normal',
|
||||
|
@ -169,6 +169,8 @@ export default {
|
||||
rwPerSecond: '每秒读写',
|
||||
ioDelay: 'IO 延迟',
|
||||
time: '次',
|
||||
uptime: '启动时间',
|
||||
runningTime: '运行时间',
|
||||
|
||||
runSmoothly: '运行流畅',
|
||||
runNormal: '运行正常',
|
||||
|
@ -106,6 +106,25 @@
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog
|
||||
v-model="phpVisiable"
|
||||
:title="$t('app.checkTitle')"
|
||||
width="30%"
|
||||
:close-on-click-modal="false"
|
||||
:destroy-on-close="true"
|
||||
>
|
||||
<el-alert :closable="false" :title="$t('app.checkInstalledWarn', ['phpMyAdmin'])" type="info">
|
||||
<el-link icon="Position" @click="goRouter('/apps')" type="primary">
|
||||
{{ $t('database.goInstall') }}
|
||||
</el-link>
|
||||
</el-alert>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="phpVisiable = false">{{ $t('commons.button.cancel') }}</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<UploadDialog ref="uploadRef" />
|
||||
<OperatrDialog @search="search" ref="dialogRef" />
|
||||
<BackupRecords ref="dialogBackupRef" />
|
||||
@ -133,13 +152,16 @@ import { Database } from '@/api/interface/database';
|
||||
import { Rules } from '@/global/form-rules';
|
||||
import { App } from '@/api/interface/app';
|
||||
import { GetAppPort } from '@/api/modules/app';
|
||||
import router from '@/routers';
|
||||
|
||||
const selects = ref<any>([]);
|
||||
const mysqlName = ref();
|
||||
const isOnSetting = ref<boolean>();
|
||||
|
||||
const checkRef = ref();
|
||||
|
||||
const phpadminPort = ref();
|
||||
const phpVisiable = ref(false);
|
||||
|
||||
const data = ref();
|
||||
const paginationConfig = reactive({
|
||||
@ -214,7 +236,15 @@ const search = async () => {
|
||||
paginationConfig.total = res.data.total;
|
||||
};
|
||||
|
||||
const goRouter = async (path: string) => {
|
||||
router.push({ path: path });
|
||||
};
|
||||
|
||||
const goDashboard = async () => {
|
||||
if (phpadminPort.value === 0) {
|
||||
phpVisiable.value = true;
|
||||
return;
|
||||
}
|
||||
window.open('http://localhost:' + phpadminPort.value, '_blank');
|
||||
};
|
||||
|
||||
|
@ -9,6 +9,25 @@
|
||||
<el-button style="margin-top: 20px" type="p" @click="goDashboard" icon="Position">Redis-Command</el-button>
|
||||
<Terminal v-show="!isOnSetting" ref="terminalRef" />
|
||||
</div>
|
||||
|
||||
<el-dialog
|
||||
v-model="commandVisiable"
|
||||
:title="$t('app.checkTitle')"
|
||||
width="30%"
|
||||
:close-on-click-modal="false"
|
||||
:destroy-on-close="true"
|
||||
>
|
||||
<el-alert :closable="false" :title="$t('app.checkInstalledWarn', ['Redis-Command'])" type="info">
|
||||
<el-link icon="Position" @click="goRouter('/apps')" type="primary">
|
||||
{{ $t('database.goInstall') }}
|
||||
</el-link>
|
||||
</el-alert>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="commandVisiable = false">{{ $t('commons.button.cancel') }}</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -20,6 +39,7 @@ import AppStatus from '@/components/app-status/index.vue';
|
||||
import { ref } from 'vue';
|
||||
import { App } from '@/api/interface/app';
|
||||
import { GetAppPort } from '@/api/modules/app';
|
||||
import router from '@/routers';
|
||||
|
||||
const terminalRef = ref();
|
||||
const settingRef = ref();
|
||||
@ -27,6 +47,7 @@ const isOnSetting = ref(false);
|
||||
const redisIsExist = ref(false);
|
||||
|
||||
const redisCommandPort = ref();
|
||||
const commandVisiable = ref(false);
|
||||
|
||||
const onSetting = async () => {
|
||||
isOnSetting.value = true;
|
||||
@ -34,12 +55,20 @@ const onSetting = async () => {
|
||||
settingRef.value!.acceptParams();
|
||||
};
|
||||
|
||||
const goRouter = async (path: string) => {
|
||||
router.push({ path: path });
|
||||
};
|
||||
|
||||
const goDashboard = async () => {
|
||||
if (redisCommandPort.value === 0) {
|
||||
commandVisiable.value = true;
|
||||
return;
|
||||
}
|
||||
window.open('http://localhost:' + redisCommandPort.value, '_blank');
|
||||
};
|
||||
|
||||
const loadDashboardPort = async () => {
|
||||
const res = await GetAppPort('phpmyadmin');
|
||||
const res = await GetAppPort('redis-commander');
|
||||
redisCommandPort.value = res.data;
|
||||
};
|
||||
|
||||
|
@ -93,6 +93,8 @@
|
||||
{{ baseInfo.kernelVersion }}
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('home.kernelArch')">{{ baseInfo.kernelArch }}</el-form-item>
|
||||
<el-form-item :label="$t('home.uptime')">{{ baseInfo.uptime }}</el-form-item>
|
||||
<el-form-item :label="$t('home.runningTime')">{{ baseInfo.timeSinceUptime }}</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</el-col>
|
||||
@ -218,6 +220,8 @@ const baseInfo = ref<Dashboard.BaseInfo>({
|
||||
kernelArch: '',
|
||||
kernelVersion: '',
|
||||
virtualizationSystem: '',
|
||||
uptime: '',
|
||||
timeSinceUptime: '',
|
||||
|
||||
cpuCores: 0,
|
||||
cpuLogicalCores: 0,
|
||||
|
2
go.mod
2
go.mod
@ -5,6 +5,7 @@ go 1.18
|
||||
require (
|
||||
github.com/aliyun/aliyun-oss-go-sdk v2.2.5+incompatible
|
||||
github.com/aws/aws-sdk-go v1.44.99
|
||||
github.com/cenkalti/backoff/v4 v4.1.3
|
||||
github.com/compose-spec/compose-go v1.6.0
|
||||
github.com/dgraph-io/badger/v3 v3.2103.2
|
||||
github.com/docker/docker v20.10.18+incompatible
|
||||
@ -63,7 +64,6 @@ require (
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1755 // indirect
|
||||
github.com/andybalholm/brotli v1.0.4 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
|
||||
github.com/cespare/xxhash v1.1.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/cloudflare/cloudflare-go v0.49.0 // indirect
|
||||
|
Loading…
Reference in New Issue
Block a user