mirror of
https://github.com/oneclickvirt/ecs.git
synced 2025-10-05 23:37:07 +08:00
update
This commit is contained in:
0
backtrace/ecs.log
Normal file
0
backtrace/ecs.log
Normal file
@@ -3,5 +3,5 @@ package basic
|
|||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
func Test_basic(t *testing.T) {
|
func Test_basic(t *testing.T) {
|
||||||
basic()
|
Basic("zh")
|
||||||
}
|
}
|
||||||
|
@@ -11,11 +11,10 @@ import (
|
|||||||
// TODO
|
// TODO
|
||||||
// 迁移Shell的完整检测逻辑使用执行命令的方式查询,最后都失败才使用gopsutil查询
|
// 迁移Shell的完整检测逻辑使用执行命令的方式查询,最后都失败才使用gopsutil查询
|
||||||
|
|
||||||
func basic() {
|
func Basic(language string) {
|
||||||
language := "zh"
|
|
||||||
ipInfo, _, _ := network.NetworkCheck("both", false, language)
|
ipInfo, _, _ := network.NetworkCheck("both", false, language)
|
||||||
res := system.CheckSystemInfo(language)
|
res := system.CheckSystemInfo(language)
|
||||||
fmt.Println("--------------------------------------------------")
|
//fmt.Println("--------------------------------------------------")
|
||||||
fmt.Printf(strings.ReplaceAll(res+ipInfo, "\n\n", "\n"))
|
fmt.Printf(strings.ReplaceAll(res+ipInfo, "\n\n", "\n"))
|
||||||
fmt.Println("--------------------------------------------------")
|
//fmt.Println("--------------------------------------------------")
|
||||||
}
|
}
|
||||||
|
@@ -3,10 +3,33 @@ package cputest
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/oneclickvirt/cputest/cpu"
|
"github.com/oneclickvirt/cputest/cpu"
|
||||||
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func cputest() {
|
func CpuTest(language, testMethod, testThread string) {
|
||||||
//res := cpu.SysBenchTest("zh", "1")
|
var res string
|
||||||
res := cpu.WinsatTest("zh", "1")
|
if runtime.GOOS == "windows" {
|
||||||
fmt.Println(res)
|
if testMethod != "winsat" && testMethod != "" {
|
||||||
|
res = "Detected host is Windows, using Winsat for testing.\n"
|
||||||
|
}
|
||||||
|
res += cpu.WinsatTest(language, testThread)
|
||||||
|
} else {
|
||||||
|
switch testMethod {
|
||||||
|
case "sysbench":
|
||||||
|
res = cpu.SysBenchTest(language, testThread)
|
||||||
|
if res == "" {
|
||||||
|
res = "Sysbench test failed, switching to Geekbench for testing.\n"
|
||||||
|
res += cpu.GeekBenchTest(language, testThread)
|
||||||
|
}
|
||||||
|
case "geekbench":
|
||||||
|
res = cpu.GeekBenchTest(language, testThread)
|
||||||
|
if res == "" {
|
||||||
|
res = "Geekbench test failed, switching to Sysbench for testing.\n"
|
||||||
|
res += cpu.SysBenchTest(language, testThread)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
res = "Invalid test method specified.\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fmt.Print(res)
|
||||||
}
|
}
|
||||||
|
@@ -5,5 +5,5 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Test(t *testing.T) {
|
func Test(t *testing.T) {
|
||||||
cputest()
|
CpuTest("zh", "sysbench", "1")
|
||||||
}
|
}
|
||||||
|
@@ -6,19 +6,32 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func diskIoTest() {
|
func DiskTest(language, testMethod, testPath string, isMultiCheck bool) {
|
||||||
var language, res string
|
var res string
|
||||||
language = "zh"
|
|
||||||
isMultiCheck := false
|
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
res = disk.WinsatTest(language, isMultiCheck, "")
|
if testMethod != "winsat" && testMethod != "" {
|
||||||
|
res = "Detected host is Windows, using Winsat for testing.\n"
|
||||||
|
}
|
||||||
|
res = disk.WinsatTest(language, isMultiCheck, testPath)
|
||||||
} else {
|
} else {
|
||||||
res = disk.FioTest(language, isMultiCheck, "")
|
switch testMethod {
|
||||||
|
case "fio":
|
||||||
|
res = disk.FioTest(language, isMultiCheck, testPath)
|
||||||
if res == "" {
|
if res == "" {
|
||||||
res = disk.DDTest(language, isMultiCheck, "")
|
res = "Fio test failed, switching to DD for testing.\n"
|
||||||
|
res += disk.DDTest(language, isMultiCheck, testPath)
|
||||||
|
}
|
||||||
|
case "dd":
|
||||||
|
res = disk.DDTest(language, isMultiCheck, testPath)
|
||||||
|
if res == "" {
|
||||||
|
res = "DD test failed, switching to Fio for testing.\n"
|
||||||
|
res += disk.FioTest(language, isMultiCheck, testPath)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
res = "Unsupported test method specified.\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println("--------------------------------------------------")
|
//fmt.Println("--------------------------------------------------")
|
||||||
fmt.Printf(res)
|
fmt.Printf(res)
|
||||||
fmt.Println("--------------------------------------------------")
|
//fmt.Println("--------------------------------------------------")
|
||||||
}
|
}
|
||||||
|
@@ -3,5 +3,5 @@ package disktest
|
|||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
func TestDiskIoTest(t *testing.T) {
|
func TestDiskIoTest(t *testing.T) {
|
||||||
diskIoTest()
|
DiskTest("zh", "", false)
|
||||||
}
|
}
|
||||||
|
60
main.go
60
main.go
@@ -1,12 +1,60 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "github.com/oneclickvirt/ecs/defaultset"
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"github.com/oneclickvirt/ecs/basic"
|
||||||
|
"github.com/oneclickvirt/ecs/cputest"
|
||||||
|
"github.com/oneclickvirt/ecs/disktest"
|
||||||
|
"github.com/oneclickvirt/ecs/memorytest"
|
||||||
|
"strings"
|
||||||
|
"unicode/utf8"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func printCenteredTitle(title string, width int) {
|
||||||
InitLogger()
|
titleLength := utf8.RuneCountInString(title) // 计算字符串的字符数
|
||||||
defer Logger.Sync()
|
totalPadding := width - titleLength
|
||||||
Logger.Info("Start logging")
|
padding := totalPadding / 2
|
||||||
// Logger.Info("Your log message", zap.Any("key", value))
|
paddingStr := strings.Repeat("-", padding)
|
||||||
|
fmt.Println(paddingStr + title + paddingStr + strings.Repeat("-", totalPadding%2))
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var (
|
||||||
|
ecsVersion = "2024.06.25"
|
||||||
|
showVersion bool
|
||||||
|
language string
|
||||||
|
cpuTestMethod, cpuTestThread string
|
||||||
|
memoryTestMethod string
|
||||||
|
diskTestMethod, diskTestPath string
|
||||||
|
diskMultiCheck bool
|
||||||
|
width = 80
|
||||||
|
)
|
||||||
|
flag.BoolVar(&showVersion, "v", false, "Show version information")
|
||||||
|
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(&cpuTestThread, "cput", "", "Specify CPU test thread count (supported: 1, 2, ...)")
|
||||||
|
flag.StringVar(&memoryTestMethod, "memorym", "", "Specify Memory test method (supported: sysbench, dd, winsat)")
|
||||||
|
flag.StringVar(&diskTestMethod, "diskm", "", "Specify Disk test method (supported: sysbench, dd, winsat)")
|
||||||
|
flag.StringVar(&diskTestPath, "diskp", "", "Specify Disk test path, example: -diskp /root")
|
||||||
|
flag.BoolVar(&diskMultiCheck, "diskmc", false, "Enable multiple disk checks, example: -diskmc=false")
|
||||||
|
flag.Parse()
|
||||||
|
if showVersion {
|
||||||
|
fmt.Println(ecsVersion)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if language == "zh" {
|
||||||
|
printCenteredTitle("融合怪测试", width)
|
||||||
|
fmt.Printf("版本:%s\n", ecsVersion)
|
||||||
|
fmt.Println("测评频道: https://t.me/vps_reviews\nGo项目地址:https://github.com/oneclickvirt/ecs\nShell项目地址:https://github.com/spiritLHLS/ecs")
|
||||||
|
printCenteredTitle("基础信息", width)
|
||||||
|
basic.Basic(language)
|
||||||
|
printCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", cpuTestMethod), width)
|
||||||
|
cputest.CpuTest(language, cpuTestMethod, cpuTestThread)
|
||||||
|
printCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", cpuTestMethod), width)
|
||||||
|
memorytest.MemoryTest(language, memoryTestMethod)
|
||||||
|
printCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", diskTestMethod), width)
|
||||||
|
disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck)
|
||||||
|
printCenteredTitle("", width)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
7
main_test.go
Normal file
7
main_test.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func Test(t *testing.T) {
|
||||||
|
main()
|
||||||
|
}
|
@@ -6,24 +6,26 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func memorytest() {
|
func MemoryTest(language, testMethod string) {
|
||||||
var res string
|
var res string
|
||||||
language := "zh"
|
|
||||||
testMethod := ""
|
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
res = memory.WinsatTest(language)
|
if testMethod != "winsat" && testMethod != "" {
|
||||||
|
res = "Detected host is Windows, using Winsat for testing.\n"
|
||||||
|
}
|
||||||
|
res += memory.WinsatTest(language)
|
||||||
} else {
|
} else {
|
||||||
if testMethod == "sysbench" {
|
switch testMethod {
|
||||||
|
case "sysbench":
|
||||||
res = memory.SysBenchTest(language)
|
res = memory.SysBenchTest(language)
|
||||||
if res == "" {
|
if res == "" {
|
||||||
res = "sysbench test failed, switch to use dd test.\n"
|
res = "sysbench test failed, switch to use dd test.\n"
|
||||||
res += memory.DDTest(language)
|
res += memory.DDTest(language)
|
||||||
}
|
}
|
||||||
} else if testMethod == "dd" {
|
case "dd":
|
||||||
res = memory.DDTest(language)
|
res = memory.DDTest(language)
|
||||||
|
default:
|
||||||
|
res = "Unsupported test method"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println("--------------------------------------------------")
|
|
||||||
fmt.Printf(res)
|
fmt.Printf(res)
|
||||||
fmt.Println("--------------------------------------------------")
|
|
||||||
}
|
}
|
||||||
|
@@ -5,5 +5,5 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Test(t *testing.T) {
|
func Test(t *testing.T) {
|
||||||
memorytest()
|
MemoryTest("zh", "sysbench")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user