Add fs status for Windows containers
This commit is contained in:
parent
9a7ff8dbe5
commit
196381c039
@ -26,6 +26,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type cadvisorClient struct {
|
type cadvisorClient struct {
|
||||||
|
rootPath string
|
||||||
winStatsClient winstats.Client
|
winStatsClient winstats.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +35,10 @@ var _ Interface = new(cadvisorClient)
|
|||||||
// New creates a cAdvisor and exports its API on the specified port if port > 0.
|
// New creates a cAdvisor and exports its API on the specified port if port > 0.
|
||||||
func New(address string, port uint, imageFsInfoProvider ImageFsInfoProvider, rootPath string, usingLegacyStats bool) (Interface, error) {
|
func New(address string, port uint, imageFsInfoProvider ImageFsInfoProvider, rootPath string, usingLegacyStats bool) (Interface, error) {
|
||||||
client, err := winstats.NewPerfCounterClient()
|
client, err := winstats.NewPerfCounterClient()
|
||||||
return &cadvisorClient{winStatsClient: client}, err
|
return &cadvisorClient{
|
||||||
|
rootPath: rootPath,
|
||||||
|
winStatsClient: client,
|
||||||
|
}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cu *cadvisorClient) Start() error {
|
func (cu *cadvisorClient) Start() error {
|
||||||
@ -70,7 +74,7 @@ func (cu *cadvisorClient) ImagesFsInfo() (cadvisorapiv2.FsInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cu *cadvisorClient) RootFsInfo() (cadvisorapiv2.FsInfo, error) {
|
func (cu *cadvisorClient) RootFsInfo() (cadvisorapiv2.FsInfo, error) {
|
||||||
return cadvisorapiv2.FsInfo{}, nil
|
return cu.GetDirFsInfo(cu.rootPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cu *cadvisorClient) WatchEvents(request *events.Request) (*events.EventChannel, error) {
|
func (cu *cadvisorClient) WatchEvents(request *events.Request) (*events.EventChannel, error) {
|
||||||
|
@ -64,6 +64,11 @@ func (ds *dockerService) ListContainerStats(ctx context.Context, r *runtimeapi.L
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ds *dockerService) getContainerStats(containerID string) (*runtimeapi.ContainerStats, error) {
|
func (ds *dockerService) getContainerStats(containerID string) (*runtimeapi.ContainerStats, error) {
|
||||||
|
info, err := ds.client.Info()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
statsJSON, err := ds.client.GetContainerStats(containerID)
|
statsJSON, err := ds.client.GetContainerStats(containerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -101,6 +106,7 @@ func (ds *dockerService) getContainerStats(containerID string) (*runtimeapi.Cont
|
|||||||
},
|
},
|
||||||
WritableLayer: &runtimeapi.FilesystemUsage{
|
WritableLayer: &runtimeapi.FilesystemUsage{
|
||||||
Timestamp: timestamp,
|
Timestamp: timestamp,
|
||||||
|
FsId: &runtimeapi.FilesystemIdentifier{Mountpoint: info.DockerRootDir},
|
||||||
UsedBytes: &runtimeapi.UInt64Value{Value: uint64(*containerJSON.SizeRw)},
|
UsedBytes: &runtimeapi.UInt64Value{Value: uint64(*containerJSON.SizeRw)},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user