cadvisor_windows.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // +build windows
  2. /*
  3. Copyright 2015 The Kubernetes Authors.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. */
  14. package cadvisor
  15. import (
  16. "github.com/google/cadvisor/events"
  17. cadvisorapi "github.com/google/cadvisor/info/v1"
  18. cadvisorapiv2 "github.com/google/cadvisor/info/v2"
  19. "k8s.io/kubernetes/pkg/kubelet/winstats"
  20. )
  21. type cadvisorClient struct {
  22. rootPath string
  23. winStatsClient winstats.Client
  24. }
  25. var _ Interface = new(cadvisorClient)
  26. // New creates a cAdvisor and exports its API on the specified port if port > 0.
  27. func New(imageFsInfoProvider ImageFsInfoProvider, rootPath string, cgroupRoots []string, usingLegacyStats bool) (Interface, error) {
  28. client, err := winstats.NewPerfCounterClient()
  29. return &cadvisorClient{
  30. rootPath: rootPath,
  31. winStatsClient: client,
  32. }, err
  33. }
  34. func (cu *cadvisorClient) Start() error {
  35. return nil
  36. }
  37. func (cu *cadvisorClient) DockerContainer(name string, req *cadvisorapi.ContainerInfoRequest) (cadvisorapi.ContainerInfo, error) {
  38. return cadvisorapi.ContainerInfo{}, nil
  39. }
  40. func (cu *cadvisorClient) ContainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) {
  41. return &cadvisorapi.ContainerInfo{}, nil
  42. }
  43. func (cu *cadvisorClient) ContainerInfoV2(name string, options cadvisorapiv2.RequestOptions) (map[string]cadvisorapiv2.ContainerInfo, error) {
  44. return cu.winStatsClient.WinContainerInfos()
  45. }
  46. func (cu *cadvisorClient) SubcontainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (map[string]*cadvisorapi.ContainerInfo, error) {
  47. return nil, nil
  48. }
  49. func (cu *cadvisorClient) MachineInfo() (*cadvisorapi.MachineInfo, error) {
  50. return cu.winStatsClient.WinMachineInfo()
  51. }
  52. func (cu *cadvisorClient) VersionInfo() (*cadvisorapi.VersionInfo, error) {
  53. return cu.winStatsClient.WinVersionInfo()
  54. }
  55. func (cu *cadvisorClient) ImagesFsInfo() (cadvisorapiv2.FsInfo, error) {
  56. return cadvisorapiv2.FsInfo{}, nil
  57. }
  58. func (cu *cadvisorClient) RootFsInfo() (cadvisorapiv2.FsInfo, error) {
  59. return cu.GetDirFsInfo(cu.rootPath)
  60. }
  61. func (cu *cadvisorClient) WatchEvents(request *events.Request) (*events.EventChannel, error) {
  62. return &events.EventChannel{}, nil
  63. }
  64. func (cu *cadvisorClient) GetDirFsInfo(path string) (cadvisorapiv2.FsInfo, error) {
  65. return cu.winStatsClient.GetDirFsInfo(path)
  66. }