Files
komodo/bin/periphery/src/api/stats.rs
rita7lopes e274d6f7c8 Network Usage - Ingress Egress per interface and global usage (#229)
* Add network io stats

Add network usage graph and current status

Change network graphs to use network interface from drop down menu

Adjust the type to be able to get general network stats for the general
UI view

Working setup with a working builder

remove changes to these dockerfile

remove lock changes

* change network hashmap to Vector

* adjust all the network_usage_interface to be a vector rather than a hash map

* PR requested changes applied

* Change net_ingress_bytes and egress to network_ingress_bytes egress respectively

* final gen-client types

---------

Co-authored-by: mbecker20 <becker.maxh@gmail.com>
2024-12-21 08:15:21 -08:00

60 lines
1.4 KiB
Rust

use anyhow::Context;
use periphery_client::api::stats::{
GetSystemInformation, GetSystemProcesses, GetSystemStats,
};
use resolver_api::ResolveToString;
use crate::{stats::stats_client, State};
impl ResolveToString<GetSystemInformation> for State {
#[instrument(
name = "GetSystemInformation",
level = "debug",
skip(self)
)]
async fn resolve_to_string(
&self,
_: GetSystemInformation,
_: (),
) -> anyhow::Result<String> {
let info = &stats_client().read().await.info;
serde_json::to_string(info)
.context("failed to serialize response to string")
}
}
//
impl ResolveToString<GetSystemStats> for State {
#[instrument(name = "GetSystemStats", level = "debug", skip(self))]
async fn resolve_to_string(
&self,
_: GetSystemStats,
_: (),
) -> anyhow::Result<String> {
let stats = &stats_client().read().await.stats;
serde_json::to_string(stats)
.context("failed to serialize response to string")
}
}
//
impl ResolveToString<GetSystemProcesses> for State {
#[instrument(
name = "GetSystemProcesses",
level = "debug",
skip(self)
)]
async fn resolve_to_string(
&self,
_: GetSystemProcesses,
_: (),
) -> anyhow::Result<String> {
let stats = &stats_client().read().await.get_processes();
serde_json::to_string(&stats)
.context("failed to serialize response to string")
}
}