1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
#[derive(RustcEncodable, RustcDecodable)] pub struct Stats { pub read: String, pub network: Network, pub memory_stats: MemoryStats, pub cpu_stats: CpuStats, pub blkio_stats: BlkioStats } #[derive(RustcEncodable, RustcDecodable)] pub struct Network { pub rx_dropped: u64, pub rx_bytes: u64, pub rx_errors: u64, pub tx_packets: u64, pub tx_dropped: u64, pub rx_packets: u64, pub tx_errors: u64, pub tx_bytes: u64 } #[derive(RustcEncodable, RustcDecodable)] pub struct MemoryStats { pub max_usage: u64, pub usage: u64, pub failcnt: u64, pub limit: u64, pub stats: MemoryStat } #[derive(RustcEncodable, RustcDecodable)] pub struct MemoryStat { pub total_pgmajfault: u64, pub cache: u64, pub mapped_file: u64, pub total_inactive_file: u64, pub pgpgout: u64, pub rss: u64, pub total_mapped_file: u64, pub writeback: u64, pub unevictable: u64, pub pgpgin: u64, pub total_unevictable: u64, pub pgmajfault: u64, pub total_rss: u64, pub total_rss_huge: u64, pub total_writeback: u64, pub total_inactive_anon: u64, pub rss_huge: u64, pub hierarchical_memory_limit: u64, pub hierarchical_memsw_limit: u64, pub total_pgfault: u64, pub total_active_file: u64, pub active_anon: u64, pub total_active_anon: u64, pub total_pgpgout: u64, pub total_cache: u64, pub inactive_anon: u64, pub active_file: u64, pub pgfault: u64, pub inactive_file: u64, pub total_pgpgin: u64, pub swap: u64, pub total_swap: u64 } #[derive(RustcEncodable, RustcDecodable)] pub struct CpuStats { pub cpu_usage: CpuUsage, pub system_cpu_usage: u64, pub throttling_data: ThrottlingData } #[derive(RustcEncodable, RustcDecodable)] pub struct CpuUsage { pub percpu_usage: Vec<u64>, pub usage_in_usermode: u64, pub total_usage: u64, pub usage_in_kernelmode: u64 } #[derive(RustcEncodable, RustcDecodable)] pub struct ThrottlingData { pub periods: u64, pub throttled_periods: u64, pub throttled_time: u64 } #[derive(RustcEncodable, RustcDecodable)] pub struct BlkioStats { pub io_service_bytes_recursive: Vec<BlkioStat>, pub io_serviced_recursive: Vec<BlkioStat>, pub io_queue_recursive: Vec<BlkioStat>, pub io_service_time_recursive: Vec<BlkioStat>, pub io_wait_time_recursive: Vec<BlkioStat>, pub io_merged_recursive: Vec<BlkioStat>, pub io_time_recursive: Vec<BlkioStat>, pub sectors_recursive: Vec<BlkioStat> } #[derive(RustcEncodable, RustcDecodable)] pub struct BlkioStat { pub major: u64, pub minor: u64, pub op: String, pub value: u64 } impl Clone for Stats { fn clone(&self) -> Stats { let stats = Stats { read: self.read.clone(), network: self.network.clone(), memory_stats: self.memory_stats.clone(), cpu_stats: self.cpu_stats.clone(), blkio_stats: self.blkio_stats.clone() }; return stats; } } impl Clone for Network { fn clone(&self) -> Self { let network = Network { rx_dropped: self.rx_dropped, rx_bytes: self.rx_bytes, rx_errors: self.rx_errors, tx_packets: self.tx_packets, tx_dropped: self.tx_dropped, rx_packets: self.rx_packets, tx_errors: self.tx_errors, tx_bytes: self.tx_bytes }; return network; } } impl Clone for MemoryStats { fn clone(&self) -> Self { let memory_stats = MemoryStats { max_usage: self.max_usage, usage: self.usage, failcnt: self.failcnt, limit: self.limit, stats: self.stats.clone() }; return memory_stats; } } impl Clone for MemoryStat { fn clone(&self) -> Self { let memory_stat = MemoryStat { total_pgmajfault: self.total_pgmajfault, cache: self.cache, mapped_file: self.mapped_file, total_inactive_file: self.total_inactive_file, pgpgout: self.pgpgout, rss: self.rss, total_mapped_file: self.total_mapped_file, writeback: self.writeback, unevictable: self.unevictable, pgpgin: self.pgpgin, total_unevictable: self.total_unevictable, pgmajfault: self.pgmajfault, total_rss: self.total_rss, total_rss_huge: self.total_rss_huge, total_writeback: self.total_writeback, total_inactive_anon: self.total_inactive_anon, rss_huge: self.rss_huge, hierarchical_memory_limit: self.hierarchical_memory_limit, hierarchical_memsw_limit: self.hierarchical_memsw_limit, total_pgfault: self.total_pgfault, total_active_file: self.total_active_file, active_anon: self.active_anon, total_active_anon: self.total_active_anon, total_pgpgout: self.total_pgpgout, total_cache: self.total_cache, inactive_anon: self.inactive_anon, active_file: self.active_file, pgfault: self.pgfault, inactive_file: self.inactive_file, total_pgpgin: self.total_pgpgin, swap: self.swap, total_swap: self.total_swap }; return memory_stat; } } impl Clone for CpuStats { fn clone(&self) -> Self { let cpu_stats = CpuStats { cpu_usage: self.cpu_usage.clone(), system_cpu_usage: self.system_cpu_usage, throttling_data: self.throttling_data.clone() }; return cpu_stats; } } impl Clone for CpuUsage { fn clone(&self) -> Self { let cpu_usage = CpuUsage { percpu_usage: self.percpu_usage.clone(), usage_in_usermode: self.usage_in_usermode, total_usage: self.total_usage, usage_in_kernelmode: self.usage_in_kernelmode }; return cpu_usage; } } impl Clone for ThrottlingData { fn clone(&self) -> Self { let throttling_data = ThrottlingData { periods: self.periods, throttled_periods: self.throttled_periods, throttled_time: self.throttled_time }; return throttling_data; } } impl Clone for BlkioStats { fn clone(&self) -> Self { let blkio_stats = BlkioStats { io_service_bytes_recursive: self.io_service_bytes_recursive.clone(), io_serviced_recursive: self.io_serviced_recursive.clone(), io_queue_recursive: self.io_queue_recursive.clone(), io_service_time_recursive: self.io_service_time_recursive.clone(), io_wait_time_recursive: self.io_wait_time_recursive.clone(), io_merged_recursive: self.io_merged_recursive.clone(), io_time_recursive: self.io_time_recursive.clone(), sectors_recursive: self.sectors_recursive.clone() }; return blkio_stats; } } impl Clone for BlkioStat { fn clone(&self) -> Self { let blkio_stat = BlkioStat { major: self.major, minor: self.minor, op: self.op.clone(), value: self.value }; return blkio_stat; } }