diff --git a/backend/app/api/v1/terminal.go b/backend/app/api/v1/terminal.go
index 347b72506..b4a045a15 100644
--- a/backend/app/api/v1/terminal.go
+++ b/backend/app/api/v1/terminal.go
@@ -73,7 +73,6 @@ func (b *BaseApi) WsSsh(c *gin.Context) {
<-quitChan
- global.LOG.Info("websocket finished")
if wshandleError(wsConn, err) {
return
}
diff --git a/backend/app/dto/dashboard.go b/backend/app/dto/dashboard.go
index c976a56ff..565d03009 100644
--- a/backend/app/dto/dashboard.go
+++ b/backend/app/dto/dashboard.go
@@ -23,8 +23,6 @@ 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"`
@@ -34,6 +32,9 @@ type DashboardBase struct {
}
type DashboardCurrent struct {
+ Uptime uint64 `json:"uptime"`
+ TimeSinceUptime string `json:"timeSinceUptime"`
+
Procs uint64 `json:"procs"`
Load1 float64 `json:"load1"`
diff --git a/backend/app/service/dashboard.go b/backend/app/service/dashboard.go
index a8d5ae078..d15649e06 100644
--- a/backend/app/service/dashboard.go
+++ b/backend/app/service/dashboard.go
@@ -2,9 +2,6 @@ package service
import (
"encoding/json"
- "fmt"
- "os/exec"
- "strings"
"time"
"github.com/1Panel-dev/1Panel/backend/app/dto"
@@ -42,18 +39,6 @@ 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", strings.ReplaceAll(string(stdout), "\n", ""))
- 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
@@ -111,6 +96,8 @@ func (u *DashboardService) LoadBaseInfo(ioOption string, netOption string) (*dto
func (u *DashboardService) LoadCurrentInfo(ioOption string, netOption string) *dto.DashboardCurrent {
var currentInfo dto.DashboardCurrent
hostInfo, _ := host.Info()
+ currentInfo.Uptime = hostInfo.Uptime
+ currentInfo.TimeSinceUptime = time.Now().Add(-time.Duration(hostInfo.Uptime) * time.Second).Format("2006-01-02 15:04:05")
currentInfo.Procs = hostInfo.Procs
currentInfo.CPUTotal, _ = cpu.Counts(true)
diff --git a/backend/app/service/image.go b/backend/app/service/image.go
index 3e67c842d..750f0cbe5 100644
--- a/backend/app/service/image.go
+++ b/backend/app/service/image.go
@@ -8,6 +8,7 @@ import (
"fmt"
"io"
"os"
+ "path"
"strings"
"time"
@@ -165,8 +166,7 @@ func (u *ImageService) ImagePull(req dto.ImagePull) (string, error) {
return "", err
}
}
- imageItemName := strings.ReplaceAll(req.ImageName, ":", "_")
- imageItemName = strings.ReplaceAll(imageItemName, "/", "@")
+ imageItemName := strings.ReplaceAll(path.Base(req.ImageName), ":", "_")
pathItem := fmt.Sprintf("%s/image_pull_%s_%s.log", dockerLogDir, imageItemName, time.Now().Format("20060102150405"))
file, err := os.OpenFile(pathItem, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {
@@ -301,8 +301,7 @@ func (u *ImageService) ImagePush(req dto.ImagePush) (string, error) {
return "", err
}
}
- imageItemName := strings.ReplaceAll(req.Name, ":", "_")
- imageItemName = strings.ReplaceAll(imageItemName, "/", "@")
+ imageItemName := strings.ReplaceAll(path.Base(req.Name), ":", "_")
pathItem := fmt.Sprintf("%s/image_push_%s_%s.log", dockerLogDir, imageItemName, time.Now().Format("20060102150405"))
file, err := os.OpenFile(pathItem, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {
diff --git a/backend/utils/terminal/ws_session.go b/backend/utils/terminal/ws_session.go
index 2d05ebc2c..338a6c877 100644
--- a/backend/utils/terminal/ws_session.go
+++ b/backend/utils/terminal/ws_session.go
@@ -185,7 +185,6 @@ func (sws *LogicSshWsSession) sendComboOutput(exitCh chan bool) {
func (sws *LogicSshWsSession) Wait(quitChan chan bool) {
if err := sws.session.Wait(); err != nil {
- global.LOG.Errorf("ssh session wait failed, err: %v", err)
setQuit(quitChan)
}
}
diff --git a/frontend/src/api/interface/dashboard.ts b/frontend/src/api/interface/dashboard.ts
index 4ffc684cd..1e4e77f08 100644
--- a/frontend/src/api/interface/dashboard.ts
+++ b/frontend/src/api/interface/dashboard.ts
@@ -20,8 +20,6 @@ export namespace Dashboard {
kernelArch: string;
kernelVersion: string;
virtualizationSystem: string;
- uptime: string;
- timeSinceUptime: string;
cpuCores: number;
cpuLogicalCores: number;
@@ -30,6 +28,8 @@ export namespace Dashboard {
currentInfo: CurrentInfo;
}
export interface CurrentInfo {
+ uptime: number;
+ timeSinceUptime: string;
procs: number;
load1: number;
diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts
index 939810bd0..a2d6e547c 100644
--- a/frontend/src/lang/modules/en.ts
+++ b/frontend/src/lang/modules/en.ts
@@ -191,6 +191,7 @@ export default {
Day: 'Days',
Hour: 'Hours',
Minute: 'Minutes',
+ Second: 'Seconds',
runSmoothly: 'Run smoothly',
runNormal: 'Run normal',
@@ -596,6 +597,7 @@ export default {
apps: 'App',
containers: 'Container',
commands: 'Command',
+ groups: 'System Group',
backups: 'Backup Account',
settings: 'Panel Setting',
cronjobs: 'Cronjob',
diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts
index e3a038375..cc89d6c06 100644
--- a/frontend/src/lang/modules/zh.ts
+++ b/frontend/src/lang/modules/zh.ts
@@ -194,8 +194,9 @@ export default {
uptime: '启动时间',
runningTime: '运行时间',
Day: '天',
- Hour: '小时',
- Minute: '分钟',
+ Hour: '时',
+ Minute: '分',
+ Second: '秒',
runSmoothly: '运行流畅',
runNormal: '运行正常',
@@ -607,6 +608,7 @@ export default {
hosts: '主机',
apps: '应用',
containers: '容器',
+ groups: '系统组',
commands: '快捷命令',
backups: '备份账号',
settings: '面板设置',
diff --git a/frontend/src/views/home/index.vue b/frontend/src/views/home/index.vue
index 2ba7a3df3..893422ad1 100644
--- a/frontend/src/views/home/index.vue
+++ b/frontend/src/views/home/index.vue
@@ -100,8 +100,10 @@
{{ baseInfo.kernelVersion }}
{{ baseInfo.kernelArch }}
- {{ baseInfo.uptime }}
- {{ baseInfo.timeSinceUptime }}
+ {{ currentInfo.timeSinceUptime }}
+
+ {{ loadUpTime(currentInfo.uptime) }}
+
@@ -227,8 +229,6 @@ const baseInfo = ref({
kernelArch: '',
kernelVersion: '',
virtualizationSystem: '',
- uptime: '',
- timeSinceUptime: '',
cpuCores: 0,
cpuLogicalCores: 0,
@@ -236,6 +236,8 @@ const baseInfo = ref({
currentInfo: null,
});
const currentInfo = ref({
+ uptime: 0,
+ timeSinceUptime: '',
procs: 0,
load1: 0,
@@ -316,11 +318,6 @@ const onLoadBaseInfo = async (isInit: boolean, range: string) => {
const res = await loadBaseInfo(searchInfo.ioOption, searchInfo.netOption);
baseInfo.value = res.data;
currentInfo.value = baseInfo.value.currentInfo;
- if (baseInfo.value.timeSinceUptime) {
- baseInfo.value.timeSinceUptime.replaceAll('days', i18n.global.t('home.Day'));
- baseInfo.value.timeSinceUptime.replaceAll('hours', i18n.global.t('home.Hour'));
- baseInfo.value.timeSinceUptime.replaceAll('minutes', i18n.global.t('home.Minute'));
- }
onLoadCurrentInfo();
statuRef.value.acceptParams(currentInfo.value, baseInfo.value);
appRef.value.acceptParams(baseInfo.value);
@@ -334,6 +331,8 @@ const onLoadBaseInfo = async (isInit: boolean, range: string) => {
const onLoadCurrentInfo = async () => {
const res = await loadCurrentInfo(searchInfo.ioOption, searchInfo.netOption);
+ currentInfo.value.timeSinceUptime = res.data.timeSinceUptime;
+
currentChartInfo.netBytesSent = Number(
((res.data.netBytesSent - currentInfo.value.netBytesSent) / 1024 / 3).toFixed(2),
);
@@ -378,6 +377,47 @@ const onLoadCurrentInfo = async () => {
statuRef.value.acceptParams(currentInfo.value, baseInfo.value);
};
+function loadUpTime(uptime: number) {
+ if (uptime <= 0) {
+ return '-';
+ }
+ let days = Math.floor(uptime / 86400);
+ let hours = Math.floor((uptime % 86400) / 3600);
+ let minutes = Math.floor((uptime % 3600) / 60);
+ let seconds = uptime % 60;
+ if (days !== 0) {
+ return (
+ days +
+ i18n.global.t('home.Day') +
+ ' ' +
+ hours +
+ i18n.global.t('home.Hour') +
+ ' ' +
+ minutes +
+ i18n.global.t('home.Minute') +
+ ' ' +
+ seconds +
+ i18n.global.t('home.Second')
+ );
+ }
+ if (hours !== 0) {
+ return (
+ hours +
+ i18n.global.t('home.Hour') +
+ ' ' +
+ minutes +
+ i18n.global.t('home.Minute') +
+ ' ' +
+ seconds +
+ i18n.global.t('home.Second')
+ );
+ }
+ if (minutes !== 0) {
+ return minutes + i18n.global.t('home.Minute') + ' ' + seconds + i18n.global.t('home.Second');
+ }
+ return seconds + i18n.global.t('home.Second');
+}
+
const loadData = async () => {
if (chartOption.value === 'io') {
let ioReadYDatas = {
diff --git a/frontend/src/views/home/status/index.vue b/frontend/src/views/home/status/index.vue
index 90ae614fd..c20dfd754 100644
--- a/frontend/src/views/home/status/index.vue
+++ b/frontend/src/views/home/status/index.vue
@@ -138,8 +138,6 @@ const baseInfo = ref({
databaseNumber: 0,
cronjobNumber: 0,
appInstalldNumber: 0,
- uptime: '',
- timeSinceUptime: '',
hostname: '',
os: '',
@@ -156,6 +154,8 @@ const baseInfo = ref({
currentInfo: null,
});
const currentInfo = ref({
+ uptime: 0,
+ timeSinceUptime: '',
procs: 0,
load1: 0,
diff --git a/frontend/src/views/host/monitor/index.vue b/frontend/src/views/host/monitor/index.vue
index cbbab7e0b..1698b6eb1 100644
--- a/frontend/src/views/host/monitor/index.vue
+++ b/frontend/src/views/host/monitor/index.vue
@@ -202,11 +202,12 @@ const search = async (param: string) => {
searchInfo.endTime = searchTime.value[1];
}
const res = await loadMonitor(searchInfo);
- if (res.data[0].value === null) {
- return;
- }
monitorBase.value = res.data;
for (const item of monitorBase.value) {
+ if (!item.value) {
+ item.value = [];
+ item.date = [];
+ }
switch (item.param) {
case 'base':
let baseDate = item.date.map(function (item: any) {
diff --git a/frontend/src/views/setting/monitor/index.vue b/frontend/src/views/setting/monitor/index.vue
index 8b4ffda05..fff6d7fbc 100644
--- a/frontend/src/views/setting/monitor/index.vue
+++ b/frontend/src/views/setting/monitor/index.vue
@@ -64,7 +64,7 @@ const panelFormRef = ref();
const search = async () => {
const res = await getSettingInfo();
form.monitorStatus = res.data.monitorStatus;
- form.monitorStoreDays = res.data.monitorStoreDays;
+ form.monitorStoreDays = Number(res.data.monitorStoreDays);
};
const onSave = async (formEl: FormInstance | undefined, key: string, val: any) => {