only support latest and remove ring buffer

This commit is contained in:
Alex Dadgar
2016-06-12 09:32:38 -07:00
parent 1a7df4e7d2
commit 020f8b05d3
10 changed files with 34 additions and 329 deletions

View File

@@ -341,7 +341,6 @@ func (a *Agent) clientConfig() (*clientconfig.Config, error) {
conf.ConsulConfig = a.config.Consul
conf.StatsDataPoints = a.config.Client.StatsConfig.DataPoints
conf.StatsCollectionInterval = a.config.Client.StatsConfig.collectionInterval
return conf, nil

View File

@@ -1,9 +1,7 @@
package agent
import (
"fmt"
"net/http"
"strconv"
"strings"
"github.com/hashicorp/nomad/nomad/structs"
@@ -75,19 +73,13 @@ func (s *HTTPServer) ClientAllocRequest(resp http.ResponseWriter, req *http.Requ
}
allocID := tokens[0]
// Get the stats reporter
clientStats := s.agent.client.StatsReporter()
task := req.URL.Query().Get("task")
var since int
var err error
if sinceTime := req.URL.Query().Get("since"); sinceTime != "" {
since, err = strconv.Atoi(sinceTime)
if err != nil {
return nil, CodedError(400, fmt.Sprintf("can't read the since query parameter: %v", err))
}
aStats, err := clientStats.GetAllocStats(allocID)
if err != nil {
return nil, err
}
if since > 0 {
return clientStats.AllocStatsSince(allocID, task, int64(since))
}
return clientStats.LatestAllocStats(allocID, task)
task := req.URL.Query().Get("task")
return aStats.LatestAllocStats(task)
}

View File

@@ -1,12 +1,6 @@
package agent
import (
"fmt"
"net/http"
"strconv"
"github.com/hashicorp/nomad/client/stats"
)
import "net/http"
const (
invalidSinceErrPrefix = "can't read the since query parameter"
@@ -17,20 +11,6 @@ func (s *HTTPServer) ClientStatsRequest(resp http.ResponseWriter, req *http.Requ
return nil, clientNotRunning
}
var since int
var err error
ts := false
if sinceTime := req.URL.Query().Get("since"); sinceTime != "" {
ts = true
since, err = strconv.Atoi(sinceTime)
if err != nil {
return nil, CodedError(400, fmt.Sprintf("%s: %v", invalidSinceErrPrefix, err))
}
}
clientStats := s.agent.client.StatsReporter()
if ts {
return clientStats.HostStatsSince(int64(since)), nil
}
return []*stats.HostStats{clientStats.LatestHostStats()}, nil
return clientStats.LatestHostStats(), nil
}