docker_sync/
stats.rs

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