|
| 1 | +// Copyright 2015 Google Inc. All Rights Reserved. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package v2 |
| 16 | + |
| 17 | +import ( |
| 18 | + // TODO(rjnagal): Move structs from v1. |
| 19 | + "github.com/google/cadvisor/info/v1" |
| 20 | +) |
| 21 | + |
| 22 | +type Attributes struct { |
| 23 | + // Kernel version. |
| 24 | + KernelVersion string `json:"kernel_version"` |
| 25 | + |
| 26 | + // OS image being used for cadvisor container, or host image if running on host directly. |
| 27 | + ContainerOsVersion string `json:"container_os_version"` |
| 28 | + |
| 29 | + // Docker version. |
| 30 | + DockerVersion string `json:"docker_version"` |
| 31 | + |
| 32 | + // cAdvisor version. |
| 33 | + CadvisorVersion string `json:"cadvisor_version"` |
| 34 | + |
| 35 | + // The number of cores in this machine. |
| 36 | + NumCores int `json:"num_cores"` |
| 37 | + |
| 38 | + // Maximum clock speed for the cores, in KHz. |
| 39 | + CpuFrequency uint64 `json:"cpu_frequency_khz"` |
| 40 | + |
| 41 | + // The amount of memory (in bytes) in this machine |
| 42 | + MemoryCapacity int64 `json:"memory_capacity"` |
| 43 | + |
| 44 | + // The machine id |
| 45 | + MachineID string `json:"machine_id"` |
| 46 | + |
| 47 | + // The system uuid |
| 48 | + SystemUUID string `json:"system_uuid"` |
| 49 | + |
| 50 | + // Filesystems on this machine. |
| 51 | + Filesystems []v1.FsInfo `json:"filesystems"` |
| 52 | + |
| 53 | + // Disk map |
| 54 | + DiskMap map[string]v1.DiskInfo `json:"disk_map"` |
| 55 | + |
| 56 | + // Network devices |
| 57 | + NetworkDevices []v1.NetInfo `json:"network_devices"` |
| 58 | + |
| 59 | + // Machine Topology |
| 60 | + // Describes cpu/memory layout and hierarchy. |
| 61 | + Topology []v1.Node `json:"topology"` |
| 62 | +} |
| 63 | + |
| 64 | +func GetAttributes(mi *v1.MachineInfo, vi *v1.VersionInfo) Attributes { |
| 65 | + return Attributes{ |
| 66 | + KernelVersion: vi.KernelVersion, |
| 67 | + ContainerOsVersion: vi.ContainerOsVersion, |
| 68 | + DockerVersion: vi.DockerVersion, |
| 69 | + CadvisorVersion: vi.CadvisorVersion, |
| 70 | + NumCores: mi.NumCores, |
| 71 | + CpuFrequency: mi.CpuFrequency, |
| 72 | + MemoryCapacity: mi.MemoryCapacity, |
| 73 | + MachineID: mi.MachineID, |
| 74 | + SystemUUID: mi.SystemUUID, |
| 75 | + Filesystems: mi.Filesystems, |
| 76 | + DiskMap: mi.DiskMap, |
| 77 | + NetworkDevices: mi.NetworkDevices, |
| 78 | + Topology: mi.Topology, |
| 79 | + } |
| 80 | +} |
0 commit comments