mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-22 16:41:29 +00:00
38 lines
872 B
Go
38 lines
872 B
Go
package api
|
|
|
|
import (
|
|
statsService "github.com/xtls/xray-core/app/stats/command"
|
|
"github.com/xtls/xray-core/main/commands/base"
|
|
)
|
|
|
|
var cmdSysStats = &base.Command{
|
|
CustomFlags: true,
|
|
UsageLine: "{{.Exec}} api statssys [--server=127.0.0.1:8080]",
|
|
Short: "Get system statistics",
|
|
Long: `
|
|
Get system statistics from Xray.
|
|
Arguments:
|
|
-s, -server
|
|
The API server address. Default 127.0.0.1:8080
|
|
-t, -timeout
|
|
Timeout seconds to call API. Default 3
|
|
`,
|
|
Run: executeSysStats,
|
|
}
|
|
|
|
func executeSysStats(cmd *base.Command, args []string) {
|
|
setSharedFlags(cmd)
|
|
cmd.Flag.Parse(args)
|
|
|
|
conn, ctx, close := dialAPIServer()
|
|
defer close()
|
|
|
|
client := statsService.NewStatsServiceClient(conn)
|
|
r := &statsService.SysStatsRequest{}
|
|
resp, err := client.GetSysStats(ctx, r)
|
|
if err != nil {
|
|
base.Fatalf("failed to get sys stats: %s", err)
|
|
}
|
|
showJSONResponse(resp)
|
|
}
|