use std::{collections::HashMap, time::SystemTime}; use serde::{Deserialize, Serialize}; use time::OffsetDateTime; use crate::metrics::TimedAction; #[derive(Debug, PartialEq, Clone, Copy)] pub enum ItemState { Offline, Initializing, Online, } impl ItemState { pub fn to_string(&self) -> &str { match self { ItemState::Offline => "offline", ItemState::Initializing => "initializing", ItemState::Online => "online", } } pub fn from_string(s: &str) -> Option { match s { "offline" => Some(ItemState::Offline), "initializing" => Some(ItemState::Initializing), "online" => Some(ItemState::Online), _ => None, } } } #[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq)] pub struct DiskMetrics { pub last_minute: HashMap, pub api_calls: HashMap, pub total_waiting: u32, pub total_errors_availability: u64, pub total_errors_timeout: u64, pub total_writes: u64, pub total_deletes: u64, } #[derive(Serialize, Deserialize, Debug, Default, Clone)] pub struct Disk { pub endpoint: String, pub root_disk: bool, pub drive_path: String, pub healing: bool, pub scanning: bool, pub state: String, pub uuid: String, pub major: u32, pub minor: u32, pub model: Option, pub total_space: u64, pub used_space: u64, pub available_space: u64, pub read_throughput: f64, pub write_throughput: f64, pub read_latency: f64, pub write_latency: f64, pub utilization: f64, pub metrics: Option, pub heal_info: Option, pub used_inodes: u64, pub free_inodes: u64, pub local: bool, pub pool_index: i32, pub set_index: i32, pub disk_index: i32, } #[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct HealingDisk { pub id: String, pub heal_id: String, pub pool_index: Option, pub set_index: Option, pub disk_index: Option, pub endpoint: String, pub path: String, pub started: Option, pub last_update: Option, pub retry_attempts: u64, pub objects_total_count: u64, pub objects_total_size: u64, pub items_healed: u64, pub items_failed: u64, pub item_skipped: u64, pub bytes_done: u64, pub bytes_failed: u64, pub bytes_skipped: u64, pub objects_healed: u64, pub objects_failed: u64, pub bucket: String, pub object: String, pub queue_buckets: Vec, pub healed_buckets: Vec, pub finished: bool, } #[derive(Debug, Default, Serialize, Deserialize)] pub enum BackendByte { #[default] Unknown, FS, Erasure, } #[derive(Debug, Default, Serialize, Deserialize)] pub struct StorageInfo { pub disks: Vec, pub backend: BackendInfo, } #[derive(Debug, Default, Serialize, Deserialize)] pub struct BackendDisks(pub HashMap); impl BackendDisks { pub fn new() -> Self { Self(HashMap::new()) } pub fn sum(&self) -> usize { self.0.values().sum() } } #[derive(Debug, Default, Serialize, Deserialize)] #[serde(rename_all = "PascalCase", default)] pub struct BackendInfo { pub backend_type: BackendByte, pub online_disks: BackendDisks, pub offline_disks: BackendDisks, #[serde(rename = "StandardSCData")] pub standard_sc_data: Vec, #[serde(rename = "StandardSCParities")] pub standard_sc_parities: Vec, #[serde(rename = "StandardSCParity")] pub standard_sc_parity: Option, #[serde(rename = "RRSCData")] pub rr_sc_data: Vec, #[serde(rename = "RRSCParities")] pub rr_sc_parities: Vec, #[serde(rename = "RRSCParity")] pub rr_sc_parity: Option, pub total_sets: Vec, pub drives_per_set: Vec, } pub const ITEM_OFFLINE: &str = "offline"; pub const ITEM_INITIALIZING: &str = "initializing"; pub const ITEM_ONLINE: &str = "online"; #[derive(Debug, Default, Serialize, Deserialize)] pub struct MemStats { pub alloc: u64, pub total_alloc: u64, pub mallocs: u64, pub frees: u64, pub heap_alloc: u64, } #[derive(Debug, Default, Serialize, Deserialize)] pub struct ServerProperties { pub state: String, pub endpoint: String, pub scheme: String, pub uptime: u64, pub version: String, #[serde(rename = "commitID")] pub commit_id: String, pub network: HashMap, #[serde(rename = "drives")] pub disks: Vec, #[serde(rename = "poolNumber")] pub pool_number: i32, #[serde(rename = "poolNumbers")] pub pool_numbers: Vec, pub mem_stats: MemStats, pub max_procs: u64, pub num_cpu: u64, pub runtime_version: String, pub rustfs_env_vars: HashMap, } #[derive(Serialize, Deserialize, Debug, Default)] pub struct Kms { pub status: Option, pub encrypt: Option, pub decrypt: Option, pub endpoint: Option, pub version: Option, } #[derive(Serialize, Deserialize, Debug, Default)] pub struct Ldap { pub status: Option, } #[derive(Serialize, Deserialize, Debug, Default)] pub struct Status { pub status: Option, } pub type Audit = HashMap; pub type Logger = HashMap; pub type TargetIDStatus = HashMap; #[derive(Serialize, Deserialize, Default, Debug)] pub struct Services { pub kms: Option, // deprecated july 2023 #[serde(rename = "kmsStatus")] pub kms_status: Option>, pub ldap: Option, pub logger: Option>, pub audit: Option>, pub notifications: Option>>>, } #[derive(Serialize, Deserialize, Debug, Default)] pub struct Buckets { pub count: u64, pub error: Option, } #[derive(Serialize, Deserialize, Debug, Default)] pub struct Objects { pub count: u64, pub error: Option, } #[derive(Serialize, Deserialize, Debug, Default)] pub struct Versions { pub count: u64, pub error: Option, } #[derive(Serialize, Deserialize, Debug, Default)] pub struct DeleteMarkers { pub count: u64, pub error: Option, } #[derive(Serialize, Deserialize, Debug, Default)] pub struct Usage { pub size: u64, pub error: Option, } #[derive(Serialize, Deserialize, Debug, Default)] pub struct ErasureSetInfo { pub id: i32, #[serde(rename = "rawUsage")] pub raw_usage: u64, #[serde(rename = "rawCapacity")] pub raw_capacity: u64, pub usage: u64, #[serde(rename = "objectsCount")] pub objects_count: u64, #[serde(rename = "versionsCount")] pub versions_count: u64, #[serde(rename = "deleteMarkersCount")] pub delete_markers_count: u64, #[serde(rename = "healDisks")] pub heal_disks: i32, } #[derive(Serialize, Deserialize, Debug, Default)] pub enum BackendType { #[default] #[serde(rename = "FS")] FsType, #[serde(rename = "Erasure")] ErasureType, } #[derive(Serialize, Deserialize)] pub struct FSBackend { #[serde(rename = "backendType")] pub backend_type: BackendType, } #[derive(Serialize, Deserialize, Debug, Default)] pub struct ErasureBackend { #[serde(rename = "backendType")] pub backend_type: BackendType, #[serde(rename = "onlineDisks")] pub online_disks: usize, #[serde(rename = "offlineDisks")] pub offline_disks: usize, #[serde(rename = "standardSCParity")] pub standard_sc_parity: Option, #[serde(rename = "rrSCParity")] pub rr_sc_parity: Option, #[serde(rename = "totalSets")] pub total_sets: Vec, #[serde(rename = "totalDrivesPerSet")] pub drives_per_set: Vec, } #[derive(Serialize, Deserialize)] pub struct InfoMessage { pub mode: Option, pub domain: Option>, pub region: Option, #[serde(rename = "sqsARN")] pub sqs_arn: Option>, #[serde(rename = "deploymentID")] pub deployment_id: Option, pub buckets: Option, pub objects: Option, pub versions: Option, #[serde(rename = "deletemarkers")] pub delete_markers: Option, pub usage: Option, pub services: Option, pub backend: Option, pub servers: Option>, pub pools: Option>>, }