github.com/xmplusdev/xray-core@v1.8.10/main/commands/all/api/stats_sys.go (about)

     1  package api
     2  
     3  import (
     4  	statsService "github.com/xmplusdev/xray-core/app/stats/command"
     5  	"github.com/xmplusdev/xray-core/main/commands/base"
     6  )
     7  
     8  var cmdSysStats = &base.Command{
     9  	CustomFlags: true,
    10  	UsageLine:   "{{.Exec}} api statssys [--server=127.0.0.1:8080]",
    11  	Short:       "Get system statistics",
    12  	Long: `
    13  Get system statistics from Xray.
    14  Arguments:
    15  	-s, -server 
    16  		The API server address. Default 127.0.0.1:8080
    17  	-t, -timeout
    18  		Timeout seconds to call API. Default 3
    19  `,
    20  	Run: executeSysStats,
    21  }
    22  
    23  func executeSysStats(cmd *base.Command, args []string) {
    24  	setSharedFlags(cmd)
    25  	cmd.Flag.Parse(args)
    26  
    27  	conn, ctx, close := dialAPIServer()
    28  	defer close()
    29  
    30  	client := statsService.NewStatsServiceClient(conn)
    31  	r := &statsService.SysStatsRequest{}
    32  	resp, err := client.GetSysStats(ctx, r)
    33  	if err != nil {
    34  		base.Fatalf("failed to get sys stats: %s", err)
    35  	}
    36  	showJSONResponse(resp)
    37  }