forked from github-starred/komodo
0.1.5
This commit is contained in:
@@ -6,7 +6,7 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
types = { package = "monitor_types", version = "0.1.4" }
|
||||
types = { package = "monitor_types", version = "0.1.5" }
|
||||
# types = { package = "monitor_types", path = "../types" }
|
||||
mungos = "0.3.0"
|
||||
anyhow = "1.0"
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "monitor_helpers"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
edition = "2021"
|
||||
authors = ["MoghTech"]
|
||||
description = "helpers used as dependency for mogh tech monitor"
|
||||
@@ -10,7 +10,7 @@ license = "GPL-3.0-or-later"
|
||||
|
||||
[dependencies]
|
||||
# types = { package = "monitor_types", path = "../types" }
|
||||
types = { package = "monitor_types", version = "0.1.4" }
|
||||
types = { package = "monitor_types", version = "0.1.5" }
|
||||
async_timing_util = "0.1.12"
|
||||
bollard = "0.13"
|
||||
anyhow = "1.0"
|
||||
|
||||
@@ -185,4 +185,4 @@ fn parse_extra_args(extra_args: &Vec<String>) -> String {
|
||||
} else {
|
||||
args
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "monitor_client"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
edition = "2021"
|
||||
authors = ["MoghTech"]
|
||||
description = "a client to interact with the monitor system"
|
||||
@@ -9,7 +9,7 @@ license = "GPL-3.0-or-later"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
monitor_types = "0.1.4"
|
||||
monitor_types = "0.1.5"
|
||||
# monitor_types = { path = "../types" }
|
||||
reqwest = { version = "0.11", features = ["json"] }
|
||||
tokio-tungstenite = { version = "0.18", features=["native-tls"] }
|
||||
|
||||
@@ -2,7 +2,7 @@ use anyhow::{anyhow, Context};
|
||||
use futures_util::{SinkExt, StreamExt};
|
||||
use monitor_types::{
|
||||
BasicContainerInfo, HistoricalStatsQuery, ImageSummary, Log, Network, Server,
|
||||
ServerActionState, ServerWithStatus, SystemStats, SystemStatsQuery, SystemStatsRecord,
|
||||
ServerActionState, ServerWithStatus, SystemStats, SystemStatsQuery, SystemStatsRecord, SystemInformation,
|
||||
};
|
||||
use serde_json::{json, Value};
|
||||
use tokio::{
|
||||
@@ -86,6 +86,24 @@ impl MonitorClient {
|
||||
.context("failed at update server")
|
||||
}
|
||||
|
||||
pub async fn get_server_version(
|
||||
&self,
|
||||
server_id: &str
|
||||
) -> anyhow::Result<String> {
|
||||
self.get(&format!("/api/server/{server_id}/version"), Option::<()>::None)
|
||||
.await
|
||||
.context(format!("failed to get server version at id {server_id}"))
|
||||
}
|
||||
|
||||
pub async fn get_server_system_information(
|
||||
&self,
|
||||
server_id: &str
|
||||
) -> anyhow::Result<SystemInformation> {
|
||||
self.get(&format!("/api/server/{server_id}/system_information"), Option::<()>::None)
|
||||
.await
|
||||
.context(format!("failed to get server system information at id {server_id}"))
|
||||
}
|
||||
|
||||
pub async fn get_server_stats(
|
||||
&self,
|
||||
server_id: &str,
|
||||
|
||||
@@ -6,8 +6,8 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
helpers = { package = "monitor_helpers", version = "0.1.4" }
|
||||
types = { package = "monitor_types", version = "0.1.4" }
|
||||
helpers = { package = "monitor_helpers", version = "0.1.5" }
|
||||
types = { package = "monitor_types", version = "0.1.5" }
|
||||
# types = { package = "monitor_types", path = "../types" }
|
||||
# helpers = { package = "monitor_helpers", path = "../helpers" }
|
||||
tokio-tungstenite = { version = "0.18", features=["native-tls"] }
|
||||
|
||||
@@ -3,7 +3,7 @@ use reqwest::StatusCode;
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
use tokio::net::TcpStream;
|
||||
use tokio_tungstenite::{connect_async, MaybeTlsStream, WebSocketStream};
|
||||
use types::{Server, SystemStats, SystemStatsQuery};
|
||||
use types::{Server, SystemInformation, SystemStats, SystemStatsQuery};
|
||||
|
||||
mod build;
|
||||
mod command;
|
||||
@@ -42,6 +42,15 @@ impl PeripheryClient {
|
||||
.context("failed to get docker accounts from periphery")
|
||||
}
|
||||
|
||||
pub async fn get_system_information(
|
||||
&self,
|
||||
server: &Server,
|
||||
) -> anyhow::Result<SystemInformation> {
|
||||
self.get_json(server, "/system_information")
|
||||
.await
|
||||
.context("failed to get system information from periphery")
|
||||
}
|
||||
|
||||
pub async fn get_system_stats(
|
||||
&self,
|
||||
server: &Server,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "monitor_types"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
edition = "2021"
|
||||
authors = ["MoghTech"]
|
||||
description = "types for the mogh tech monitor"
|
||||
|
||||
@@ -139,6 +139,8 @@ pub enum ServerStatus {
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, Default)]
|
||||
pub struct SystemStatsQuery {
|
||||
#[serde(default)]
|
||||
pub cpus: bool,
|
||||
#[serde(default)]
|
||||
pub disks: bool,
|
||||
#[serde(default)]
|
||||
@@ -152,6 +154,7 @@ pub struct SystemStatsQuery {
|
||||
impl SystemStatsQuery {
|
||||
pub fn all() -> SystemStatsQuery {
|
||||
SystemStatsQuery {
|
||||
cpus: true,
|
||||
disks: true,
|
||||
networks: true,
|
||||
components: true,
|
||||
@@ -167,11 +170,16 @@ impl SystemStatsQuery {
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
|
||||
pub struct SystemStats {
|
||||
pub cpu_perc: f32, // in %
|
||||
#[serde(default)]
|
||||
pub system_load: f64,
|
||||
pub cpu_perc: f32,
|
||||
pub cpu_freq_mhz: f64,
|
||||
pub mem_used_gb: f64, // in GB
|
||||
pub mem_total_gb: f64, // in GB
|
||||
pub disk: DiskUsage,
|
||||
#[serde(default)]
|
||||
pub cpus: Vec<SingleCpuUsage>,
|
||||
#[serde(default)]
|
||||
pub networks: Vec<SystemNetwork>,
|
||||
#[serde(default)]
|
||||
pub components: Vec<SystemComponent>,
|
||||
@@ -182,6 +190,13 @@ pub struct SystemStats {
|
||||
pub refresh_list_ts: u128,
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct SingleCpuUsage {
|
||||
pub name: String,
|
||||
pub usage: f32,
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
|
||||
pub struct DiskUsage {
|
||||
@@ -244,12 +259,16 @@ pub struct SystemStatsRecord {
|
||||
)]
|
||||
pub id: String,
|
||||
pub server_id: String,
|
||||
pub ts: f64, // unix ts milliseconds
|
||||
pub ts: f64, // unix ts milliseconds
|
||||
pub system_load: f64,
|
||||
pub cpu_perc: f32, // in %
|
||||
pub cpu_freq_mhz: f64, // in MHz
|
||||
pub mem_used_gb: f64, // in GB
|
||||
pub mem_total_gb: f64, // in GB
|
||||
pub disk: DiskUsage,
|
||||
#[serde(default)]
|
||||
pub cpus: Vec<SingleCpuUsage>,
|
||||
#[serde(default)]
|
||||
pub networks: Vec<SystemNetwork>,
|
||||
#[serde(default)]
|
||||
pub components: Vec<SystemComponent>,
|
||||
@@ -264,10 +283,13 @@ impl SystemStatsRecord {
|
||||
id: String::new(),
|
||||
server_id,
|
||||
ts: ts as f64,
|
||||
system_load: stats.system_load,
|
||||
cpu_perc: stats.cpu_perc,
|
||||
cpu_freq_mhz: stats.cpu_freq_mhz,
|
||||
mem_used_gb: stats.mem_used_gb,
|
||||
mem_total_gb: stats.mem_total_gb,
|
||||
disk: stats.disk,
|
||||
cpus: stats.cpus,
|
||||
networks: stats.networks,
|
||||
components: stats.components,
|
||||
processes: stats.processes,
|
||||
@@ -310,3 +332,14 @@ fn default_interval() -> Timelength {
|
||||
fn default_limit() -> f64 {
|
||||
100.0
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct SystemInformation {
|
||||
pub name: Option<String>,
|
||||
pub os: Option<String>,
|
||||
pub kernel: Option<String>,
|
||||
pub core_count: Option<u32>,
|
||||
pub host_name: Option<String>,
|
||||
pub cpu_brand: String,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user