mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-09-03 08:46:18 +00:00
Add files via upload
This commit is contained in:
parent
be8892b338
commit
a436695de9
1 changed files with 1 additions and 49 deletions
|
@ -17,8 +17,6 @@ import (
|
||||||
"x-ui/xray"
|
"x-ui/xray"
|
||||||
|
|
||||||
"github.com/mymmrac/telego"
|
"github.com/mymmrac/telego"
|
||||||
"github.com/shirou/gopsutil/cpu"
|
|
||||||
"github.com/shirou/gopsutil/disk"
|
|
||||||
th "github.com/mymmrac/telego/telegohandler"
|
th "github.com/mymmrac/telego/telegohandler"
|
||||||
tu "github.com/mymmrac/telego/telegoutil"
|
tu "github.com/mymmrac/telego/telegoutil"
|
||||||
)
|
)
|
||||||
|
@ -590,30 +588,6 @@ func (t *Tgbot) SendBackupToAdmins() {
|
||||||
t.sendBackup(int64(adminId))
|
t.sendBackup(int64(adminId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Get CPU Info
|
|
||||||
func getCPUInfo() (string, error) {
|
|
||||||
infoStat, err := cpu.Info()
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("CPU Info: %v", infoStat[0]), nil
|
|
||||||
}
|
|
||||||
// Get disk usage
|
|
||||||
func getDiskUsage() (string, error) {
|
|
||||||
usageStat, err := disk.Usage("/")
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("Disk Usage: %v", usageStat), nil
|
|
||||||
}
|
|
||||||
// Get CPU usage
|
|
||||||
func getCPUUsage() (string, error) {
|
|
||||||
percent, err := cpu.Percent(time.Second, false)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("CPU Usage: %.2f%%", percent[0]), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *Tgbot) getServerUsage() string {
|
func (t *Tgbot) getServerUsage() string {
|
||||||
info, ipv4, ipv6 := "", "", ""
|
info, ipv4, ipv6 := "", "", ""
|
||||||
|
@ -646,6 +620,7 @@ func (t *Tgbot) getServerUsage() string {
|
||||||
info += t.I18nBot("tgbot.messages.ipv4", "IPv4=="+ipv4)
|
info += t.I18nBot("tgbot.messages.ipv4", "IPv4=="+ipv4)
|
||||||
info += t.I18nBot("tgbot.messages.ipv6", "IPv6=="+ipv6)
|
info += t.I18nBot("tgbot.messages.ipv6", "IPv6=="+ipv6)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get latest status of server
|
// get latest status of server
|
||||||
t.lastStatus = t.serverService.GetStatus(t.lastStatus)
|
t.lastStatus = t.serverService.GetStatus(t.lastStatus)
|
||||||
info += t.I18nBot("tgbot.messages.serverUpTime", "UpTime=="+strconv.FormatUint(t.lastStatus.Uptime/86400, 10), "Unit=="+t.I18nBot("tgbot.days"))
|
info += t.I18nBot("tgbot.messages.serverUpTime", "UpTime=="+strconv.FormatUint(t.lastStatus.Uptime/86400, 10), "Unit=="+t.I18nBot("tgbot.days"))
|
||||||
|
@ -655,29 +630,6 @@ func (t *Tgbot) getServerUsage() string {
|
||||||
info += t.I18nBot("tgbot.messages.udpCount", "Count=="+strconv.Itoa(t.lastStatus.UdpCount))
|
info += t.I18nBot("tgbot.messages.udpCount", "Count=="+strconv.Itoa(t.lastStatus.UdpCount))
|
||||||
info += t.I18nBot("tgbot.messages.traffic", "Total=="+common.FormatTraffic(int64(t.lastStatus.NetTraffic.Sent+t.lastStatus.NetTraffic.Recv)), "Upload=="+common.FormatTraffic(int64(t.lastStatus.NetTraffic.Sent)), "Download=="+common.FormatTraffic(int64(t.lastStatus.NetTraffic.Recv)))
|
info += t.I18nBot("tgbot.messages.traffic", "Total=="+common.FormatTraffic(int64(t.lastStatus.NetTraffic.Sent+t.lastStatus.NetTraffic.Recv)), "Upload=="+common.FormatTraffic(int64(t.lastStatus.NetTraffic.Sent)), "Download=="+common.FormatTraffic(int64(t.lastStatus.NetTraffic.Recv)))
|
||||||
info += t.I18nBot("tgbot.messages.xrayStatus", "State=="+fmt.Sprint(t.lastStatus.Xray.State))
|
info += t.I18nBot("tgbot.messages.xrayStatus", "State=="+fmt.Sprint(t.lastStatus.Xray.State))
|
||||||
// get CPU info
|
|
||||||
cpuInfo, err := getCPUInfo()
|
|
||||||
if err != nil {
|
|
||||||
logger.Error("Error getting CPU info: ", err)
|
|
||||||
} else {
|
|
||||||
info += t.I18nBot("tgbot.messages.cpuInfo", "CPU Info=="+cpuInfo)
|
|
||||||
}
|
|
||||||
|
|
||||||
// get CPU usage
|
|
||||||
cpuUsage, err := getCPUUsage()
|
|
||||||
if err != nil {
|
|
||||||
logger.Error("Error getting CPU usage: ", err)
|
|
||||||
} else {
|
|
||||||
info += t.I18nBot("tgbot.messages.cpuUsage", "CPU Usage=="+cpuUsage)
|
|
||||||
}
|
|
||||||
|
|
||||||
// get disk usage
|
|
||||||
diskUsage, err := getDiskUsage()
|
|
||||||
if err != nil {
|
|
||||||
logger.Error("Error getting disk usage: ", err)
|
|
||||||
} else {
|
|
||||||
info += t.I18nBot("tgbot.messages.diskUsage", "Disk Usage=="+diskUsage)
|
|
||||||
}
|
|
||||||
return info
|
return info
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue