Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logger warning to monit and edit mode for vm #444

Merged
merged 1 commit into from
Oct 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add logger warning to monit and edit mode for vm
  • Loading branch information
JakeRoggenbuck committed Oct 27, 2022
commit 58a8c13f181d7b2ca9a72b628efab406ad134c6c
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());
}
}