From 99df104cdd54cb7d64f3969d0de9cc34a9b983ef Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sat, 28 May 2022 15:50:05 -0700 Subject: [PATCH 1/7] documentation changes. --- README.md | 3 ++- docs/TROUBLESHOOTING_DEVICE_COLLECTOR.md | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index af29cc0..3eb5620 100644 --- a/README.md +++ b/README.md @@ -58,11 +58,12 @@ Scrutiny uses `smartctl --scan` to detect devices/drives. - All RAID controllers supported by `smartctl` are automatically supported by Scrutiny. - While some RAID controllers support passing through the underlying SMART data to `smartctl` others do not. - In some cases `--scan` does not correctly detect the device type, returning [incomplete SMART data](https://github.com/AnalogJ/scrutiny/issues/45). - Scrutiny will eventually support overriding detected device type via the config file. + Scrutiny supports overriding detected device type via the config file: see [example.collector.yaml](https://github.com/AnalogJ/scrutiny/blob/master/example.collector.yaml) - If you use docker, you **must** pass though the RAID virtual disk to the container using `--device` (see below) - This device may be in `/dev/*` or `/dev/bus/*`. - If you're unsure, run `smartctl --scan` on your host, and pass all listed devices to the container. +See [docs/TROUBLESHOOTING_DEVICE_COLLECTOR.md](./docs/TROUBLESHOOTING_DEVICE_COLLECTOR.md) for help ## Docker diff --git a/docs/TROUBLESHOOTING_DEVICE_COLLECTOR.md b/docs/TROUBLESHOOTING_DEVICE_COLLECTOR.md index 0db3fb8..6821238 100644 --- a/docs/TROUBLESHOOTING_DEVICE_COLLECTOR.md +++ b/docs/TROUBLESHOOTING_DEVICE_COLLECTOR.md @@ -52,6 +52,8 @@ If the output is the same, your devices will be processed by Scrutiny. In some cases `--scan` does not correctly detect the device type, returning [incomplete SMART data](https://github.com/AnalogJ/scrutiny/issues/45). Scrutiny will supports overriding the detected device type via the config file. +[example.collector.yaml](https://github.com/AnalogJ/scrutiny/blob/master/example.collector.yaml) + ### RAID Controllers (Megaraid/3ware/HBA/Adaptec/HPE/etc) Smartctl has support for a large number of [RAID controllers](https://www.smartmontools.org/wiki/Supported_RAID-Controllers), however this support is not automatic, and may require some additional device type hinting. You can provide this information to the Scrutiny collector @@ -138,3 +140,17 @@ Thankfully the collector has a special `--host-id` flag (or `COLLECTOR_HOST_ID` See the [docs/INSTALL_HUB_SPOKE.md](/docs/INSTALL_HUB_SPOKE.md) guide for more information. +## Collector DEBUG mode + +You can use environmental variables to enable debug logging and/or log files for the collector: + +```bash +DEBUG=true +COLLECTOR_LOG_FILE=/tmp/collector.log +``` + +Or if you're not using docker, you can pass CLI arguments to the collector during startup: + +```bash +scrutiny-collector-metrics run --debug --log-file /tmp/collector.log +``` \ No newline at end of file From fe5dbcff1e35489d5a28d757ebd742daa3120b79 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sat, 28 May 2022 16:15:26 -0700 Subject: [PATCH 2/7] documentation changes. --- docs/INSTALL_MANUAL.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/INSTALL_MANUAL.md b/docs/INSTALL_MANUAL.md index ea4f0c6..bce5a57 100644 --- a/docs/INSTALL_MANUAL.md +++ b/docs/INSTALL_MANUAL.md @@ -83,9 +83,11 @@ Now that we have downloaded the required files, let's prepare the filesystem. chmod +x /opt/scrutiny/bin/scrutiny-web-linux-amd64 # Next, lets extract the frontend files. +# NOTE: after extraction, there **should not** be a `dist` subdirectory in `/opt/scrutiny/web` directory. cd /opt/scrutiny/web tar xvzf scrutiny-web-frontend.tar.gz --strip-components 1 -C . + # Cleanup rm -rf scrutiny-web-frontend.tar.gz ``` From 8d203b35478982aa99d1eb6ed863914e8da49ed2 Mon Sep 17 00:00:00 2001 From: BadCo-NZ <50016048+BadCo-NZ@users.noreply.github.com> Date: Mon, 30 May 2022 10:17:51 +0000 Subject: [PATCH 3/7] Create INSTALL_PFSENSE.md As requested by @AnalogJ --- docs/INSTALL_PFSENSE.md | 72 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 docs/INSTALL_PFSENSE.md diff --git a/docs/INSTALL_PFSENSE.md b/docs/INSTALL_PFSENSE.md new file mode 100644 index 0000000..d3e82bb --- /dev/null +++ b/docs/INSTALL_PFSENSE.md @@ -0,0 +1,72 @@ +# pfsense Install + +This bascially follows the [Manual collector instructions](https://github.com/AnalogJ/scrutiny/blob/master/docs/INSTALL_MANUAL.md#collector) and assumes you are running a hub and spoke deployment and already have the web app setup. + + +### Dependencies + +SSH into pfsense, hit `8` for the shell and install the required dependencies. + +``` +pkg install smartmontools +``` + +Ensure smartmontools is v7+. This won't be a problem in pfsense 2.6.0+ + + +### Directory Structure + +Now let's create a directory structure to contain the Scrutiny collector binary. + +``` +mkdir -p /opt/scrutiny/bin +``` + + +### Download Files + +Next, we'll download the Scrutiny collector binary from the [latest Github release](https://github.com/analogj/scrutiny/releases). + +> NOTE: Ensure you have the latest version in the below command + +``` +fetch -o /opt/scrutiny/bin https://github.com/AnalogJ/scrutiny/releases/download/vX.X.X/scrutiny-collector-metrics-freebsd-amd64 +``` + + +### Prepare Scrutiny + +Now that we have downloaded the required files, let's prepare the filesystem. + +``` +chmod +x /opt/scrutiny/bin/scrutiny-collector-metrics-freebsd-amd64 +``` + + +### Start Scrutiny Collector, Populate Webapp + +Next, we will manually trigger the collector, to populate the Scrutiny dashboard: + +> NOTE: if you need to pass a config file to the scrutiny collector, you can provide it using the `--config` flag. + +``` +/opt/scrutiny/bin/scrutiny-collector-metrics-freebsd-amd64 run --api-endpoint "http://localhost:8080" +``` +> NOTE: change the IP address to that of your web app + +### Schedule Collector with Cron + +Finally you need to schedule the collector to run periodically. + +Login to the pfsense webGUI and head to `Services/Cron` add an entry with the following details: + +``` +Minute: */15 +Hour: * +Day of the Month: * +Month of the Year: * +Day of the Week: * +User: root +Command: /opt/scrutiny/bin/scrutiny-collector-metrics-freebsd-amd64 run --api-endpoint "http://localhost:8080" >/dev/null 2>&1 +``` +> NOTE: `>/dev/null 2>&1` is used to stop cron confirmation emails being sent. From 411eca20e0f03896263e8149729a1749fa1eaeee Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Tue, 31 May 2022 18:11:25 -0700 Subject: [PATCH 4/7] Update SUPPORTED_NAS_OS.md --- docs/SUPPORTED_NAS_OS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/SUPPORTED_NAS_OS.md b/docs/SUPPORTED_NAS_OS.md index e937f16..123c190 100644 --- a/docs/SUPPORTED_NAS_OS.md +++ b/docs/SUPPORTED_NAS_OS.md @@ -4,11 +4,12 @@ These are the officially supported NAS OS's (with documentation and setup guides Once a guide is created (in `docs/guides/`) it will be linked here. - [ ] freenas/truenas -- [x] [unraid](https://github.com/AnalogJ/scrutiny/blob/master/docs/INSTALL_UNRAID.md) +- [x] [unraid](./INSTALL_UNRAID.md) - [ ] ESXI - [ ] Proxmox - [ ] Synology - [ ] OMV - [ ] Amahi - [ ] Running in a LXC container +- [ ] [PFSense](./INSTALL_UNRAID.md) From 6e64ae09aacd878f4fd462429067cc0432012986 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Wed, 1 Jun 2022 16:39:46 -0700 Subject: [PATCH 5/7] Update SUPPORTED_NAS_OS.md --- docs/SUPPORTED_NAS_OS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/SUPPORTED_NAS_OS.md b/docs/SUPPORTED_NAS_OS.md index 123c190..483043a 100644 --- a/docs/SUPPORTED_NAS_OS.md +++ b/docs/SUPPORTED_NAS_OS.md @@ -11,5 +11,6 @@ Once a guide is created (in `docs/guides/`) it will be linked here. - [ ] OMV - [ ] Amahi - [ ] Running in a LXC container -- [ ] [PFSense](./INSTALL_UNRAID.md) +- [x] [PFSense](./INSTALL_UNRAID.md) +- [ ] QNAP From 165f98dc09a8a29191a4844142ad026c4ae82e09 Mon Sep 17 00:00:00 2001 From: Michael Shamoon <4887959+shamoon@users.noreply.github.com> Date: Fri, 3 Jun 2022 00:20:14 -0700 Subject: [PATCH 6/7] Add settings UI for dark mode --- .../@treo/services/config/config.service.ts | 24 +++++++++++++++++-- .../src/app/core/config/app.config.ts | 4 ++++ .../dashboard-settings.component.html | 15 ++++++++++++ .../dashboard-settings.component.ts | 10 +++++++- 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/webapp/frontend/src/@treo/services/config/config.service.ts b/webapp/frontend/src/@treo/services/config/config.service.ts index b1501f5..8bce7bc 100644 --- a/webapp/frontend/src/@treo/services/config/config.service.ts +++ b/webapp/frontend/src/@treo/services/config/config.service.ts @@ -2,6 +2,7 @@ import { Inject, Injectable } from '@angular/core'; import { BehaviorSubject, Observable } from 'rxjs'; import * as _ from 'lodash'; import { TREO_APP_CONFIG } from '@treo/services/config/config.constants'; +import { AppConfig } from 'app/core/config/app.config'; const SCRUTINY_CONFIG_LOCAL_STORAGE_KEY = 'scrutiny'; @@ -12,20 +13,26 @@ export class TreoConfigService { // Private private _config: BehaviorSubject; + private systemPrefersDark: boolean; + /** * Constructor */ constructor(@Inject(TREO_APP_CONFIG) defaultConfig: any) { + this.systemPrefersDark = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches; + let currentScrutinyConfig = defaultConfig let localConfigStr = localStorage.getItem(SCRUTINY_CONFIG_LOCAL_STORAGE_KEY) - if(localConfigStr){ + if (localConfigStr){ //check localstorage for a value let localConfig = JSON.parse(localConfigStr) currentScrutinyConfig = localConfig } + currentScrutinyConfig.theme = this.determineTheme(currentScrutinyConfig); + // Set the private defaults this._config = new BehaviorSubject(currentScrutinyConfig); } @@ -41,10 +48,12 @@ export class TreoConfigService set config(value: any) { // Merge the new config over to the current config - const config = _.merge({}, this._config.getValue(), value); + let config = _.merge({}, this._config.getValue(), value); //Store the config in localstorage localStorage.setItem(SCRUTINY_CONFIG_LOCAL_STORAGE_KEY, JSON.stringify(config)); + + config.theme = this.determineTheme(config); // Execute the observable this._config.next(config); @@ -56,6 +65,17 @@ export class TreoConfigService return this._config.asObservable(); } + // ----------------------------------------------------------------------------------------------------- + // @ Private methods + // ----------------------------------------------------------------------------------------------------- + + /** + * Checks if theme should be set to dark based on config & system settings + */ + private determineTheme(config:AppConfig): string { + return (config.darkModeUseSystem && this.systemPrefersDark) ? "dark" : config.theme; + } + // ----------------------------------------------------------------------------------------------------- // @ Public methods // ----------------------------------------------------------------------------------------------------- diff --git a/webapp/frontend/src/app/core/config/app.config.ts b/webapp/frontend/src/app/core/config/app.config.ts index 39ba1ca..913292c 100644 --- a/webapp/frontend/src/app/core/config/app.config.ts +++ b/webapp/frontend/src/app/core/config/app.config.ts @@ -17,6 +17,8 @@ export interface AppConfig dashboardSort: string; temperatureUnit: string; + + darkModeUseSystem: boolean; } /** @@ -35,5 +37,7 @@ export const appConfig: AppConfig = { dashboardSort: "status", temperatureUnit: "celsius", + + darkModeUseSystem: true, }; diff --git a/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.html b/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.html index 37099bb..682a91e 100644 --- a/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.html +++ b/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.html @@ -2,6 +2,21 @@
+
+ Use system settings for dark mode +

+ Theme: + + + light_mode + + + dark_mode + + +

+
+
Display Title diff --git a/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.ts b/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.ts index 1ec2f69..1efd9e8 100644 --- a/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.ts +++ b/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.ts @@ -13,7 +13,9 @@ export class DashboardSettingsComponent implements OnInit { dashboardDisplay: string; dashboardSort: string; - temperatureUnit: string + temperatureUnit: string; + darkModeUseSystem: boolean; + theme: string; // Private private _unsubscribeAll: Subject; @@ -35,7 +37,11 @@ export class DashboardSettingsComponent implements OnInit { this.dashboardDisplay = config.dashboardDisplay; this.dashboardSort = config.dashboardSort; this.temperatureUnit = config.temperatureUnit; + this.darkModeUseSystem = config.darkModeUseSystem; + this.theme = config.theme; + }); + } saveSettings(): void { @@ -43,6 +49,8 @@ export class DashboardSettingsComponent implements OnInit { dashboardDisplay: this.dashboardDisplay, dashboardSort: this.dashboardSort, temperatureUnit: this.temperatureUnit, + darkModeUseSystem: this.darkModeUseSystem, + theme: this.theme } this._configService.config = newSettings console.log(`Saved Settings: ${JSON.stringify(newSettings)}`) From 8051ad4dde8c525be597195fb3be82ec36dcda20 Mon Sep 17 00:00:00 2001 From: Michael Shamoon <4887959+shamoon@users.noreply.github.com> Date: Fri, 3 Jun 2022 00:40:18 -0700 Subject: [PATCH 7/7] Tweak / fix some dark mode colors Update styles.scss --- .../dashboard-settings.component.html | 24 +++++++++---------- webapp/frontend/src/styles/styles.scss | 12 ++++++++++ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.html b/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.html index 682a91e..2ef214f 100644 --- a/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.html +++ b/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.html @@ -53,24 +53,24 @@ -
+
- Critical Error Threshold + Critical Error Threshold - Critical Warning Threshold + Critical Warning Threshold
-
+
- Error Threshold + Error Threshold - Warning Threshold + Warning Threshold
@@ -78,26 +78,26 @@ -
+
- Critical Error Threshold + Critical Error Threshold - Critical Warning Threshold + Critical Warning Threshold
-
+
- Critical Error Threshold + Critical Error Threshold - Critical Warning Threshold + Critical Warning Threshold
diff --git a/webapp/frontend/src/styles/styles.scss b/webapp/frontend/src/styles/styles.scss index e86eb52..c200595 100644 --- a/webapp/frontend/src/styles/styles.scss +++ b/webapp/frontend/src/styles/styles.scss @@ -4,3 +4,15 @@ // @ Styles from this file will override anything from 'vendors.scss' file allowing customizations and // modifications of third party libraries. // ----------------------------------------------------------------------------------------------------- + +.treo-theme-dark .yellow-50 { + background-color: #242b38 !important; + + .mat-icon { + color: #6f4315 !important; + } + + .text-secondary { + color: rgb(203 101 37 / 70%) !important + } +} \ No newline at end of file