Re: [PATCH datacenter-manager v2 1/4] api: return global cpu/memory/storage statistics

Dominik Csapak
2026-04-02T13:02:22Z

On 4/1/26 1:33 PM, Lukas Wagner wrote:
> Looking good, some tiny suggestions for improvement inline.
>
> Can also be fixed in a small follow-up patch in case there is nothing
> else that needs to be changed.
>
> On Mon Mar 30, 2026 at 3:07 PM CEST, Dominik Csapak wrote:
>> Global CPU/memory/storage usage (per remote type) is useful and
>> interesting from an administration POV. Calculate and return these so
>> we can use them on the dashboards.
>>
>> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
>> ---
>> lib/pdm-api-types/src/lib.rs | 14 ++++++-
>> lib/pdm-api-types/src/resource.rs | 27 +++++++++++++
>> server/src/api/resources.rs | 65 ++++++++++++++++++++++++-------
>> 3 files changed, 92 insertions(+), 14 deletions(-)
>>
>> diff --git a/lib/pdm-api-types/src/lib.rs b/lib/pdm-api-types/src/lib.rs
>> index d4cc7ef0..28aed3f4 100644
>> --- a/lib/pdm-api-types/src/lib.rs
>> +++ b/lib/pdm-api-types/src/lib.rs
>> @@ -191,7 +191,7 @@ pub const PVE_STORAGE_ID_SCHEMA: Schema = StringSchema::new("Storage ID.")
>> // Complex type definitions
>>
>> #[api()]
>> -#[derive(Default, Serialize, Deserialize)]
>> +#[derive(Default, Serialize, Deserialize, PartialEq, Clone)]
>> /// Storage space usage information.
>> pub struct StorageStatus {
>> /// Total space (bytes).
>> @@ -202,6 +202,18 @@ pub struct StorageStatus {
>> pub avail: u64,
>> }
>>
>> +#[api()]
>
> nit: you can leave out the parentheses: #[api]
>
>> +#[derive(Default, Serialize, Deserialize, PartialEq, Clone)]
>> +/// Storage space usage information.
>
> ^ The doc comment seems to be wrong (copy/paste mistake?)
>
>> +pub struct MemoryStatus {
>> + /// Total memory size (bytes).
>> + pub total: u64,
>> + /// Used memory (bytes).
>> + pub used: u64,
>> + /// Available memory (bytes).
>> + pub avail: u64,
>> +}
>> +
>> pub const PASSWORD_HINT_SCHEMA: Schema = StringSchema::new("Password hint.")
>> .format(&SINGLE_LINE_COMMENT_FORMAT)
>> .min_length(1)
>> diff --git a/lib/pdm-api-types/src/resource.rs b/lib/pdm-api-types/src/resource.rs
>> index d2db3b5a..01a5eb6c 100644
>> --- a/lib/pdm-api-types/src/resource.rs
>> +++ b/lib/pdm-api-types/src/resource.rs
>> @@ -6,6 +6,8 @@ use serde::{Deserialize, Serialize};
>> use proxmox_schema::{api, ApiStringFormat, ApiType, EnumEntry, OneOfSchema, Schema, StringSchema};
>>
>> use super::remotes::{RemoteType, REMOTE_ID_SCHEMA};
>> +use super::{MemoryStatus, StorageStatus};
>> +
>> use pve_api_types::ClusterResourceNetworkType;
>>
>> /// High PBS datastore usage threshold
>> @@ -666,6 +668,18 @@ pub struct SdnZoneCount {
>> pub unknown: u64,
>> }
>>
>> +#[api]
>> +#[derive(Default, Serialize, Deserialize, Clone, PartialEq)]
>> +/// Statistics for CPU utilization
>> +pub struct CpuStatistics {
>> + /// Amount of threads utilized
>
> 'thread' is a countable noun, so it should rather be "Number of threads"

thanks, i'll fix it, but just to note, in that same file we have
many instances of this, for example:

"Amount of running guests"
"Amount of online datastores"
"Amount of configured remotes"

which all seem to me like countable nouns?

so we might want to clean that up for all of them

>
>> + pub used: f64,
>> + /// Amount of physically available cpu threads
>
> same here
>
>
>> + pub max: f64,
>> + /// Currently allocated cores of running guests (only on PVE)
>> + pub allocated: Option<f64>,
>> +}
>> +
>