github.com/djenriquez/nomad-1@v0.8.1/client/client_stats_endpoint.go (about) 1 package client 2 3 import ( 4 "time" 5 6 metrics "github.com/armon/go-metrics" 7 "github.com/hashicorp/nomad/client/structs" 8 nstructs "github.com/hashicorp/nomad/nomad/structs" 9 ) 10 11 // ClientStats endpoint is used for retrieving stats about a client 12 type ClientStats struct { 13 c *Client 14 } 15 16 // Stats is used to retrieve the Clients stats. 17 func (s *ClientStats) Stats(args *nstructs.NodeSpecificRequest, reply *structs.ClientStatsResponse) error { 18 defer metrics.MeasureSince([]string{"client", "client_stats", "stats"}, time.Now()) 19 20 // Check node read permissions 21 if aclObj, err := s.c.ResolveToken(args.AuthToken); err != nil { 22 return err 23 } else if aclObj != nil && !aclObj.AllowNodeRead() { 24 return nstructs.ErrPermissionDenied 25 } 26 27 clientStats := s.c.StatsReporter() 28 reply.HostStats = clientStats.LatestHostStats() 29 return nil 30 }