mirror of
https://github.com/oneclickvirt/ecs.git
synced 2025-10-01 05:32:18 +08:00
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9073802585 |
@@ -10,11 +10,10 @@ import (
|
|||||||
// 使用gopsutil查询可能会特别慢,执行命令查询反而更快
|
// 使用gopsutil查询可能会特别慢,执行命令查询反而更快
|
||||||
// TODO
|
// TODO
|
||||||
// 迁移Shell的完整检测逻辑使用执行命令的方式查询,最后都失败才使用gopsutil查询
|
// 迁移Shell的完整检测逻辑使用执行命令的方式查询,最后都失败才使用gopsutil查询
|
||||||
|
// 本包已在main中调用
|
||||||
func Basic(language string) {
|
func Basic(language string) {
|
||||||
ipInfo, _, _ := network.NetworkCheck("both", false, language)
|
ipInfo, _, _ := network.NetworkCheck("both", false, language)
|
||||||
res := system.CheckSystemInfo(language)
|
systemInfo := system.CheckSystemInfo(language)
|
||||||
//fmt.Println("--------------------------------------------------")
|
basicInfo := strings.ReplaceAll(systemInfo+ipInfo, "\n\n", "\n")
|
||||||
fmt.Printf(strings.ReplaceAll(res+ipInfo, "\n\n", "\n"))
|
fmt.Printf(basicInfo)
|
||||||
//fmt.Println("--------------------------------------------------")
|
|
||||||
}
|
}
|
||||||
|
77
goecs.go
77
goecs.go
@@ -4,8 +4,8 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/oneclickvirt/UnlockTests/uts"
|
"github.com/oneclickvirt/UnlockTests/uts"
|
||||||
|
"github.com/oneclickvirt/basics/system"
|
||||||
"github.com/oneclickvirt/ecs/backtrace"
|
"github.com/oneclickvirt/ecs/backtrace"
|
||||||
"github.com/oneclickvirt/ecs/basic"
|
|
||||||
"github.com/oneclickvirt/ecs/commediatest"
|
"github.com/oneclickvirt/ecs/commediatest"
|
||||||
"github.com/oneclickvirt/ecs/cputest"
|
"github.com/oneclickvirt/ecs/cputest"
|
||||||
"github.com/oneclickvirt/ecs/disktest"
|
"github.com/oneclickvirt/ecs/disktest"
|
||||||
@@ -23,16 +23,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ecsVersion = "2024.06.30"
|
ecsVersion = "2024.06.30"
|
||||||
showVersion bool
|
showVersion bool
|
||||||
language string
|
language string
|
||||||
cpuTestMethod, cpuTestThread string
|
cpuTestMethod, cpuTestThreadMode string
|
||||||
memoryTestMethod string
|
memoryTestMethod string
|
||||||
diskTestMethod, diskTestPath string
|
diskTestMethod, diskTestPath string
|
||||||
diskMultiCheck bool
|
diskMultiCheck bool
|
||||||
nt3CheckType, nt3Location string
|
nt3CheckType, nt3Location string
|
||||||
spNum int
|
spNum int
|
||||||
width = 84
|
width = 84
|
||||||
)
|
)
|
||||||
|
|
||||||
func printCenteredTitle(title string, width int) {
|
func printCenteredTitle(title string, width int) {
|
||||||
@@ -43,8 +43,21 @@ func printCenteredTitle(title string, width int) {
|
|||||||
fmt.Println(paddingStr + title + paddingStr + strings.Repeat("-", totalPadding%2))
|
fmt.Println(paddingStr + title + paddingStr + strings.Repeat("-", totalPadding%2))
|
||||||
}
|
}
|
||||||
|
|
||||||
func securityCheck() string {
|
func securityCheck() (string, string) {
|
||||||
ipInfo, securityInfo, _ := network.NetworkCheck("both", true, language)
|
var wgt sync.WaitGroup
|
||||||
|
var ipInfo, securityInfo, systemInfo string
|
||||||
|
go func() {
|
||||||
|
wgt.Add(1)
|
||||||
|
defer wgt.Done()
|
||||||
|
ipInfo, securityInfo, _ = network.NetworkCheck("both", true, language)
|
||||||
|
}()
|
||||||
|
go func() {
|
||||||
|
wgt.Add(1)
|
||||||
|
defer wgt.Done()
|
||||||
|
systemInfo = system.CheckSystemInfo(language)
|
||||||
|
}()
|
||||||
|
wgt.Wait()
|
||||||
|
basicInfo := systemInfo + ipInfo
|
||||||
if strings.Contains(ipInfo, "IPV4") && strings.Contains(ipInfo, "IPV6") {
|
if strings.Contains(ipInfo, "IPV4") && strings.Contains(ipInfo, "IPV6") {
|
||||||
uts.IPV4 = true
|
uts.IPV4 = true
|
||||||
uts.IPV6 = true
|
uts.IPV6 = true
|
||||||
@@ -69,11 +82,8 @@ func securityCheck() string {
|
|||||||
} else if nt3CheckType == "ipv6" && !strings.Contains(ipInfo, "IPV6") && strings.Contains(ipInfo, "IPV4") {
|
} else if nt3CheckType == "ipv6" && !strings.Contains(ipInfo, "IPV6") && strings.Contains(ipInfo, "IPV4") {
|
||||||
nt3CheckType = "ipv4"
|
nt3CheckType = "ipv4"
|
||||||
}
|
}
|
||||||
return securityInfo
|
basicInfo = strings.ReplaceAll(basicInfo, "\n\n", "\n")
|
||||||
}
|
return basicInfo, securityInfo
|
||||||
|
|
||||||
func mediatest(language string) string {
|
|
||||||
return unlocktest.MediaTest(language)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func printHead() {
|
func printHead() {
|
||||||
@@ -96,7 +106,7 @@ func main() {
|
|||||||
flag.BoolVar(&showVersion, "v", false, "Show version information")
|
flag.BoolVar(&showVersion, "v", false, "Show version information")
|
||||||
flag.StringVar(&language, "l", "zh", "Specify language (supported: en, zh)")
|
flag.StringVar(&language, "l", "zh", "Specify language (supported: en, zh)")
|
||||||
flag.StringVar(&cpuTestMethod, "cpum", "sysbench", "Specify CPU test method (supported: sysbench, geekbench, winsat)")
|
flag.StringVar(&cpuTestMethod, "cpum", "sysbench", "Specify CPU test method (supported: sysbench, geekbench, winsat)")
|
||||||
flag.StringVar(&cpuTestThread, "cput", "", "Specify CPU test thread count (supported: 1, 2, ...)")
|
flag.StringVar(&cpuTestThreadMode, "cput", "multi", "Specify CPU test thread mode (supported: single multi)")
|
||||||
flag.StringVar(&memoryTestMethod, "memorym", "dd", "Specify Memory test method (supported: sysbench, dd, winsat)")
|
flag.StringVar(&memoryTestMethod, "memorym", "dd", "Specify Memory test method (supported: sysbench, dd, winsat)")
|
||||||
flag.StringVar(&diskTestMethod, "diskm", "fio", "Specify Disk test method (supported: fio, dd, winsat)")
|
flag.StringVar(&diskTestMethod, "diskm", "fio", "Specify Disk test method (supported: fio, dd, winsat)")
|
||||||
flag.StringVar(&diskTestPath, "diskp", "", "Specify Disk test path, example: -diskp /root")
|
flag.StringVar(&diskTestPath, "diskp", "", "Specify Disk test path, example: -diskp /root")
|
||||||
@@ -111,23 +121,14 @@ func main() {
|
|||||||
}
|
}
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
var securityInfo, emailInfo, mediaInfo string
|
var basicInfo, securityInfo, emailInfo, mediaInfo string
|
||||||
if language == "zh" {
|
if language == "zh" {
|
||||||
printHead()
|
printHead()
|
||||||
printCenteredTitle("基础信息", width)
|
printCenteredTitle("基础信息", width)
|
||||||
go func() {
|
basicInfo, securityInfo = securityCheck()
|
||||||
wg.Add(1)
|
fmt.Println(basicInfo)
|
||||||
defer wg.Done()
|
|
||||||
basic.Basic(language)
|
|
||||||
}()
|
|
||||||
go func() {
|
|
||||||
wg.Add(1)
|
|
||||||
defer wg.Done()
|
|
||||||
securityInfo = securityCheck()
|
|
||||||
}()
|
|
||||||
wg.Wait()
|
|
||||||
printCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", cpuTestMethod), width)
|
printCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", cpuTestMethod), width)
|
||||||
cputest.CpuTest(language, cpuTestMethod, cpuTestThread)
|
cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode)
|
||||||
printCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", cpuTestMethod), width)
|
printCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", cpuTestMethod), width)
|
||||||
memorytest.MemoryTest(language, memoryTestMethod)
|
memorytest.MemoryTest(language, memoryTestMethod)
|
||||||
printCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", diskTestMethod), width)
|
printCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", diskTestMethod), width)
|
||||||
@@ -140,7 +141,7 @@ func main() {
|
|||||||
go func() {
|
go func() {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
mediaInfo = mediatest(language)
|
mediaInfo = unlocktest.MediaTest(language)
|
||||||
}()
|
}()
|
||||||
printCenteredTitle("御三家流媒体解锁", width)
|
printCenteredTitle("御三家流媒体解锁", width)
|
||||||
commediatest.ComMediaTest(language)
|
commediatest.ComMediaTest(language)
|
||||||
@@ -180,16 +181,12 @@ func main() {
|
|||||||
go func() {
|
go func() {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
basic.Basic(language)
|
basicInfo, securityInfo = securityCheck()
|
||||||
}()
|
|
||||||
go func() {
|
|
||||||
wg.Add(1)
|
|
||||||
defer wg.Done()
|
|
||||||
securityInfo = securityCheck()
|
|
||||||
}()
|
}()
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
fmt.Printf(basicInfo)
|
||||||
printCenteredTitle(fmt.Sprintf("CPU Test - %s Method", cpuTestMethod), width)
|
printCenteredTitle(fmt.Sprintf("CPU Test - %s Method", cpuTestMethod), width)
|
||||||
cputest.CpuTest(language, cpuTestMethod, cpuTestThread)
|
cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode)
|
||||||
printCenteredTitle(fmt.Sprintf("Memory Test - %s Method", memoryTestMethod), width)
|
printCenteredTitle(fmt.Sprintf("Memory Test - %s Method", memoryTestMethod), width)
|
||||||
memorytest.MemoryTest(language, memoryTestMethod)
|
memorytest.MemoryTest(language, memoryTestMethod)
|
||||||
printCenteredTitle(fmt.Sprintf("Disk Test - %s Method", diskTestMethod), width)
|
printCenteredTitle(fmt.Sprintf("Disk Test - %s Method", diskTestMethod), width)
|
||||||
|
Reference in New Issue
Block a user