mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-04-19 21:42:24 +00:00
add panel usage to main page
This commit is contained in:
parent
05bc655e16
commit
e00c3f1823
4 changed files with 57 additions and 23 deletions
|
@ -108,8 +108,15 @@
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :sm="24" :md="12">
|
<a-col :sm="24" :md="12">
|
||||||
<a-card hoverable :class="themeSwitcher.darkCardClass">
|
<a-card hoverable :class="themeSwitcher.darkCardClass">
|
||||||
<a-row>
|
{{ i18n "pages.index.operationHours" }}:
|
||||||
<a-col :span="12">
|
Xray:
|
||||||
|
<a-tag color="green">[[ formatSecond(status.appStats.uptime) ]]</a-tag>
|
||||||
|
OS:
|
||||||
|
<a-tag color="green">[[ formatSecond(status.uptime) ]]</a-tag>
|
||||||
|
</a-card>
|
||||||
|
</a-col>
|
||||||
|
<a-col :sm="24" :md="12">
|
||||||
|
<a-card hoverable :class="themeSwitcher.darkCardClass">
|
||||||
{{ i18n "pages.index.systemLoad" }}: [[ status.loads[0] ]] | [[ status.loads[1] ]] | [[ status.loads[2] ]]
|
{{ i18n "pages.index.systemLoad" }}: [[ status.loads[0] ]] | [[ status.loads[1] ]] | [[ status.loads[2] ]]
|
||||||
<a-tooltip>
|
<a-tooltip>
|
||||||
<template slot="title">
|
<template slot="title">
|
||||||
|
@ -117,12 +124,14 @@
|
||||||
</template>
|
</template>
|
||||||
<a-icon type="question-circle" theme="filled"></a-icon>
|
<a-icon type="question-circle" theme="filled"></a-icon>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
|
</a-card>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="12">
|
<a-col :sm="24" :md="12">
|
||||||
{{ i18n "pages.index.operationHours" }}:
|
<a-card hoverable :class="themeSwitcher.darkCardClass">
|
||||||
<a-tag color="green">[[ formatSecond(status.uptime) ]]</a-tag>
|
{{ i18n "usage"}}:
|
||||||
</a-col>
|
Memory [[ sizeFormat(status.appStats.mem) ]] -
|
||||||
</a-row>
|
Threads [[ status.appStats.threads ]]
|
||||||
|
</a-tooltip>
|
||||||
</a-card>
|
</a-card>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :sm="24" :md="12">
|
<a-col :sm="24" :md="12">
|
||||||
|
@ -361,6 +370,8 @@
|
||||||
this.tcpCount = 0;
|
this.tcpCount = 0;
|
||||||
this.udpCount = 0;
|
this.udpCount = 0;
|
||||||
this.uptime = 0;
|
this.uptime = 0;
|
||||||
|
this.appUptime = 0;
|
||||||
|
this.appStats = {threads: 0, mem: 0, uptime: 0};
|
||||||
this.xray = { state: State.Stop, errorMsg: "", version: "", color: "" };
|
this.xray = { state: State.Stop, errorMsg: "", version: "", color: "" };
|
||||||
|
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
|
@ -379,6 +390,8 @@
|
||||||
this.tcpCount = data.tcpCount;
|
this.tcpCount = data.tcpCount;
|
||||||
this.udpCount = data.udpCount;
|
this.udpCount = data.udpCount;
|
||||||
this.uptime = data.uptime;
|
this.uptime = data.uptime;
|
||||||
|
this.appUptime = data.appUptime;
|
||||||
|
this.appStats = data.appStats;
|
||||||
this.xray = data.xray;
|
this.xray = data.xray;
|
||||||
switch (this.xray.state) {
|
switch (this.xray.state) {
|
||||||
case State.Running:
|
case State.Running:
|
||||||
|
|
|
@ -31,7 +31,6 @@ func NewCheckClientIpJob() *CheckClientIpJob {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *CheckClientIpJob) Run() {
|
func (j *CheckClientIpJob) Run() {
|
||||||
logger.Debug("Check Client IP Job...")
|
|
||||||
|
|
||||||
// create files required for iplimit if not exists
|
// create files required for iplimit if not exists
|
||||||
for i := 0; i < len(ipFiles); i++ {
|
for i := 0; i < len(ipFiles); i++ {
|
||||||
|
|
|
@ -77,6 +77,11 @@ type Status struct {
|
||||||
IPv4 string `json:"ipv4"`
|
IPv4 string `json:"ipv4"`
|
||||||
IPv6 string `json:"ipv6"`
|
IPv6 string `json:"ipv6"`
|
||||||
} `json:"publicIP"`
|
} `json:"publicIP"`
|
||||||
|
AppStats struct {
|
||||||
|
Threads uint32 `json:"threads"`
|
||||||
|
Mem uint64 `json:"mem"`
|
||||||
|
Uptime uint64 `json:"uptime"`
|
||||||
|
} `json:"appStats"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Release struct {
|
type Release struct {
|
||||||
|
@ -220,6 +225,16 @@ func (s *ServerService) GetStatus(lastStatus *Status) *Status {
|
||||||
status.Xray.ErrorMsg = s.xrayService.GetXrayResult()
|
status.Xray.ErrorMsg = s.xrayService.GetXrayResult()
|
||||||
}
|
}
|
||||||
status.Xray.Version = s.xrayService.GetXrayVersion()
|
status.Xray.Version = s.xrayService.GetXrayVersion()
|
||||||
|
var rtm runtime.MemStats
|
||||||
|
runtime.ReadMemStats(&rtm)
|
||||||
|
|
||||||
|
status.AppStats.Mem = rtm.Sys
|
||||||
|
status.AppStats.Threads = uint32(runtime.NumGoroutine())
|
||||||
|
if p.IsRunning() {
|
||||||
|
status.AppStats.Uptime = p.GetUptime()
|
||||||
|
} else {
|
||||||
|
status.AppStats.Uptime = 0
|
||||||
|
}
|
||||||
|
|
||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
"time"
|
||||||
|
|
||||||
"x-ui/config"
|
"x-ui/config"
|
||||||
"x-ui/logger"
|
"x-ui/logger"
|
||||||
|
@ -104,6 +105,7 @@ type process struct {
|
||||||
config *Config
|
config *Config
|
||||||
lines *queue.Queue
|
lines *queue.Queue
|
||||||
exitErr error
|
exitErr error
|
||||||
|
startTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func newProcess(config *Config) *process {
|
func newProcess(config *Config) *process {
|
||||||
|
@ -111,6 +113,7 @@ func newProcess(config *Config) *process {
|
||||||
version: "Unknown",
|
version: "Unknown",
|
||||||
config: config,
|
config: config,
|
||||||
lines: queue.New(100),
|
lines: queue.New(100),
|
||||||
|
startTime: time.Now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,6 +157,10 @@ func (p *Process) GetConfig() *Config {
|
||||||
return p.config
|
return p.config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Process) GetUptime() uint64 {
|
||||||
|
return uint64(time.Since(p.startTime).Seconds())
|
||||||
|
}
|
||||||
|
|
||||||
func (p *process) refreshAPIPort() {
|
func (p *process) refreshAPIPort() {
|
||||||
for _, inbound := range p.config.InboundConfigs {
|
for _, inbound := range p.config.InboundConfigs {
|
||||||
if inbound.Tag == "api" {
|
if inbound.Tag == "api" {
|
||||||
|
|
Loading…
Reference in a new issue