2016-11-01 20:01:27 +00:00
|
|
|
// +build windows
|
|
|
|
|
|
|
|
/*
|
|
|
|
Copyright 2015 The Kubernetes Authors.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package cadvisor
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/google/cadvisor/events"
|
|
|
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
|
|
|
cadvisorapiv2 "github.com/google/cadvisor/info/v2"
|
2017-08-08 19:18:42 +00:00
|
|
|
"k8s.io/kubernetes/pkg/kubelet/winstats"
|
2016-11-01 20:01:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type cadvisorClient struct {
|
2018-05-17 06:21:49 +00:00
|
|
|
rootPath string
|
2017-08-08 19:18:42 +00:00
|
|
|
winStatsClient winstats.Client
|
2016-11-01 20:01:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var _ Interface = new(cadvisorClient)
|
|
|
|
|
|
|
|
// New creates a cAdvisor and exports its API on the specified port if port > 0.
|
2018-07-02 12:40:54 +00:00
|
|
|
func New(imageFsInfoProvider ImageFsInfoProvider, rootPath string, usingLegacyStats bool) (Interface, error) {
|
2017-08-08 19:18:42 +00:00
|
|
|
client, err := winstats.NewPerfCounterClient()
|
2018-05-17 06:21:49 +00:00
|
|
|
return &cadvisorClient{
|
|
|
|
rootPath: rootPath,
|
|
|
|
winStatsClient: client,
|
|
|
|
}, err
|
2016-11-01 20:01:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (cu *cadvisorClient) Start() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cu *cadvisorClient) DockerContainer(name string, req *cadvisorapi.ContainerInfoRequest) (cadvisorapi.ContainerInfo, error) {
|
|
|
|
return cadvisorapi.ContainerInfo{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cu *cadvisorClient) ContainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) {
|
|
|
|
return &cadvisorapi.ContainerInfo{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cu *cadvisorClient) ContainerInfoV2(name string, options cadvisorapiv2.RequestOptions) (map[string]cadvisorapiv2.ContainerInfo, error) {
|
2017-08-08 19:18:42 +00:00
|
|
|
return cu.winStatsClient.WinContainerInfos()
|
2016-11-01 20:01:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (cu *cadvisorClient) SubcontainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (map[string]*cadvisorapi.ContainerInfo, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cu *cadvisorClient) MachineInfo() (*cadvisorapi.MachineInfo, error) {
|
2017-08-08 19:18:42 +00:00
|
|
|
return cu.winStatsClient.WinMachineInfo()
|
2016-11-01 20:01:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (cu *cadvisorClient) VersionInfo() (*cadvisorapi.VersionInfo, error) {
|
2017-08-08 19:18:42 +00:00
|
|
|
return cu.winStatsClient.WinVersionInfo()
|
2016-11-01 20:01:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (cu *cadvisorClient) ImagesFsInfo() (cadvisorapiv2.FsInfo, error) {
|
|
|
|
return cadvisorapiv2.FsInfo{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cu *cadvisorClient) RootFsInfo() (cadvisorapiv2.FsInfo, error) {
|
2018-05-17 06:21:49 +00:00
|
|
|
return cu.GetDirFsInfo(cu.rootPath)
|
2016-11-01 20:01:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (cu *cadvisorClient) WatchEvents(request *events.Request) (*events.EventChannel, error) {
|
|
|
|
return &events.EventChannel{}, nil
|
|
|
|
}
|
2017-06-26 19:49:00 +00:00
|
|
|
|
2018-02-07 08:36:20 +00:00
|
|
|
func (cu *cadvisorClient) GetDirFsInfo(path string) (cadvisorapiv2.FsInfo, error) {
|
2018-02-12 05:53:52 +00:00
|
|
|
return cu.winStatsClient.GetDirFsInfo(path)
|
2017-09-07 04:28:58 +00:00
|
|
|
}
|