diff options
author | openshift-ci[bot] <75433959+openshift-ci[bot]@users.noreply.github.com> | 2021-08-04 09:56:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-04 09:56:57 +0000 |
commit | 3a922cbc99f49b996c0379a9ec90ccc47a325018 (patch) | |
tree | dab0fdf142508614c6b17cc0d277ae91c58d756a /pkg/api/handlers | |
parent | 1bc8c94409c1c9dc47b4569833af534beba9333f (diff) | |
parent | 34b28d95986a08bdd74dd89ce6647458cda75731 (diff) | |
download | podman-3a922cbc99f49b996c0379a9ec90ccc47a325018.tar.gz podman-3a922cbc99f49b996c0379a9ec90ccc47a325018.tar.bz2 podman-3a922cbc99f49b996c0379a9ec90ccc47a325018.zip |
Merge pull request #11003 from pascomnet/f_stats
stats: add a interval parameter to cli and api stats streaming
Diffstat (limited to 'pkg/api/handlers')
-rw-r--r-- | pkg/api/handlers/libpod/containers_stats.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/pkg/api/handlers/libpod/containers_stats.go b/pkg/api/handlers/libpod/containers_stats.go index 22faab71f..8a04884b0 100644 --- a/pkg/api/handlers/libpod/containers_stats.go +++ b/pkg/api/handlers/libpod/containers_stats.go @@ -3,7 +3,6 @@ package libpod import ( "encoding/json" "net/http" - "time" "github.com/containers/podman/v3/libpod" "github.com/containers/podman/v3/pkg/api/handlers/utils" @@ -16,8 +15,6 @@ import ( "github.com/sirupsen/logrus" ) -const DefaultStatsPeriod = 5 * time.Second - func StatsContainer(w http.ResponseWriter, r *http.Request) { runtime := r.Context().Value("runtime").(*libpod.Runtime) decoder := r.Context().Value("decoder").(*schema.Decoder) @@ -35,8 +32,10 @@ func StatsContainer(w http.ResponseWriter, r *http.Request) { query := struct { Containers []string `schema:"containers"` Stream bool `schema:"stream"` + Interval int `schema:"interval"` }{ - Stream: true, + Stream: true, + Interval: 5, } if err := decoder.Decode(&query, r.URL.Query()); err != nil { utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String())) @@ -48,7 +47,8 @@ func StatsContainer(w http.ResponseWriter, r *http.Request) { containerEngine := abi.ContainerEngine{Libpod: runtime} statsOptions := entities.ContainerStatsOptions{ - Stream: query.Stream, + Stream: query.Stream, + Interval: query.Interval, } // Stats will stop if the connection is closed. |