Compare commits

..

41 Commits

Author SHA1 Message Date
spiritysdx
a9df37f216 update 2024-07-02 22:12:57 +08:00
spiritysdx
60bec3d46c update 2024-07-02 22:10:44 +08:00
spiritysdx
3c1e1f19c4 update 2024-07-02 21:50:39 +08:00
spiritysdx
207d8ff746 update 2024-07-02 21:32:17 +08:00
spiritysdx
835dc7a0fd update 2024-07-02 20:10:49 +08:00
spiritysdx
cdfb956211 update 2024-07-02 16:22:01 +08:00
spiritysdx
d5ba31e5d7 update 2024-07-02 15:21:36 +08:00
spiritysdx
e80ec4f063 update 2024-07-02 14:14:37 +08:00
spiritysdx
cdb8d8681e update 2024-07-02 11:35:51 +08:00
spiritysdx
d6d0abeb1c update 2024-07-02 11:33:31 +08:00
spiritysdx
9565248f95 update 2024-07-02 11:20:34 +08:00
spiritysdx
1d6cd5984b update 2024-07-02 00:18:59 +08:00
spiritysdx
63b857c915 update 2024-07-01 19:46:16 +08:00
spiritysdx
6811f19db4 update 2024-07-01 19:38:06 +08:00
spiritysdx
847e1c0d6e update 2024-07-01 18:40:23 +08:00
spiritysdx
99a8448d53 update 2024-07-01 18:38:16 +08:00
spiritysdx
4fe9cd21ef update 2024-07-01 18:31:21 +08:00
spiritysdx
bdb53ac436 update 2024-07-01 18:26:09 +08:00
spiritysdx
01b9ee4505 update 2024-07-01 18:13:57 +08:00
spiritysdx
fadbf9c6aa update 2024-07-01 17:59:40 +08:00
spiritysdx
60e235e4d7 update 2024-07-01 17:59:24 +08:00
spiritysdx
da4b431761 update 2024-07-01 17:48:40 +08:00
spiritysdx
7fff30521e update 2024-07-01 17:46:33 +08:00
spiritysdx
e7c78774ca update 2024-07-01 17:43:35 +08:00
spiritysdx
fb6f9da14c update 2024-07-01 17:40:45 +08:00
spiritysdx
7b1773c5f0 update 2024-07-01 17:40:08 +08:00
spiritysdx
7b15a74448 update 2024-07-01 17:33:09 +08:00
spiritysdx
956f65941e update 2024-07-01 17:15:27 +08:00
spiritysdx
6d1f806e94 update 2024-07-01 17:04:37 +08:00
spiritysdx
d727d6b778 update 2024-07-01 16:58:02 +08:00
spiritysdx
ea891861b3 update 2024-07-01 16:40:35 +08:00
spiritysdx
e0826a80c8 update 2024-07-01 16:38:45 +08:00
spiritysdx
74868a918e update 2024-07-01 16:34:36 +08:00
spiritysdx
889ecee3f3 update 2024-07-01 16:32:36 +08:00
spiritysdx
f6dd0bbb56 update 2024-07-01 15:03:54 +08:00
spiritysdx
01686f3e9d update 2024-07-01 13:44:03 +08:00
spiritysdx
5a6cd7d671 update 2024-07-01 13:31:44 +08:00
spiritysdx
35e183b640 update 2024-07-01 13:14:49 +08:00
spiritysdx
a684052966 update 2024-07-01 12:29:18 +08:00
spiritysdx
2beb74c319 update 2024-07-01 12:22:39 +08:00
spiritysdx
5218c95162 update 2024-07-01 12:10:56 +08:00
7 changed files with 389 additions and 204 deletions

138
README.md
View File

