Skip to content

Commit

Permalink
feat: display total logical cores & memory
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Mar 11, 2024
1 parent d2b709f commit a3a3218
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions frontend/src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
Total: {{status.total_worker_count}}
<p></p>
Live: {{status.live_worker_count}}
<p></p>
Total Logical Cores: {{status.total_logical_cores}}
<p></p>
Total Memory: {{status.total_memory_bytes && prettyBytes(Number(status.total_memory_bytes))}}
<p></p>
</v-card-text>
</v-card>
</v-col>
Expand Down Expand Up @@ -80,19 +85,25 @@
live_worker_count: number;
total_logical_cores: number;
total_memory_bytes: string;
total_job_count: number;
pending_job_count: number;
running_job_count: number;
}
interface DashboardStatusResponse {
total_pipeline_count: number;
total_job_count: number;
pending_job_count: number;
running_job_count: number;
finished_job_count: number;
total_worker_count: number;
live_worker_count: number;
total_logical_cores: number;
total_memory_bytes: string;
by_arch: { [key:string]: DashboardStatusResponseByArch };
}
Expand Down
14 changes: 14 additions & 0 deletions server/src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ pub struct DashboardStatusResponseByArch {
live_worker_count: i64,
total_logical_cores: i64,
total_memory_bytes: bigdecimal::BigDecimal,

total_job_count: i64,
pending_job_count: i64,
running_job_count: i64,
Expand All @@ -611,12 +612,17 @@ pub struct DashboardStatusResponseByArch {
#[derive(Serialize)]
pub struct DashboardStatusResponse {
total_pipeline_count: i64,

total_job_count: i64,
pending_job_count: i64,
running_job_count: i64,
finished_job_count: i64,

total_worker_count: i64,
live_worker_count: i64,
total_logical_cores: i64,
total_memory_bytes: bigdecimal::BigDecimal,

by_arch: BTreeMap<String, DashboardStatusResponseByArch>,
}

Expand Down Expand Up @@ -648,6 +654,12 @@ pub async fn dashboard_status(
let total_worker_count = crate::schema::workers::dsl::workers
.count()
.get_result(conn)?;
let (total_logical_cores, total_memory_bytes) = crate::schema::workers::dsl::workers
.select((
sum(crate::schema::workers::dsl::logical_cores),
sum(crate::schema::workers::dsl::memory_bytes),
))
.get_result::<(Option<i64>, Option<bigdecimal::BigDecimal>)>(conn)?;

let deadline = Utc::now() - chrono::Duration::try_seconds(300).unwrap();
let live_worker_count = crate::schema::workers::dsl::workers
Expand Down Expand Up @@ -744,6 +756,8 @@ pub async fn dashboard_status(
finished_job_count,
total_worker_count,
live_worker_count,
total_logical_cores: total_logical_cores.unwrap_or(0),
total_memory_bytes: total_memory_bytes.unwrap_or_default(),
by_arch,
})
})?,
Expand Down

0 comments on commit a3a3218

Please sign in to comment.