@@ -31,6 +31,37 @@ pub struct Disk {
31
31
pub iops : u64 ,
32
32
}
33
33
34
+ impl Disk {
35
+ #[ must_use]
36
+ pub fn from_metrics (
37
+ disk_name : String ,
38
+ disk_path : String ,
39
+ raw_metrics : & dto:: MetricsSnapshotModel ,
40
+ raw_space : & dto:: SpaceInfo ,
41
+ ) -> Self {
42
+ let status = DiskStatus :: from_space_info ( raw_space, & disk_name) ;
43
+ let used_space = raw_space
44
+ . occupied_disk_space_by_disk
45
+ . get ( & disk_name)
46
+ . copied ( )
47
+ . unwrap_or_default ( ) ;
48
+ let iops = raw_metrics
49
+ . metrics
50
+ . get ( & format ! ( "hardware.disks.{:?}_iops" , disk_name) )
51
+ . cloned ( )
52
+ . unwrap_or_default ( )
53
+ . value ;
54
+ Self {
55
+ name : disk_name,
56
+ path : disk_path,
57
+ status,
58
+ total_space : raw_space. total_disk_space_bytes ,
59
+ used_space,
60
+ iops,
61
+ }
62
+ }
63
+ }
64
+
34
65
/// Defines kind of problem on disk
35
66
#[ derive( Debug , Clone , Eq , PartialEq , PartialOrd , Serialize , Hash ) ]
36
67
#[ cfg_attr( all( feature = "swagger" , debug_assertions) , derive( ToSchema ) ) ]
@@ -189,6 +220,12 @@ pub enum NodeStatus {
189
220
Offline ,
190
221
}
191
222
223
+ impl Default for NodeStatus {
224
+ fn default ( ) -> Self {
225
+ Self :: Offline
226
+ }
227
+ }
228
+
192
229
impl NodeStatus {
193
230
#[ must_use]
194
231
pub fn from_problems ( problems : Vec < NodeProblem > ) -> Self {
@@ -343,7 +380,7 @@ pub enum VDiskStatus {
343
380
Offline ,
344
381
}
345
382
346
- #[ derive( Debug , Clone , Serialize ) ]
383
+ #[ derive( Default , Debug , Clone , Serialize ) ]
347
384
#[ cfg_attr( all( feature = "swagger" , debug_assertions) , derive( ToSchema ) ) ]
348
385
pub struct DetailedNode {
349
386
pub name : String ,
@@ -360,7 +397,7 @@ pub struct DetailedNode {
360
397
pub disks : Vec < Disk > ,
361
398
}
362
399
363
- #[ derive( Debug , Clone , Serialize ) ]
400
+ #[ derive( Default , Debug , Clone , Serialize ) ]
364
401
#[ cfg_attr( all( feature = "swagger" , debug_assertions) , derive( ToSchema ) ) ]
365
402
#[ serde( rename_all = "camelCase" ) ]
366
403
pub struct DetailedNodeMetrics {
@@ -381,6 +418,22 @@ pub struct DetailedNodeMetrics {
381
418
pub descr_amount : u64 ,
382
419
}
383
420
421
+ impl DetailedNodeMetrics {
422
+ #[ must_use]
423
+ pub fn from_metrics ( metrics : & TypedMetrics , space : SpaceInfo ) -> Self {
424
+ Self {
425
+ rps : RPS :: from_metrics ( metrics) ,
426
+ alien_count : metrics[ RawMetricEntry :: BackendAlienCount ] . value ,
427
+ corrupted_count : metrics[ RawMetricEntry :: BackendCorruptedBlobCount ] . value ,
428
+ space,
429
+ cpu_load : metrics[ RawMetricEntry :: HardwareBobCpuLoad ] . value ,
430
+ total_ram : metrics[ RawMetricEntry :: HardwareTotalRam ] . value ,
431
+ used_ram : metrics[ RawMetricEntry :: HardwareUsedRam ] . value ,
432
+ descr_amount : metrics[ RawMetricEntry :: HardwareDescrAmount ] . value ,
433
+ }
434
+ }
435
+ }
436
+
384
437
/// Types of operations on BOB cluster
385
438
#[ derive( Debug , Clone , Serialize , Hash , Eq , PartialEq , PartialOrd , Ord , EnumIter ) ]
386
439
#[ cfg_attr( all( feature = "swagger" , debug_assertions) , derive( ToSchema ) ) ]
0 commit comments