Skip to content

Commit

Permalink
Add logger warning to monit and edit mode for vm
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeRoggenbuck committed Oct 27, 2022
1 parent 43f6ecd commit 58a8c13
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
15 changes: 13 additions & 2 deletions src/daemon.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::power::battery::{has_battery, Battery};
use std::convert::TryInto;
use std::fs::{File, OpenOptions};
use std::io::Write;
Expand All @@ -17,12 +16,15 @@ use super::graph::{Graph, Grapher};
use super::logger;
use super::logger::Interface;
use super::network::{hook, listen};
use super::power::battery::{has_battery, Battery};
use super::power::lid::{read_lid_state, LidState};
use super::power::read_power_source;
use super::settings::{GraphType, Settings};
use super::setup::{inside_docker_message, inside_wsl_message};
use super::system::{
check_available_governors, check_cpu_freq, check_cpu_temperature, check_cpu_usage,
get_highest_temp, list_cpus, parse_proc_file, read_proc_stat_file, ProcStat,
get_highest_temp, inside_docker, inside_wsl, list_cpus, parse_proc_file, read_proc_stat_file,
ProcStat,
};
use super::terminal::terminal_width;
use super::Error;
Expand Down Expand Up @@ -278,6 +280,15 @@ impl Checker for Daemon {
self.timeout = time::Duration::from_millis(self.settings.delay);

self.setup_csv_logging();

if inside_wsl() {
self.logger
.log(&inside_wsl_message(), logger::Severity::Warning);
}
if inside_docker() {
self.logger
.log(&inside_docker_message(), logger::Severity::Warning);
}
}

fn start_loop(&mut self) -> Result<(), Error> {
Expand Down
23 changes: 15 additions & 8 deletions src/setup.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
use super::system::inside_docker;
use super::system::{inside_docker, inside_wsl};
use super::warn_user;
use crate::system::inside_wsl;

pub fn inside_wsl_message() -> String {
String::from(
"ACS is intended to run on an actual linux distribution, \
the program will NOT work inside of Windows Subsystem for Linux \
Please install an actual distribution of Linux.",
)
}

pub fn inside_docker_message() -> String {
String::from("Stats may be incorrect if running inside docker.")
}

pub fn setup() {
if inside_wsl() {
warn_user!(
"ACS is intended to run on an actual linux distribution, \
the program will NOT work inside of Windows Subsystem for Linux \
Please install an actual distribution of Linux"
);
warn_user!(inside_wsl_message());
}
if inside_docker() {
warn_user!("Stats may be incorrect if running inside docker.");
warn_user!(inside_docker_message());
}
}

0 comments on commit 58a8c13

Please sign in to comment.