2016-04-29 18:06:19 +00:00
|
|
|
package agent
|
|
|
|
|
2017-10-05 22:43:20 +00:00
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/hashicorp/nomad/nomad/structs"
|
|
|
|
)
|
2016-04-29 18:06:19 +00:00
|
|
|
|
2016-05-24 23:41:35 +00:00
|
|
|
func (s *HTTPServer) ClientStatsRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
2016-04-29 18:06:19 +00:00
|
|
|
if s.agent.client == nil {
|
|
|
|
return nil, clientNotRunning
|
|
|
|
}
|
2016-05-09 19:24:03 +00:00
|
|
|
|
2017-10-05 22:43:20 +00:00
|
|
|
var secret string
|
|
|
|
s.parseToken(req, &secret)
|
|
|
|
|
|
|
|
// Check node read permissions
|
|
|
|
if aclObj, err := s.agent.Client().ResolveToken(secret); err != nil {
|
|
|
|
return nil, err
|
|
|
|
} else if aclObj != nil && !aclObj.AllowNodeRead() {
|
|
|
|
return nil, structs.ErrPermissionDenied
|
|
|
|
}
|
|
|
|
|
2016-05-09 19:24:03 +00:00
|
|
|
clientStats := s.agent.client.StatsReporter()
|
2016-06-12 16:32:38 +00:00
|
|
|
return clientStats.LatestHostStats(), nil
|
2016-05-18 05:11:25 +00:00
|
|
|
}
|