@@ -25,6 +25,140 @@ Shell版本 https://github.com/spiritLHLS/ecs
- [ ] 测试三网Ping值[借鉴[ecsspeed](https://github.com/spiritLHLS/ecsspeed)的逻辑二次开发]
## 说明
## Linux/macOS上使用的说明
开发中,勿要使用
开发中,勿要使用
下载脚本
```
curl -L https://raw.githubusercontent.com/oneclickvirt/ecs/master/goecs.sh -o goecs.sh && chmod +x goecs.sh
```
```
curl -L https://cdn.spiritlhl.net/https://raw.githubusercontent.com/oneclickvirt/ecs/master/goecs.sh -o goecs.sh && chmod +x goecs.sh
```
安装环境
```
./goecs.sh env
```
安装goecs
```
./goecs.sh install
```
升级goecs
```
./goecs.sh upgrade
```
卸载goecs
```
./goecs.sh delete
```
shell脚本的说明
```
Available commands:
./goecs.sh env Check and Install package:
tar (Almost all unix-like systems have it.)
unzip (Almost all unix-like systems have it.)
dd (Almost all unix-like systems have it.)
fio (Almost all unix-like systems can be installed through the system's package manager.)
sysbench (Almost all unix-like systems can be installed through the system's package manager.)
geekbench (geekbench5)(Only support IPV4 environment, and memory greater than 1GB network detection, only support amd64 and arm64 architecture.)
speedtest (Use the officially provided binaries for more accurate test results.)
In fact, sysbench/geekbench is the only one of the above dependencies that must be installed, without which the CPU score cannot be tested.
./goecs.sh install Install goecs command
./goecs.sh upgrade Upgrade goecs command
./goecs.sh delete Uninstall goecs command
./goecs.sh help Show this message
```
goecs唤起菜单
```
goecs
```
```
./goecs
```
goecs命令参数化
```
Usage: goecs [options]
-backtrace
Enable/Disable backtrace test (in 'en' language or on windows it always false) (default true)
-basic
Enable/Disable basic test (default true)
-comm
Enable/Disable common media test (default true)
-cpu
Enable/Disable CPU test (default true)
-cpum string
Set CPU test method (supported: sysbench, geekbench, winsat) (default "sysbench")
-cput string
Set CPU test thread mode (supported: single, multi) (default "multi")
-disk
Enable/Disable disk test (default true)
-diskm string
Set disk test method (supported: fio, dd, winsat) (default "fio")
-diskmc
Enable/Disable multiple disk checks, e.g., -diskmc=false
-diskp string
Set disk test path, e.g., -diskp /root
-email
Enable/Disable email port test (default true)
-h Show help information
-l string
Set language (supported: en, zh) (default "zh")
-log
Enable/Disable logging in the current path
-memory
Enable/Disable memory test (default true)
-memorym string
Set memory test method (supported: sysbench, dd, winsat) (default "dd")
-menu
Enable/Disable menu mode, disable example: -menu=false (default true)
-nt3
Enable/Disable NT3 test (in 'en' language or on windows it always false) (default true)
-nt3loc string
Specify NT3 test location (supported: GZ, SH, BJ, CD for Guangzhou, Shanghai, Beijing, Chengdu) (default "GZ")
-nt3t string
Set NT3 test type (supported: both, ipv4, ipv6) (default "ipv4")
-security
Enable/Disable security test (default true)
-speed
Enable/Disable speed test (default true)
-spnum int
Set the number of servers per operator for speed test (default 2)
-ut
Enable/Disable unlock media test (default true)
-v Display version information
```
## Windows上使用的说明
下载带exe文件的压缩文件
https://github.com/oneclickvirt/ecs/releases
找其中最新的版本,按照对应架构下载对应的 .tar.gz 文件解压后文件夹内有一个exe文件
选择该exe文件右键点击选择管理员模式运行(非管理员模式运行无法进行硬件测试),唤起菜单自选
windows测试无需进行环境安装

20
go.mod
View File

@@ -4,19 +4,19 @@ go 1.22.4
require (
github.com/imroc/req/v3 v3.43.7
github.com/oneclickvirt/CommonMediaTests v0.0.2-20240630023003
github.com/oneclickvirt/CommonMediaTests v0.0.3-20240702073302
github.com/oneclickvirt/UnlockTests v0.0.10-20240630044930
github.com/oneclickvirt/backtrace v0.0.4-20240624090335
github.com/oneclickvirt/basics v0.0.3-20240625075226
github.com/oneclickvirt/cputest v0.0.7-20240701020012
github.com/oneclickvirt/backtrace v0.0.4-20240702140722
github.com/oneclickvirt/basics v0.0.5-20240702055351
github.com/oneclickvirt/cputest v0.0.8-20240702070215
github.com/oneclickvirt/defaultset v0.0.2-20240624082446
github.com/oneclickvirt/disktest v0.0.3-20240629152513
github.com/oneclickvirt/gostun v0.0.2-20240625025941
github.com/oneclickvirt/memorytest v0.0.1-20240624151629
github.com/oneclickvirt/nt3 v0.0.2-20240630152642
github.com/oneclickvirt/disktest v0.0.4-20240702071738
github.com/oneclickvirt/gostun v0.0.3-20240702054621
github.com/oneclickvirt/memorytest v0.0.2-20240702031042
github.com/oneclickvirt/nt3 v0.0.3-20240702132013
github.com/oneclickvirt/portchecker v0.0.1-20240624155429
github.com/oneclickvirt/security v0.0.2-20240630142358
github.com/oneclickvirt/speedtest v0.0.6-20240630114816
github.com/oneclickvirt/security v0.0.4-20240702055848
github.com/oneclickvirt/speedtest v0.0.6-20240702134926
)
require (

40
go.sum
View File

@@ -75,32 +75,32 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/nxtrace/NTrace-core v1.3.1 h1:f4z5UaZEuhUP/g6xElpZ2bo+guWITJVrMKrJTqd27oc=
github.com/nxtrace/NTrace-core v1.3.1/go.mod h1:0Px/Zc60qk6cssmP+yv4kstFxvX9sXqDduoVqBO+qf8=
github.com/oneclickvirt/CommonMediaTests v0.0.2-20240630023003 h1:8jQFqDK5m7V9xlLBk8rSUYDyi3u5xzf5kqwEx5b+/7g=
github.com/oneclickvirt/CommonMediaTests v0.0.2-20240630023003/go.mod h1:DAmFPRjFV5p9fEzUUSml5jJGn2f1NZJQCzTxITHDjc4=
github.com/oneclickvirt/CommonMediaTests v0.0.3-20240702073302 h1:JbgWWVL6WR44H/dqpBLdet0M7lM/YrnwGEG40FmawRo=
github.com/oneclickvirt/CommonMediaTests v0.0.3-20240702073302/go.mod h1:DAmFPRjFV5p9fEzUUSml5jJGn2f1NZJQCzTxITHDjc4=
github.com/oneclickvirt/UnlockTests v0.0.10-20240630044930 h1:/Sc4Eas1Pso18ak93wlazkuMKRRElCntITja/0opOpM=
github.com/oneclickvirt/UnlockTests v0.0.10-20240630044930/go.mod h1:HP3CvAS+AJWxxY+BVbxIOlvaQ87YOSge89vAMG52b5o=
github.com/oneclickvirt/backtrace v0.0.4-20240624090335 h1:0LP5KyA6GLlqQAtOF0uyBSAykHJrzOA96Eb87qUhGQw=
github.com/oneclickvirt/backtrace v0.0.4-20240624090335/go.mod h1:zvsC7xY/WZqs5KL2JB967OVnuqjNbxu9bW6wXRLo5h8=
github.com/oneclickvirt/basics v0.0.3-20240625075226 h1:K9VriCHIYnXPZXBSn9PRQX+jBS6AIFH8tBVb/i8VGAw=
github.com/oneclickvirt/basics v0.0.3-20240625075226/go.mod h1:dTB+/oyFQYfTYX55rFJVWatum5F9g62zjfmHCM6Vj1s=
github.com/oneclickvirt/cputest v0.0.7-20240701020012 h1:U5cCI+6ZU3pudoAlmb1b3yB9IQNm5AnDXi1TQAZJCIA=
github.com/oneclickvirt/cputest v0.0.7-20240701020012/go.mod h1:MmaHN9+XMntI3rLycwj8Ne31fG18IfNoa8N2utDK1CY=
github.com/oneclickvirt/backtrace v0.0.4-20240702140722 h1:UJ/VWf+ZbhGarc9HcHMIyenpmX+b2LxkXu0hlLk3Gxs=
github.com/oneclickvirt/backtrace v0.0.4-20240702140722/go.mod h1:zvsC7xY/WZqs5KL2JB967OVnuqjNbxu9bW6wXRLo5h8=
github.com/oneclickvirt/basics v0.0.5-20240702055351 h1:Ez9iLNAr+A8AA3EdcDh1aB/XVSWjwSKjhgMUySkcSSY=
github.com/oneclickvirt/basics v0.0.5-20240702055351/go.mod h1:CjcPkpy/ClTgrwB6YJtBi//lvseHAWYmsbTrOOm+zCs=
github.com/oneclickvirt/cputest v0.0.8-20240702070215 h1:CcFpyVPlQkJ6vjFP17BRuJhh/afiJhOhZ0BW+TtfVDg=
github.com/oneclickvirt/cputest v0.0.8-20240702070215/go.mod h1:MmaHN9+XMntI3rLycwj8Ne31fG18IfNoa8N2utDK1CY=
github.com/oneclickvirt/defaultset v0.0.2-20240624082446 h1:5Pg3mK/u/vQvSz7anu0nxzrNdELi/AcDAU1mMsmPzyc=
github.com/oneclickvirt/defaultset v0.0.2-20240624082446/go.mod h1:e9Jt4tf2sbemCtc84/XgKcHy9EZ2jkc5x2sW1NiJS+E=
github.com/oneclickvirt/disktest v0.0.3-20240629152513 h1:ZW7MBMd2HxQi1ktg/ztVI2A10JzF4ZI6I7ATZvcK9w8=
github.com/oneclickvirt/disktest v0.0.3-20240629152513/go.mod h1:x7VAJF0Ks05FyE4BI5xedXNKmwbeXfp8GCRALAIlueI=
github.com/oneclickvirt/gostun v0.0.2-20240625025941 h1:h+ZL8jkjXR6QE0qEX34FjWTv89+lNj2fEkWx5Agpgzc=
github.com/oneclickvirt/gostun v0.0.2-20240625025941/go.mod h1:f7DPEXAxbmwXSW33dbxtb0/KzqvOBWhTs2Or5xBerQA=
github.com/oneclickvirt/memorytest v0.0.1-20240624151629 h1:2rJAB3gFGlFPocIb/WRVWYqs4nr2jGYokfDOgqFicD4=
github.com/oneclickvirt/memorytest v0.0.1-20240624151629/go.mod h1:+YNzy+NeVg61d0kNwSyVDqHyVtKzjuRe1NvMzsDLg0I=
github.com/oneclickvirt/nt3 v0.0.2-20240630152642 h1:BkpR1j9JaDxMzx7iIwtsnFDxSldjYr2TUYpZE7m8z/Y=
github.com/oneclickvirt/nt3 v0.0.2-20240630152642/go.mod h1:UojPmtangn17TiQaDccVrZbn6sZwJOtzBgg3idp68cA=
github.com/oneclickvirt/disktest v0.0.4-20240702071738 h1:3rErTS9RwU8jAmGc8LqjtFBBd94lIk+wSWpohI55C/w=
github.com/oneclickvirt/disktest v0.0.4-20240702071738/go.mod h1:wIZy8G6Mbcy8Op8tc0HmJNpbJQQ5A15fvnUqMJXIdO0=
github.com/oneclickvirt/gostun v0.0.3-20240702054621 h1:IE89eEYV9TJbF94SakQDAxTLIaqX+Tb6ZhJ/CCIP+90=
github.com/oneclickvirt/gostun v0.0.3-20240702054621/go.mod h1:f7DPEXAxbmwXSW33dbxtb0/KzqvOBWhTs2Or5xBerQA=
github.com/oneclickvirt/memorytest v0.0.2-20240702031042 h1:j+LsjOh5glYiidqtSqjZJRw694LYW1PHLMh6AovluTQ=
github.com/oneclickvirt/memorytest v0.0.2-20240702031042/go.mod h1:+YNzy+NeVg61d0kNwSyVDqHyVtKzjuRe1NvMzsDLg0I=
github.com/oneclickvirt/nt3 v0.0.3-20240702132013 h1:zPI/zqqCraIVwRnYz07hMkBKDRJVkEBb6gZpZ4M9CjI=
github.com/oneclickvirt/nt3 v0.0.3-20240702132013/go.mod h1:UojPmtangn17TiQaDccVrZbn6sZwJOtzBgg3idp68cA=
github.com/oneclickvirt/portchecker v0.0.1-20240624155429 h1:+wapaOcFrg1iWJDhBKThDzppyIMY7hWxK7F5RBkZg4o=
github.com/oneclickvirt/portchecker v0.0.1-20240624155429/go.mod h1:HQxSTrqM8/QFqHMTBZ7S8H9eEO5FkUXU1eb7ZX5Mk+k=
github.com/oneclickvirt/security v0.0.2-20240630142358 h1:yioMtHuW9wbJ7payL8GCPnj1ScEqNoqbNHt3+4Z4VAg=
github.com/oneclickvirt/security v0.0.2-20240630142358/go.mod h1:cUNNOldoVQuovyc0EtAVAZlAT4y2xA1e0uA80aj1ly8=
github.com/oneclickvirt/speedtest v0.0.6-20240630114816 h1:gI2hqV0IwcvGqYzLhlt4w2oZvYhCL+73jftUuJYBsuI=
github.com/oneclickvirt/speedtest v0.0.6-20240630114816/go.mod h1:zd5ZgIGslmtQLQehEfRjyumlvgDHTpCSMchKfKXoASI=
github.com/oneclickvirt/security v0.0.4-20240702055848 h1:UCfjfoslcfKhCvJm37jQmhJ+O8d4lL+uvBJVcLAXc2s=
github.com/oneclickvirt/security v0.0.4-20240702055848/go.mod h1:YKmO3FRWjhHYJ5rKqz+1H3hB6sCA4gioik7r8GMfyqo=
github.com/oneclickvirt/speedtest v0.0.6-20240702134926 h1:1aF6O9iFZGD7iabb9BB3O8MDL9/guuXJlRdsfJMs+dI=
github.com/oneclickvirt/speedtest v0.0.6-20240702134926/go.mod h1:zd5ZgIGslmtQLQehEfRjyumlvgDHTpCSMchKfKXoASI=
github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA=
github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To=
github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk=

276
goecs.go
View File

@@ -6,6 +6,8 @@ import (
"github.com/oneclickvirt/CommonMediaTests/commediatests"
backtraceori "github.com/oneclickvirt/backtrace/bk"
basicmodel "github.com/oneclickvirt/basics/model"
cputestmodel "github.com/oneclickvirt/cputest/model"
disktestmodel "github.com/oneclickvirt/disktest/disk"
"github.com/oneclickvirt/ecs/backtrace"
"github.com/oneclickvirt/ecs/commediatest"
"github.com/oneclickvirt/ecs/cputest"
@@ -16,17 +18,22 @@ import (
"github.com/oneclickvirt/ecs/unlocktest"
"github.com/oneclickvirt/ecs/utils"
gostunmodel "github.com/oneclickvirt/gostun/model"
memorytestmodel "github.com/oneclickvirt/memorytest/memory"
nt3model "github.com/oneclickvirt/nt3/model"
"github.com/oneclickvirt/portchecker/email"
speedtestmodel "github.com/oneclickvirt/speedtest/model"
"os"
"os/signal"
"regexp"
"runtime"
"strings"
"sync"
"syscall"
"time"
)
var (
ecsVersion = "2024.07.01.1"
ecsVersion = "v0.0.31"
menuMode bool
input, choice string
showVersion bool
@@ -38,48 +45,65 @@ var (
diskMultiCheck bool
nt3CheckType, nt3Location string
spNum int
width = 84
width = 82
basicStatus, cpuTestStatus, memoryTestStatus, diskTestStatus bool
commTestStatus, utTestStatus, securityTestStatus, emailTestStatus bool
backtraceStatus, nt3Status, speedTestStatus bool
filePath = "goecs.txt"
enabelUpload = true
help bool
goecsFlag = flag.NewFlagSet("goecs", flag.ContinueOnError)
)
func main() {
flag.BoolVar(&showVersion, "v", false, "Display version information")
flag.BoolVar(&menuMode, "menu", true, "Enable/Disable menu mode, disable example: -menu=false") // true 默认启用菜单栏模式
flag.StringVar(&language, "l", "zh", "Set language (supported: en, zh)")
flag.BoolVar(&basicStatus, "basic", true, "Enable/Disable basic test")
flag.BoolVar(&cpuTestStatus, "cpu", true, "Enable/Disable CPU test")
flag.BoolVar(&memoryTestStatus, "memory", true, "Enable/Disable memory test")
flag.BoolVar(&diskTestStatus, "disk", true, "Enable/Disable disk test")
flag.BoolVar(&commTestStatus, "comm", true, "Enable/Disable common media test")
flag.BoolVar(&utTestStatus, "ut", true, "Enable/Disable unlock media test")
flag.BoolVar(&securityTestStatus, "security", true, "Enable/Disable security test")
flag.BoolVar(&emailTestStatus, "email", true, "Enable/Disable email port test")
flag.BoolVar(&backtraceStatus, "backtrace", true, "Enable/Disable backtrace test (in 'en' language or on `windows` it always false)")
flag.BoolVar(&nt3Status, "nt3", true, "Enable/Disable NT3 test (in 'en' language or on `windows` it always false)")
flag.BoolVar(&speedTestStatus, "speed", true, "Enable/Disable speed test")
flag.StringVar(&cpuTestMethod, "cpum", "sysbench", "Set CPU test method (supported: sysbench, geekbench, winsat)")
flag.StringVar(&cpuTestThreadMode, "cput", "multi", "Set CPU test thread mode (supported: single, multi)")
flag.StringVar(&memoryTestMethod, "memorym", "dd", "Set memory test method (supported: sysbench, dd, winsat)")
flag.StringVar(&diskTestMethod, "diskm", "fio", "Set disk test method (supported: fio, dd, winsat)")
flag.StringVar(&diskTestPath, "diskp", "", "Set disk test path, e.g., -diskp /root")
flag.BoolVar(&diskMultiCheck, "diskmc", false, "Enable/Disable multiple disk checks, e.g., -diskmc=false")
flag.StringVar(&nt3Location, "nt3loc", "GZ", "Specify NT3 test location (supported: GZ, SH, BJ, CD for Guangzhou, Shanghai, Beijing, Chengdu)")
flag.StringVar(&nt3CheckType, "nt3t", "ipv4", "Set NT3 test type (supported: both, ipv4, ipv6)")
flag.IntVar(&spNum, "spnum", 2, "Set the number of servers per operator for speed test")
flag.BoolVar(&enableLogger, "log", false, "Enable/Disable logging in the current path")
flag.Parse()
goecsFlag.BoolVar(&help, "h", false, "Show help information")
goecsFlag.BoolVar(&showVersion, "v", false, "Display version information")
goecsFlag.BoolVar(&menuMode, "menu", true, "Enable/Disable menu mode, disable example: -menu=false") // true 默认启用菜单栏模式
goecsFlag.StringVar(&language, "l", "zh", "Set language (supported: en, zh)")
goecsFlag.BoolVar(&basicStatus, "basic", true, "Enable/Disable basic test")
goecsFlag.BoolVar(&cpuTestStatus, "cpu", true, "Enable/Disable CPU test")
goecsFlag.BoolVar(&memoryTestStatus, "memory", true, "Enable/Disable memory test")
goecsFlag.BoolVar(&diskTestStatus, "disk", true, "Enable/Disable disk test")
goecsFlag.BoolVar(&commTestStatus, "comm", true, "Enable/Disable common media test")
goecsFlag.BoolVar(&utTestStatus, "ut", true, "Enable/Disable unlock media test")
goecsFlag.BoolVar(&securityTestStatus, "security", true, "Enable/Disable security test")
goecsFlag.BoolVar(&emailTestStatus, "email", true, "Enable/Disable email port test")
goecsFlag.BoolVar(&backtraceStatus, "backtrace", true, "Enable/Disable backtrace test (in 'en' language or on windows it always false)")
goecsFlag.BoolVar(&nt3Status, "nt3", true, "Enable/Disable NT3 test (in 'en' language or on windows it always false)")
goecsFlag.BoolVar(&speedTestStatus, "speed", true, "Enable/Disable speed test")
goecsFlag.StringVar(&cpuTestMethod, "cpum", "sysbench", "Set CPU test method (supported: sysbench, geekbench, winsat)")
goecsFlag.StringVar(&cpuTestThreadMode, "cput", "multi", "Set CPU test thread mode (supported: single, multi)")
goecsFlag.StringVar(&memoryTestMethod, "memorym", "dd", "Set memory test method (supported: sysbench, dd, winsat)")
goecsFlag.StringVar(&diskTestMethod, "diskm", "fio", "Set disk test method (supported: fio, dd, winsat)")
goecsFlag.StringVar(&diskTestPath, "diskp", "", "Set disk test path, e.g., -diskp /root")
goecsFlag.BoolVar(&diskMultiCheck, "diskmc", false, "Enable/Disable multiple disk checks, e.g., -diskmc=false")
goecsFlag.StringVar(&nt3Location, "nt3loc", "GZ", "Specify NT3 test location (supported: GZ, SH, BJ, CD for Guangzhou, Shanghai, Beijing, Chengdu)")
goecsFlag.StringVar(&nt3CheckType, "nt3t", "ipv4", "Set NT3 test type (supported: both, ipv4, ipv6)")
goecsFlag.IntVar(&spNum, "spnum", 2, "Set the number of servers per operator for speed test")
goecsFlag.BoolVar(&enableLogger, "log", false, "Enable/Disable logging in the current path")
goecsFlag.Parse(os.Args[1:])
if help {
fmt.Printf("Usage: %s [options]\n", os.Args[0])
goecsFlag.PrintDefaults()
return
}
sig := make(chan os.Signal, 1)
signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
if showVersion {
fmt.Println(ecsVersion)
return
}
if enableLogger {
basicmodel.EnableLoger = true
speedtestmodel.EnableLoger = true
gostunmodel.EnableLoger = true
basicmodel.EnableLoger = true
cputestmodel.EnableLoger = true
memorytestmodel.EnableLoger = true
disktestmodel.EnableLoger = true
commediatests.EnableLoger = true
backtraceori.EnableLoger = true
nt3model.EnableLoger = true
speedtestmodel.EnableLoger = true
}
if menuMode {
basicStatus, cpuTestStatus, memoryTestStatus, diskTestStatus = false, false, false, false
@@ -87,6 +111,7 @@ func main() {
backtraceStatus, nt3Status, speedTestStatus = false, false, false
switch language {
case "zh":
fmt.Println("VPS融合怪版本: ", ecsVersion)
fmt.Println("1. 融合怪完全体")
fmt.Println("2. 极简版(系统信息+CPU+内存+磁盘+测速节点5个)")
fmt.Println("3. 精简版(系统信息+CPU+内存+磁盘+御三家+常用流媒体+回程+路由+测速节点5个)")
@@ -98,6 +123,7 @@ func main() {
fmt.Println("9. IP质量检测(15个数据库的IP检测+邮件端口检测)")
fmt.Println("10. 三网回程线路+广州三网路由+全国三网延迟")
case "en":
fmt.Println("VPS Fusion Monster Test Version: ", ecsVersion)
fmt.Println("1. VPS Fusion Monster Test Comprehensive Test Suite")
fmt.Println("2. Minimal Test Suite (System Info + CPU + Memory + Disk + 5 Speed Test Nodes)")
fmt.Println("3. Standard Test Suite (System Info + CPU + Memory + Disk + Basic Unlock Tests + Common Streaming Services + 5 Speed Test Nodes)")
@@ -108,6 +134,7 @@ func main() {
fmt.Println("8. Hardware-Only Test (Basic System Info + CPU + Memory + dd Disk Test + fio Disk Test)")
fmt.Println("9. IP Quality Test (IP Test with 15 Databases + Email Port Test)")
}
Loop:
for {
fmt.Print("请输入选项 / Please enter your choice: ")
fmt.Scanln(&input)
@@ -129,14 +156,14 @@ func main() {
backtraceStatus = true
nt3Status = true
speedTestStatus = true
break
break Loop
case "2":
basicStatus = true
cpuTestStatus = true
memoryTestStatus = true
diskTestStatus = true
speedTestStatus = true
break
break Loop
case "3":
basicStatus = true
cpuTestStatus = true
@@ -148,7 +175,7 @@ func main() {
backtraceStatus = true
nt3Status = true
speedTestStatus = true
break
break Loop
case "4":
basicStatus = true
cpuTestStatus = true
@@ -157,7 +184,7 @@ func main() {
backtraceStatus = true
nt3Status = true
speedTestStatus = true
break
break Loop
case "5":
basicStatus = true
cpuTestStatus = true
@@ -165,30 +192,30 @@ func main() {
diskTestStatus = true
securityTestStatus = true
speedTestStatus = true
break
break Loop
case "6":
speedTestStatus = true
backtraceStatus = true
nt3Status = true
break
break Loop
case "7":
securityTestStatus = true
commTestStatus = true
break
break Loop
case "8":
basicStatus = true
cpuTestStatus = true
memoryTestStatus = true
diskTestStatus = true
break
break Loop
case "9":
emailTestStatus = true
break
break Loop
case "10":
backtraceStatus = true
nt3Status = true
speedTestStatus = true
break
break Loop
default:
if language == "zh" {
fmt.Println("无效的选项")
@@ -211,90 +238,105 @@ func main() {
}
startTime := time.Now()
var (
wg1, wg2, wg3 sync.WaitGroup
basicInfo, securityInfo, emailInfo, mediaInfo, backtraceInfo string
output, tempOutput string
wg1, wg2 sync.WaitGroup
basicInfo, securityInfo, emailInfo, mediaInfo string
output, tempOutput string
)
output = utils.PrintAndCapture(func() {
switch language {
case "zh":
// 启动一个goroutine来等待信号
go func() {
// 等待信号
<-sig
utils.ProcessAndUpload(output, filePath, enabelUpload)
os.Exit(1) // 使用非零状态码退出,表示意外退出
}()
switch language {
case "zh":
output = utils.PrintAndCapture(func() {
utils.PrintHead(language, width, ecsVersion)
if basicStatus || securityTestStatus {
if basicStatus {
utils.PrintCenteredTitle("基础信息", width)
utils.PrintCenteredTitle("系统基础信息", width)
}
basicInfo, securityInfo, nt3CheckType = utils.SecurityCheck(language, nt3CheckType, securityTestStatus)
if basicStatus {
fmt.Printf(basicInfo)
}
}
}, tempOutput, output)
output = utils.PrintAndCapture(func() {
if cpuTestStatus {
utils.PrintCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", cpuTestMethod), width)
cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode)
}
}, tempOutput, output)
output = utils.PrintAndCapture(func() {
if memoryTestStatus {
utils.PrintCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", cpuTestMethod), width)
memorytest.MemoryTest(language, memoryTestMethod)
}
}, tempOutput, output)
output = utils.PrintAndCapture(func() {
if diskTestStatus {
utils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", diskTestMethod), width)
disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck)
}
if emailTestStatus {
wg2.Add(1)
go func() {
defer wg1.Done()
emailInfo = email.EmailCheck()
}()
}
if utTestStatus {
wg1.Add(1)
go func() {
defer wg1.Done()
mediaInfo = unlocktest.MediaTest(language)
}()
}
if runtime.GOOS == "windows" {
if backtraceStatus {
wg3.Add(1)
go func() {
defer wg3.Done()
backtraceInfo = utils.GetCaptureOutput(func() {
backtrace.BackTrace()
})
}()
}
}
}, tempOutput, output)
if emailTestStatus {
wg2.Add(1)
go func() {
defer wg2.Done()
emailInfo = email.EmailCheck()
}()
}
if utTestStatus {
wg1.Add(1)
go func() {
defer wg1.Done()
mediaInfo = unlocktest.MediaTest(language)
}()
}
output = utils.PrintAndCapture(func() {
if commTestStatus {
utils.PrintCenteredTitle("御三家流媒体解锁", width)
commediatest.ComMediaTest(language)
}
}, tempOutput, output)
output = utils.PrintAndCapture(func() {
if utTestStatus {
utils.PrintCenteredTitle("跨国流媒体解锁", width)
wg1.Wait()
fmt.Printf(mediaInfo)
}
}, tempOutput, output)
output = utils.PrintAndCapture(func() {
if securityTestStatus {
utils.PrintCenteredTitle("IP质量检测", width)
fmt.Printf(securityInfo)
}
}, tempOutput, output)
output = utils.PrintAndCapture(func() {
if emailTestStatus {
utils.PrintCenteredTitle("邮件端口检测", width)
wg2.Wait()
fmt.Println(emailInfo)
}
if runtime.GOOS != "windows" {
}, tempOutput, output)
if runtime.GOOS != "windows" {
output = utils.PrintAndCapture(func() {
if backtraceStatus {
utils.PrintCenteredTitle("三网回程", width)
wg3.Wait()
fmt.Printf(backtraceInfo)
utils.PrintCenteredTitle("三网回程线路检测", width)
backtrace.BackTrace()
}
// nexttrace 在win上不支持检测报错 bind: An invalid argument was supplied.
}, tempOutput, output)
// nexttrace 在win上不支持检测报错 bind: An invalid argument was supplied.
output = utils.PrintAndCapture(func() {
if nt3Status {
utils.PrintCenteredTitle("路由检测", width)
utils.PrintCenteredTitle("三网回程路由检测", width)
ntrace.TraceRoute3(language, nt3Location, nt3CheckType)
}
}
}, tempOutput, output)
}
output = utils.PrintAndCapture(func() {
if speedTestStatus {
utils.PrintCenteredTitle("就近节点测速", width)
speedtest.ShowHead(language)
@@ -308,81 +350,107 @@ func main() {
speedtest.CustomSP("net", "global", 4)
}
}
}, tempOutput, output)
endTime := time.Now()
duration := endTime.Sub(startTime)
minutes := int(duration.Minutes())
seconds := int(duration.Seconds()) % 60
currentTime := time.Now().Format("Mon Jan 2 15:04:05 MST 2006")
output = utils.PrintAndCapture(func() {
utils.PrintCenteredTitle("", width)
endTime := time.Now()
duration := endTime.Sub(startTime)
minutes := int(duration.Minutes())
seconds := int(duration.Seconds()) % 60
currentTime := time.Now().Format("Mon Jan 2 15:04:05 MST 2006")
fmt.Printf("花费 : %d 分 %d 秒\n", minutes, seconds)
fmt.Printf("时间 : %s\n", currentTime)
utils.PrintCenteredTitle("", width)
case "en":
}, tempOutput, output)
case "en":
output = utils.PrintAndCapture(func() {
utils.PrintHead(language, width, ecsVersion)
if basicStatus || securityTestStatus {
if basicStatus {
utils.PrintCenteredTitle("Basic Information", width)
utils.PrintCenteredTitle("System Basic Information", width)
}
basicInfo, securityInfo, nt3CheckType = utils.SecurityCheck(language, nt3CheckType, securityTestStatus)
if basicStatus {
fmt.Printf(basicInfo)
}
}
}, tempOutput, output)
output = utils.PrintAndCapture(func() {
if cpuTestStatus {
utils.PrintCenteredTitle(fmt.Sprintf("CPU Test - %s Method", cpuTestMethod), width)
cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode)
}
}, tempOutput, output)
output = utils.PrintAndCapture(func() {
if memoryTestStatus {
utils.PrintCenteredTitle(fmt.Sprintf("Memory Test - %s Method", memoryTestMethod), width)
memorytest.MemoryTest(language, memoryTestMethod)
}
}, tempOutput, output)
output = utils.PrintAndCapture(func() {
if diskTestStatus {
utils.PrintCenteredTitle(fmt.Sprintf("Disk Test - %s Method", diskTestMethod), width)
disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck)
}
if emailTestStatus {
wg1.Add(1)
go func() {
defer wg1.Done()
emailInfo = email.EmailCheck()
}()
}
}, tempOutput, output)
if emailTestStatus {
wg1.Add(1)
go func() {
defer wg1.Done()
emailInfo = email.EmailCheck()
}()
}
output = utils.PrintAndCapture(func() {
if commTestStatus {
utils.PrintCenteredTitle("The Three Families Streaming Media Unlock", width)
utils.PrintCenteredTitle("The Three Main Streaming Media Unlock", width)
commediatest.ComMediaTest(language)
}
}, tempOutput, output)
output = utils.PrintAndCapture(func() {
if utTestStatus {
utils.PrintCenteredTitle("Cross-Border Streaming Media Unlock", width)
unlocktest.MediaTest(language)
}
}, tempOutput, output)
output = utils.PrintAndCapture(func() {
if securityTestStatus {
utils.PrintCenteredTitle("IP Quality Check", width)
fmt.Printf(securityInfo)
}
}, tempOutput, output)
output = utils.PrintAndCapture(func() {
if emailTestStatus {
utils.PrintCenteredTitle("Email Port Check", width)
wg1.Wait()
fmt.Println(emailInfo)
}
}, tempOutput, output)
output = utils.PrintAndCapture(func() {
if speedTestStatus {
utils.PrintCenteredTitle("Nearby Node Speed Test", width)
speedtest.ShowHead(language)
speedtest.NearbySP()
speedtest.CustomSP("net", "global", -1)
}
}, tempOutput, output)
endTime := time.Now()
duration := endTime.Sub(startTime)
minutes := int(duration.Minutes())
seconds := int(duration.Seconds()) % 60
currentTime := time.Now().Format("Mon Jan 2 15:04:05 MST 2006")
output = utils.PrintAndCapture(func() {
utils.PrintCenteredTitle("", width)
endTime := time.Now()
duration := endTime.Sub(startTime)
minutes := int(duration.Minutes())
seconds := int(duration.Seconds()) % 60
currentTime := time.Now().Format("Mon Jan 2 15:04:05 MST 2006")
fmt.Printf("Cost Time : %d 分 %d 秒\n", minutes, seconds)
fmt.Printf("Current Time : %s\n", currentTime)
utils.PrintCenteredTitle("", width)
default:
fmt.Println("Unsupported language")
}
}, tempOutput, output)
filePath := "goecs.txt"
utils.ProcessAndUpload(output, filePath, true)
}, tempOutput, output)
default:
fmt.Println("Unsupported language")
}
utils.ProcessAndUpload(output, filePath, enabelUpload)
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
fmt.Println("Press Enter to exit...")
fmt.Scanln()
}
}

View File

@@ -59,17 +59,16 @@ goecs_check() {
ECS_VERSION=$(curl -m 6 -sSL "https://githubapi.spiritlhl.top/repos/oneclickvirt/ecs/releases/latest" | awk -F \" '/tag_name/{gsub(/^v/,"",$4); print $4}')
fi
# 检测原始goecs命令是否存在若存在则升级不存在则安装
version_output=$(goecs -v || ./goecs -v)
version_output=$(goecs -v command 2>/dev/null || ./goecs -v command 2>/dev/null)
if [ $? -eq 0 ]; then
extracted_version=$(echo "$version_output" | grep -oP '^v\d+(\.\d+)+')
extracted_version=$(echo "${version_output//v/}")
if [ -n "$extracted_version" ]; then
current_version=$(echo "$extracted_version" | cut -c 2-)
ecs_version=$ECS_VERSION
if [[ "$(echo -e "$current_version\n$ecs_version" | sort -V | tail -n 1)" == "$current_version" ]]; then
echo "goecs version ($current_version) is latest, no need to upgrade."
if [[ "$(echo -e "$extracted_version\n$ecs_version" | sort -V | tail -n 1)" == "$extracted_version" ]]; then
echo "goecs version ($extracted_version) is latest, no need to upgrade."
return
else
echo "goecs version ($current_version) < $ecs_version, need to upgrade, 5 seconds later will start to upgrade"
echo "goecs version ($extracted_version) < $ecs_version, need to upgrade, 5 seconds later will start to upgrade"
rm -rf /usr/bin/goecs
rm -rf goecs
fi
@@ -163,7 +162,7 @@ InstallSysbench() {
arch) pacman -S --needed --noconfirm sysbench && pacman -S --needed --noconfirm libaio && ldconfig ;;
freebsd) pkg install -y sysbench ;;
alpinelinux) echo -e "${Msg_Warning}Sysbench Module not found, installing ..." && echo -e "${Msg_Warning}SysBench Current not support Alpine Linux, Skipping..." && Var_Skip_SysBench="1" ;;
*) echo "Error: Unknown OS release: $os_release" && exit 1 ;;
*) echo "Error: Unknown OS release: $os_release" ;;
esac
}
@@ -230,7 +229,7 @@ prepare_compile_env() {
env_check() {
REGEX=("debian|astra" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch" "freebsd" "alpine" "openbsd")
RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch" "FreeBSD" "Alpine" "OpenBSD")
PACKAGE_UPDATE=("! apt-get update && apt-get --fix-broken install -y && apt-get update" "apt-get update" "yum -y update" "yum -y update" "yum -y update" "pacman -Sy" "pkg update" "apk update" "pkg_add -u")
PACKAGE_UPDATE=("apt-get update" "apt-get update" "yum -y update" "yum -y update" "yum -y update" "pacman -Sy" "pkg update" "apk update" "pkg_add -u")
PACKAGE_INSTALL=("apt-get -y install" "apt-get -y install" "yum -y install" "yum -y install" "yum -y install" "pacman -Sy --noconfirm --needed" "pkg install -y" "apk add")
PACKAGE_REMOVE=("apt-get -y remove" "apt-get -y remove" "yum -y remove" "yum -y remove" "yum -y remove" "pacman -Rsc --noconfirm" "pkg delete" "apk del")
PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "" "pkg autoremove" "apk autoremove")
@@ -245,6 +244,16 @@ env_check() {
done
cdn_urls=("https://cdn0.spiritlhl.top/" "http://cdn3.spiritlhl.net/" "http://cdn1.spiritlhl.net/" "http://cdn2.spiritlhl.net/")
check_cdn_file
_green "Update system manager."
$PACKAGE_UPDATE command 2>/dev/null
if ! command -v tar >/dev/null 2>&1; then
_green "Installing tar"
$PACKAGE_INSTALL tar
fi
if ! command -v unzip >/dev/null 2>&1; then
_green "Installing unzip"
$PACKAGE_INSTALL unzip
fi
if ! command -v dd >/dev/null 2>&1; then
_green "Installing dd"
$PACKAGE_INSTALL dd
@@ -291,16 +300,36 @@ env_check() {
echo "rm -rf /usr/bin/speedtest-go"
_blue "to uninstall speedtest and speedtest-go"
fi
if [ "$(uname -s)" = "Darwin" ]; then
echo "Detected MacOS. Installing sysbench and fio..."
brew install --force sysbench fio dd
# 有问题需要修复root环境不能brewbrew安装完毕后可能路径不在环境变量中
fi
_green "The environment is ready."
}
delete_goecs() {
rm -rf /root/goecs
rm -rf /usr/bin/goecs
}
show_help() {
cat <<"EOF"
Available commands:
env Check and Install package: dd fio sysbench geekbench5 speedtest
install Install goecs command
upgrade Upgrade goecs command
help Show this message
./goecs.sh env Check and Install package:
tar (Almost all unix-like systems have it.)
unzip (Almost all unix-like systems have it.)
dd (Almost all unix-like systems have it.)
fio (Almost all unix-like systems can be installed through the system's package manager.)
sysbench (Almost all unix-like systems can be installed through the system's package manager.)
geekbench (geekbench5)(Only support IPV4 environment, and memory greater than 1GB network detection, only support amd64 and arm64 architecture.)
speedtest (Use the officially provided binaries for more accurate test results.)
In fact, sysbench/geekbench is the only one of the above dependencies that must be installed, without which the CPU score cannot be tested.
./goecs.sh install Install goecs command
./goecs.sh upgrade Upgrade goecs command
./goecs.sh delete Uninstall goecs command
./goecs.sh help Show this message
EOF
}
@@ -315,6 +344,9 @@ case "$1" in
"install" | "upgrade")
goecs_check
;;
"delete")
delete_goecs
;;
*)
echo "No command found."
echo

View File

@@ -91,56 +91,6 @@ func SecurityCheck(language, nt3CheckType string, securtyCheckStatus bool) (stri
return basicInfo, securityInfo, nt3CheckType
}
// GetCaptureOutput 仅捕获输出不实时输出
func GetCaptureOutput(f func()) string {
// 保存旧的 stdout 和 stderr
oldStdout := os.Stdout
oldStderr := os.Stderr
// 创建管道
stdoutPipeR, stdoutPipeW, err := os.Pipe()
if err != nil {
return "Error creating stdout pipe"
}
stderrPipeR, stderrPipeW, err := os.Pipe()
if err != nil {
stdoutPipeW.Close()
stdoutPipeR.Close()
return "Error creating stderr pipe"
}
// 替换标准输出和标准错误输出为管道写入端
os.Stdout = stdoutPipeW
os.Stderr = stderrPipeW
// 恢复标准输出和标准错误输出
defer func() {
os.Stdout = oldStdout
os.Stderr = oldStderr
stdoutPipeW.Close()
stderrPipeW.Close()
}()
// 缓冲区
var stdoutBuf, stderrBuf bytes.Buffer
// 并发读取 stdout 和 stderr
done := make(chan struct{})
go func() {
io.Copy(&stdoutBuf, stdoutPipeR)
done <- struct{}{}
}()
go func() {
io.Copy(&stderrBuf, stderrPipeR)
done <- struct{}{}
}()
// 执行函数
f()
// 关闭管道写入端,让管道读取端可以读取所有数据
stdoutPipeW.Close()
stderrPipeW.Close()
// 等待两个 goroutine 完成
<-done
<-done
// 返回捕获的输出字符串
return stdoutBuf.String() + stderrBuf.String()
}
// CaptureOutput 捕获函数输出和错误输出,实时输出,并返回字符串
func CaptureOutput(f func()) string {
// 保存旧的 stdout 和 stderr
@@ -265,16 +215,16 @@ func ProcessAndUpload(output string, filePath string, enableUplaod bool) {
}
if enableUplaod {
// 获取文件的绝对路径
absPath, err := filepath.Abs(filePath)
if err != nil {
fmt.Println("Failed to get absolute file path:", err)
absPath, err2 := filepath.Abs(filePath)
if err2 != nil {
fmt.Println("Failed to get absolute file path:", err2)
return
}
// 上传文件并生成短链接
shorturl, err := UploadText(absPath)
if err != nil {
shorturl, err3 := UploadText(absPath)
if err3 != nil {
fmt.Println("Upload failed, cannot generate short URL.")
fmt.Println(err.Error())
fmt.Println(err3.Error())
return
}
fmt.Println("Upload successful, short URL:", shorturl)

View File

@@ -24,6 +24,7 @@ REM 提示用户输入版本号
set /p version="Enter the version number (e.g., v1.0.0): "
REM 创建并推送标签
:push_tag
git tag %version%
git push origin %version%
if errorlevel 1 (