github.com/google/cadvisor@v0.49.1/fs/types.go (about) 1 // Copyright 2014 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 fs 16 17 import ( 18 "errors" 19 ) 20 21 type Context struct { 22 // docker root directory. 23 Docker DockerContext 24 Crio CrioContext 25 Podman PodmanContext 26 } 27 28 type DockerContext struct { 29 Root string 30 Driver string 31 DriverStatus map[string]string 32 } 33 34 type PodmanContext struct { 35 Root string 36 Driver string 37 DriverStatus map[string]string 38 } 39 40 type CrioContext struct { 41 Root string 42 ImageStore string 43 Driver string 44 } 45 46 type DeviceInfo struct { 47 Device string 48 Major uint 49 Minor uint 50 } 51 52 type FsType string 53 54 func (ft FsType) String() string { 55 return string(ft) 56 } 57 58 const ( 59 ZFS FsType = "zfs" 60 DeviceMapper FsType = "devicemapper" 61 VFS FsType = "vfs" 62 NFS FsType = "nfs" 63 ) 64 65 type Fs struct { 66 DeviceInfo 67 Type FsType 68 Capacity uint64 69 Free uint64 70 Available uint64 71 Inodes *uint64 72 InodesFree *uint64 73 DiskStats DiskStats 74 } 75 76 type DiskStats struct { 77 MajorNum uint64 78 MinorNum uint64 79 ReadsCompleted uint64 80 ReadsMerged uint64 81 SectorsRead uint64 82 ReadTime uint64 83 WritesCompleted uint64 84 WritesMerged uint64 85 SectorsWritten uint64 86 WriteTime uint64 87 IoInProgress uint64 88 IoTime uint64 89 WeightedIoTime uint64 90 Major uint64 91 Minor uint64 92 } 93 94 type UsageInfo struct { 95 Bytes uint64 96 Inodes uint64 97 } 98 99 var ( 100 // ErrNoSuchDevice is the error indicating the requested device does not exist. 101 ErrNoSuchDevice = errors.New("cadvisor: no such device") 102 103 // ErrDeviceNotInPartitionsMap is the error resulting if a device could not be found in the partitions map. 104 ErrDeviceNotInPartitionsMap = errors.New("could not find device in cached partitions map") 105 ) 106 107 type FsInfo interface { 108 // Returns capacity and free space, in bytes, of all the ext2, ext3, ext4 filesystems on the host. 109 GetGlobalFsInfo() ([]Fs, error) 110 111 // Returns capacity and free space, in bytes, of the set of mounts passed. 112 GetFsInfoForPath(mountSet map[string]struct{}) ([]Fs, error) 113 114 // GetDirUsage returns a usage information for 'dir'. 115 GetDirUsage(dir string) (UsageInfo, error) 116 117 // GetDeviceInfoByFsUUID returns the information of the device with the 118 // specified filesystem uuid. If no such device exists, this function will 119 // return the ErrNoSuchDevice error. 120 GetDeviceInfoByFsUUID(uuid string) (*DeviceInfo, error) 121 122 // Returns the block device info of the filesystem on which 'dir' resides. 123 GetDirFsDevice(dir string) (*DeviceInfo, error) 124 125 // Returns the device name associated with a particular label. 126 GetDeviceForLabel(label string) (string, error) 127 128 // Returns all labels associated with a particular device name. 129 GetLabelsForDevice(device string) ([]string, error) 130 131 // Returns the mountpoint associated with a particular device. 132 GetMountpointForDevice(device string) (string, error) 133 }