github.com/google/cadvisor@v0.49.1/info/v2/machine.go (about) 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 "time" 20 21 v1 "github.com/google/cadvisor/info/v1" 22 ) 23 24 type Attributes struct { 25 // Kernel version. 26 KernelVersion string `json:"kernel_version"` 27 28 // OS image being used for cadvisor container, or host image if running on host directly. 29 ContainerOsVersion string `json:"container_os_version"` 30 31 // Docker version. 32 DockerVersion string `json:"docker_version"` 33 34 // Docker API version. 35 DockerAPIVersion string `json:"docker_api_version"` 36 37 // cAdvisor version. 38 CadvisorVersion string `json:"cadvisor_version"` 39 40 // The number of cores in this machine. 41 NumCores int `json:"num_cores"` 42 43 // Maximum clock speed for the cores, in KHz. 44 CpuFrequency uint64 `json:"cpu_frequency_khz"` 45 46 // The amount of memory (in bytes) in this machine 47 MemoryCapacity uint64 `json:"memory_capacity"` 48 49 // The machine id 50 MachineID string `json:"machine_id"` 51 52 // The system uuid 53 SystemUUID string `json:"system_uuid"` 54 55 // HugePages on this machine. 56 HugePages []v1.HugePagesInfo `json:"hugepages"` 57 58 // Filesystems on this machine. 59 Filesystems []v1.FsInfo `json:"filesystems"` 60 61 // Disk map 62 DiskMap map[string]v1.DiskInfo `json:"disk_map"` 63 64 // Network devices 65 NetworkDevices []v1.NetInfo `json:"network_devices"` 66 67 // Machine Topology 68 // Describes cpu/memory layout and hierarchy. 69 Topology []v1.Node `json:"topology"` 70 71 // Cloud provider the machine belongs to 72 CloudProvider v1.CloudProvider `json:"cloud_provider"` 73 74 // Type of cloud instance (e.g. GCE standard) the machine is. 75 InstanceType v1.InstanceType `json:"instance_type"` 76 } 77 78 func GetAttributes(mi *v1.MachineInfo, vi *v1.VersionInfo) Attributes { 79 return Attributes{ 80 KernelVersion: vi.KernelVersion, 81 ContainerOsVersion: vi.ContainerOsVersion, 82 DockerVersion: vi.DockerVersion, 83 DockerAPIVersion: vi.DockerAPIVersion, 84 CadvisorVersion: vi.CadvisorVersion, 85 NumCores: mi.NumCores, 86 CpuFrequency: mi.CpuFrequency, 87 MemoryCapacity: mi.MemoryCapacity, 88 MachineID: mi.MachineID, 89 SystemUUID: mi.SystemUUID, 90 HugePages: mi.HugePages, 91 Filesystems: mi.Filesystems, 92 DiskMap: mi.DiskMap, 93 NetworkDevices: mi.NetworkDevices, 94 Topology: mi.Topology, 95 CloudProvider: mi.CloudProvider, 96 InstanceType: mi.InstanceType, 97 } 98 } 99 100 // MachineStats contains usage statistics for the entire machine. 101 type MachineStats struct { 102 // The time of this stat point. 103 Timestamp time.Time `json:"timestamp"` 104 // In nanoseconds (aggregated) 105 Cpu *v1.CpuStats `json:"cpu,omitempty"` 106 // In nanocores per second (instantaneous) 107 CpuInst *CpuInstStats `json:"cpu_inst,omitempty"` 108 // Memory statistics 109 Memory *v1.MemoryStats `json:"memory,omitempty"` 110 // Network statistics 111 Network *NetworkStats `json:"network,omitempty"` 112 // Filesystem statistics 113 Filesystem []MachineFsStats `json:"filesystem,omitempty"` 114 // Task load statistics 115 Load *v1.LoadStats `json:"load_stats,omitempty"` 116 } 117 118 // MachineFsStats contains per filesystem capacity and usage information. 119 type MachineFsStats struct { 120 // The block device name associated with the filesystem. 121 Device string `json:"device"` 122 123 // Type of filesystem. 124 Type string `json:"type"` 125 126 // Number of bytes that can be consumed on this filesystem. 127 Capacity *uint64 `json:"capacity,omitempty"` 128 129 // Number of bytes that is currently consumed on this filesystem. 130 Usage *uint64 `json:"usage,omitempty"` 131 132 // Number of bytes available for non-root user on this filesystem. 133 Available *uint64 `json:"available,omitempty"` 134 135 // Number of inodes that are available on this filesystem. 136 InodesFree *uint64 `json:"inodes_free,omitempty"` 137 138 // DiskStats for this device. 139 DiskStats `json:"inline"` 140 } 141 142 // DiskStats contains per partition usage information. 143 // This information is only available at the machine level. 144 type DiskStats struct { 145 // Number of reads completed 146 // This is the total number of reads completed successfully. 147 ReadsCompleted *uint64 `json:"reads_completed,omitempty"` 148 149 // Number of reads merged 150 // Reads and writes which are adjacent to each other may be merged for 151 // efficiency. Thus two 4K reads may become one 8K read before it is 152 // ultimately handed to the disk, and so it will be counted (and queued) 153 // as only one I/O. This field lets you know how often this was done. 154 ReadsMerged *uint64 `json:"reads_merged,omitempty"` 155 156 // Number of sectors read 157 // This is the total number of sectors read successfully. 158 SectorsRead *uint64 `json:"sectors_read,omitempty"` 159 160 // Time spent reading 161 // This is the total number of milliseconds spent by all reads (as 162 // measured from __make_request() to end_that_request_last()). 163 ReadDuration *time.Duration `json:"read_duration,omitempty"` 164 165 // Number of writes completed 166 // This is the total number of writes completed successfully. 167 WritesCompleted *uint64 `json:"writes_completed,omitempty"` 168 169 // Number of writes merged 170 // See the description of reads merged. 171 WritesMerged *uint64 `json:"writes_merged,omitempty"` 172 173 // Number of sectors written 174 // This is the total number of sectors written successfully. 175 SectorsWritten *uint64 `json:"sectors_written,omitempty"` 176 177 // Time spent writing 178 // This is the total number of milliseconds spent by all writes (as 179 // measured from __make_request() to end_that_request_last()). 180 WriteDuration *time.Duration `json:"write_duration,omitempty"` 181 182 // Number of I/Os currently in progress 183 // The only field that should go to zero. Incremented as requests are 184 // given to appropriate struct request_queue and decremented as they finish. 185 IoInProgress *uint64 `json:"io_in_progress,omitempty"` 186 187 // Time spent doing I/Os 188 // This field increases so long as field 9 is nonzero. 189 IoDuration *time.Duration `json:"io_duration,omitempty"` 190 191 // weighted time spent doing I/Os 192 // This field is incremented at each I/O start, I/O completion, I/O 193 // merge, or read of these stats by the number of I/Os in progress 194 // (field 9) times the number of milliseconds spent doing I/O since the 195 // last update of this field. This can provide an easy measure of both 196 // I/O completion time and the backlog that may be accumulating. 197 WeightedIoDuration *time.Duration `json:"weighted_io_duration,omitempty"` 198 }