What a sexy pre-commit config file !

This commit is contained in:
nicolargo
2025-11-22 18:48:13 +01:00
parent 868aa0f4b1
commit 50818213b1
58 changed files with 8489 additions and 7673 deletions

View File

@@ -1,36 +1,105 @@
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.24.2
hooks:
- id: gitleaks
name: "🔒 security · Detect hardcoded secrets"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.1
hooks:
# Run the linter.
- id: ruff-check
name: "🐍 python · Linter with Ruff"
types_or: [ python, pyi ]
args: [ --fix, --exit-non-zero-on-fix ]
# Run the formatter.
- id: ruff-format
name: "🐍 python · Format with Ruff"
types_or: [ python, pyi ]
# - repo: https://github.com/RobertCraigie/pyright-python
# rev: v1.1.391
# hooks:
# - id: pyright
# name: "🐍 python · Check types"
# - repo: https://github.com/biomejs/pre-commit
# rev: "v2.3.7"
# hooks:
# - id: biome-check
# name: "🟨 javascript · Lint, format, and safe fixes with Biome"
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.35.0
hooks:
- id: check-github-workflows
name: "🐙 github-actions · Validate gh workflow files"
args: ["--verbose"]
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.11.0.1
hooks:
- id: shellcheck
name: "🐚 shell · Lint shell scripts"
- repo: https://github.com/openstack/bashate
rev: 2.1.1
hooks:
- id: bashate
name: "🐚 shell · Check shell script code style"
entry: bashate --error . --ignore=E006
- repo: https://github.com/mrtazz/checkmake.git
rev: 0.2.2
hooks:
- id: checkmake
name: "🐮 Makefile · Lint Makefile"
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-ast
- id: check-docstring-first
- id: check-json
- id: check-merge-conflict
- id: check-executables-have-shebangs
name: "📁 filesystem/⚙️ exec · Verify shebang presence"
- id: check-shebang-scripts-are-executable
name: "📁 filesystem/⚙️ exec · Verify script permissions"
- id: check-case-conflict
name: "📁 filesystem/📝 names · Check case sensitivity"
- id: destroyed-symlinks
name: "📁 filesystem/🔗 symlink · Detect broken symlinks"
- id: check-merge-conflict
name: "🌳 git · Detect conflict markers"
- id: forbid-new-submodules
name: "🌳 git · Prevent submodule creation"
- id: no-commit-to-branch
name: "🌳 git · Protect main branches"
args: ["--branch", "main", "--branch", "master"]
- id: check-added-large-files
name: "🌳 git · Block large file commits"
args: ['--maxkb=5000']
- id: check-ast
name: "🐍 python/🔍 quality · Validate Python AST"
- id: check-docstring-first
name: "🐍 python/📝 style · Enforce docstring at top"
- id: check-json
name: "📄 formats/json · Validate JSON files"
- id: check-shebang-scripts-are-executable
name: "📁 filesystem/⚙️ exec · Ensure scripts are executable"
- id: check-toml
name: "📄 formats/toml · Validate TOML files"
- id: check-yaml
name: "📄 formats/yaml · Validate YAML syntax"
- id: debug-statements
name: "🐍 python/🪲 debug · Detect debug statements"
- id: detect-private-key
name: "🔐 security · Detect private keys"
- id: mixed-line-ending
name: "📄 text/↩️ newline · Normalize line endings"
- id: requirements-txt-fixer
name: "🐍 python/📦 deps · Sort requirements.txt"
- repo: local
hooks:
# test duplicate line at the end of file with a custom script
# /bin/bash tests-data/tools/find-duplicate-lines.sh
- id: find-duplicate-lines
name: find duplicate lines at the end of file
name: "❗local script · Find duplicate lines at the end of file"
entry: bash tests-data/tools/find-duplicate-lines.sh
language: system
types: [python]

View File

@@ -20,14 +20,12 @@ UV_RUN := .venv-uv/bin/uv
# if the command is only `make`, the default tasks will be the printing of the help.
.DEFAULT_GOAL := help
.PHONY: help test docs docs-server venv
.PHONY: help test docs docs-server venv requirements profiling docker all clean
help: ## List all make commands available
@grep -E '^[\.a-zA-Z_%-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk -F ":" '{print $1}' | \
grep -v % | \
sed 's/\\//g' | \
sort | \
grep -v % | sed 's/\\//g' | sort | \
awk 'BEGIN {FS = ":[^:]*?##"}; {printf "\033[1;34mmake %-50s\033[0m %s\n", $$1, $$2}'
# ===================================================================
@@ -142,7 +140,10 @@ test-exports: test-export-csv test-export-json test-export-influxdb-v1 test-expo
# Linters, profilers and cyber security
# ===================================================================
find-duplicate-lines:
pre-commit: ## Run pre-commit hooks
$(UV_RUN) run pre-commit run --all-files
find-duplicate-lines: ## Search for duplicate lines in files
/bin/bash tests-data/tools/find-duplicate-lines.sh
format: ## Format the code

View File

File diff suppressed because it is too large Load Diff

View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,22 +1,24 @@
{
"version": 1,
"disable_existing_loggers": "False",
"root": {"level": "INFO", "handlers": ["console"]},
"formatters": {
"standard": {"format": "%(asctime)s -- %(levelname)s -- %(message)s"},
"short": {"format": "%(levelname)s -- %(message)s"},
"long": {"format": "%(asctime)s -- %(levelname)s -- %(message)s (%(funcName)s in %(filename)s)"},
"free": {"format": "%(message)s"}
},
"handlers": {
"console": {"class": "logging.StreamHandler", "formatter": "standard"}
},
"loggers": {
"debug": {"handlers": ["console"], "level": "DEBUG"},
"verbose": {"handlers": ["console"], "level": "INFO"},
"standard": {"handlers": ["console"], "level": "INFO"},
"requests": {"handlers": ["console"], "level": "ERROR"},
"elasticsearch": {"handlers": ["console"], "level": "ERROR"},
"elasticsearch.trace": {"handlers": ["console"], "level": "ERROR"}
}
}
"version": 1,
"disable_existing_loggers": "False",
"root": { "level": "INFO", "handlers": ["console"] },
"formatters": {
"standard": { "format": "%(asctime)s -- %(levelname)s -- %(message)s" },
"short": { "format": "%(levelname)s -- %(message)s" },
"long": {
"format": "%(asctime)s -- %(levelname)s -- %(message)s (%(funcName)s in %(filename)s)"
},
"free": { "format": "%(message)s" }
},
"handlers": {
"console": { "class": "logging.StreamHandler", "formatter": "standard" }
},
"loggers": {
"debug": { "handlers": ["console"], "level": "DEBUG" },
"verbose": { "handlers": ["console"], "level": "INFO" },
"standard": { "handlers": ["console"], "level": "INFO" },
"requests": { "handlers": ["console"], "level": "ERROR" },
"elasticsearch": { "handlers": ["console"], "level": "ERROR" },
"elasticsearch.trace": { "handlers": ["console"], "level": "ERROR" }
}
}

View File

File diff suppressed because one or more lines are too long

View File

@@ -1,2 +1,5 @@
#!/bin/sh
make clean
make html
LC_ALL=C make man

View File

@@ -1,10 +1,10 @@
module.exports = {
printWidth: 100,
arrowParens: 'always',
bracketSpacing: true,
semi: true,
singleQuote: true,
tabWidth: 4,
trailingComma: 'none',
useTabs: false
printWidth: 100,
arrowParens: "always",
bracketSpacing: true,
semi: true,
singleQuote: true,
tabWidth: 4,
trailingComma: "none",
useTabs: false,
};

View File

@@ -1,29 +1,29 @@
import eslint from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import eslintPluginVue from 'eslint-plugin-vue';
import globals from 'globals';
import typescriptEslint from 'typescript-eslint';
import eslint from "@eslint/js";
import eslintConfigPrettier from "eslint-config-prettier";
import eslintPluginVue from "eslint-plugin-vue";
import globals from "globals";
import typescriptEslint from "typescript-eslint";
export default typescriptEslint.config(
{ ignores: ['*.d.ts', '**/coverage', '**/dist'] },
{
extends: [
eslint.configs.recommended,
...typescriptEslint.configs.recommended,
...eslintPluginVue.configs['flat/recommended'],
],
files: ['**/*.{ts,vue}'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: globals.browser,
parserOptions: {
parser: typescriptEslint.parser,
},
},
rules: {
// your rules
},
},
eslintConfigPrettier
{ ignores: ["*.d.ts", "**/coverage", "**/dist"] },
{
extends: [
eslint.configs.recommended,
...typescriptEslint.configs.recommended,
...eslintPluginVue.configs["flat/recommended"],
],
files: ["**/*.{ts,vue}"],
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
globals: globals.browser,
parserOptions: {
parser: typescriptEslint.parser,
},
},
rules: {
// your rules
},
},
eslintConfigPrettier,
);

View File

@@ -90,329 +90,335 @@
</template>
<script>
import hotkeys from 'hotkeys-js';
import { GlancesStats } from './services.js';
import { store } from './store.js';
import hotkeys from "hotkeys-js";
import GlancesHelp from "./components/help.vue";
import GlancesPluginAlert from "./components/plugin-alert.vue";
import GlancesPluginCloud from "./components/plugin-cloud.vue";
import GlancesPluginConnections from "./components/plugin-connections.vue";
import GlancesPluginContainers from "./components/plugin-containers.vue";
import GlancesPluginCpu from "./components/plugin-cpu.vue";
import GlancesPluginDiskio from "./components/plugin-diskio.vue";
import GlancesPluginFolders from "./components/plugin-folders.vue";
import GlancesPluginFs from "./components/plugin-fs.vue";
import GlancesPluginGpu from "./components/plugin-gpu.vue";
import GlancesPluginHostname from "./components/plugin-hostname.vue";
import GlancesPluginIp from "./components/plugin-ip.vue";
import GlancesPluginIrq from "./components/plugin-irq.vue";
import GlancesPluginLoad from "./components/plugin-load.vue";
import GlancesPluginMem from "./components/plugin-mem.vue";
import GlancesPluginMemswap from "./components/plugin-memswap.vue";
import GlancesPluginNetwork from "./components/plugin-network.vue";
import GlancesPluginNow from "./components/plugin-now.vue";
import GlancesPluginPercpu from "./components/plugin-percpu.vue";
import GlancesPluginPorts from "./components/plugin-ports.vue";
import GlancesPluginProcess from "./components/plugin-process.vue";
import GlancesPluginQuicklook from "./components/plugin-quicklook.vue";
import GlancesPluginRaid from "./components/plugin-raid.vue";
import GlancesPluginSensors from "./components/plugin-sensors.vue";
import GlancesPluginSmart from "./components/plugin-smart.vue";
import GlancesPluginSystem from "./components/plugin-system.vue";
import GlancesPluginUptime from "./components/plugin-uptime.vue";
import GlancesPluginVms from "./components/plugin-vms.vue";
import GlancesPluginWifi from "./components/plugin-wifi.vue";
import { GlancesStats } from "./services.js";
import { store } from "./store.js";
import GlancesHelp from './components/help.vue';
import GlancesPluginAlert from './components/plugin-alert.vue';
import GlancesPluginCloud from './components/plugin-cloud.vue';
import GlancesPluginConnections from './components/plugin-connections.vue';
import GlancesPluginCpu from './components/plugin-cpu.vue';
import GlancesPluginDiskio from './components/plugin-diskio.vue';
import GlancesPluginContainers from './components/plugin-containers.vue';
import GlancesPluginFolders from './components/plugin-folders.vue';
import GlancesPluginFs from './components/plugin-fs.vue';
import GlancesPluginGpu from './components/plugin-gpu.vue';
import GlancesPluginHostname from './components/plugin-hostname.vue';
import GlancesPluginIp from './components/plugin-ip.vue';
import GlancesPluginIrq from './components/plugin-irq.vue';
import GlancesPluginLoad from './components/plugin-load.vue';
import GlancesPluginMem from './components/plugin-mem.vue';
import GlancesPluginMemswap from './components/plugin-memswap.vue';
import GlancesPluginNetwork from './components/plugin-network.vue';
import GlancesPluginNow from './components/plugin-now.vue';
import GlancesPluginPercpu from './components/plugin-percpu.vue';
import GlancesPluginPorts from './components/plugin-ports.vue';
import GlancesPluginProcess from './components/plugin-process.vue';
import GlancesPluginQuicklook from './components/plugin-quicklook.vue';
import GlancesPluginRaid from './components/plugin-raid.vue';
import GlancesPluginSmart from './components/plugin-smart.vue';
import GlancesPluginSensors from './components/plugin-sensors.vue';
import GlancesPluginSystem from './components/plugin-system.vue';
import GlancesPluginUptime from './components/plugin-uptime.vue';
import GlancesPluginVms from './components/plugin-vms.vue';
import GlancesPluginWifi from './components/plugin-wifi.vue';
import uiconfig from './uiconfig.json';
import uiconfig from "./uiconfig.json";
export default {
components: {
GlancesHelp,
GlancesPluginAlert,
GlancesPluginCloud,
GlancesPluginConnections,
GlancesPluginCpu,
GlancesPluginDiskio,
GlancesPluginContainers,
GlancesPluginFolders,
GlancesPluginFs,
GlancesPluginGpu,
GlancesPluginHostname,
GlancesPluginIp,
GlancesPluginIrq,
GlancesPluginLoad,
GlancesPluginMem,
GlancesPluginMemswap,
GlancesPluginNetwork,
GlancesPluginNow,
GlancesPluginPercpu,
GlancesPluginPorts,
GlancesPluginProcess,
GlancesPluginQuicklook,
GlancesPluginRaid,
GlancesPluginSensors,
GlancesPluginSmart,
GlancesPluginSystem,
GlancesPluginUptime,
GlancesPluginVms,
GlancesPluginWifi
},
data() {
return {
store
};
},
computed: {
args() {
return this.store.args || {};
},
config() {
return this.store.config || {};
},
data() {
return this.store.data || {};
},
dataLoaded() {
return this.store.data !== undefined;
},
hasGpu() {
return this.store.data.stats.gpu.length > 0;
},
isLinux() {
return this.store.data.isLinux;
},
title() {
const { data } = this;
const title = (data.stats && data.stats.system && data.stats.system.hostname) || '';
return title ? `${title} - Glances` : 'Glances';
},
topMenu() {
return this.config.outputs !== undefined && this.config.outputs.top_menu !== undefined
? this.config.outputs.top_menu.split(',')
: uiconfig.topMenu;
},
leftMenu() {
return this.config.outputs !== undefined && this.config.outputs.left_menu !== undefined
? this.config.outputs.left_menu.split(',')
: uiconfig.leftMenu;
}
},
watch: {
title() {
if (document) {
document.title = this.title;
}
}
},
mounted() {
const GLANCES = window.__GLANCES__ || {};
const refreshTime = isFinite(GLANCES['refresh-time'])
? parseInt(GLANCES['refresh-time'], 10)
: undefined;
GlancesStats.init(refreshTime);
this.setupHotKeys();
},
beforeUnmount() {
hotkeys.unbind();
},
methods: {
setupHotKeys() {
// a => Sort processes/containers automatically
hotkeys('a', () => {
this.store.args.sort_processes_key = null;
});
components: {
GlancesHelp,
GlancesPluginAlert,
GlancesPluginCloud,
GlancesPluginConnections,
GlancesPluginCpu,
GlancesPluginDiskio,
GlancesPluginContainers,
GlancesPluginFolders,
GlancesPluginFs,
GlancesPluginGpu,
GlancesPluginHostname,
GlancesPluginIp,
GlancesPluginIrq,
GlancesPluginLoad,
GlancesPluginMem,
GlancesPluginMemswap,
GlancesPluginNetwork,
GlancesPluginNow,
GlancesPluginPercpu,
GlancesPluginPorts,
GlancesPluginProcess,
GlancesPluginQuicklook,
GlancesPluginRaid,
GlancesPluginSensors,
GlancesPluginSmart,
GlancesPluginSystem,
GlancesPluginUptime,
GlancesPluginVms,
GlancesPluginWifi,
},
data() {
return {
store,
};
},
computed: {
args() {
return this.store.args || {};
},
config() {
return this.store.config || {};
},
data() {
return this.store.data || {};
},
dataLoaded() {
return this.store.data !== undefined;
},
hasGpu() {
return this.store.data.stats.gpu.length > 0;
},
isLinux() {
return this.store.data.isLinux;
},
title() {
const { data } = this;
const title =
(data.stats && data.stats.system && data.stats.system.hostname) || "";
return title ? `${title} - Glances` : "Glances";
},
topMenu() {
return this.config.outputs !== undefined &&
this.config.outputs.top_menu !== undefined
? this.config.outputs.top_menu.split(",")
: uiconfig.topMenu;
},
leftMenu() {
return this.config.outputs !== undefined &&
this.config.outputs.left_menu !== undefined
? this.config.outputs.left_menu.split(",")
: uiconfig.leftMenu;
},
},
watch: {
title() {
if (document) {
document.title = this.title;
}
},
},
mounted() {
const GLANCES = window.__GLANCES__ || {};
const refreshTime = isFinite(GLANCES["refresh-time"])
? parseInt(GLANCES["refresh-time"], 10)
: undefined;
GlancesStats.init(refreshTime);
this.setupHotKeys();
},
beforeUnmount() {
hotkeys.unbind();
},
methods: {
setupHotKeys() {
// a => Sort processes/containers automatically
hotkeys("a", () => {
this.store.args.sort_processes_key = null;
});
// c => Sort processes/containers by CPU%
hotkeys('c', () => {
this.store.args.sort_processes_key = 'cpu_percent';
});
// c => Sort processes/containers by CPU%
hotkeys("c", () => {
this.store.args.sort_processes_key = "cpu_percent";
});
// m => Sort processes/containers by MEM%
hotkeys('m', () => {
this.store.args.sort_processes_key = 'memory_percent';
});
// m => Sort processes/containers by MEM%
hotkeys("m", () => {
this.store.args.sort_processes_key = "memory_percent";
});
// u => Sort processes/containers by user
hotkeys('u', () => {
this.store.args.sort_processes_key = 'username';
});
// u => Sort processes/containers by user
hotkeys("u", () => {
this.store.args.sort_processes_key = "username";
});
// p => Sort processes/containers by name
hotkeys('p', () => {
this.store.args.sort_processes_key = 'name';
});
// p => Sort processes/containers by name
hotkeys("p", () => {
this.store.args.sort_processes_key = "name";
});
// i => Sort processes/containers by I/O rate
hotkeys('i', () => {
this.store.args.sort_processes_key = 'io_counters';
});
// i => Sort processes/containers by I/O rate
hotkeys("i", () => {
this.store.args.sort_processes_key = "io_counters";
});
// t => Sort processes/containers by time
hotkeys('t', () => {
this.store.args.sort_processes_key = 'timemillis';
});
// t => Sort processes/containers by time
hotkeys("t", () => {
this.store.args.sort_processes_key = "timemillis";
});
// A => Enable/disable AMPs
hotkeys('shift+A', () => {
this.store.args.disable_amps = !this.store.args.disable_amps;
});
// A => Enable/disable AMPs
hotkeys("shift+A", () => {
this.store.args.disable_amps = !this.store.args.disable_amps;
});
// d => Show/hide disk I/O stats
hotkeys('d', () => {
this.store.args.disable_diskio = !this.store.args.disable_diskio;
});
// d => Show/hide disk I/O stats
hotkeys("d", () => {
this.store.args.disable_diskio = !this.store.args.disable_diskio;
});
// Q => Show/hide IRQ
hotkeys('shift+Q', () => {
this.store.args.enable_irq = !this.store.args.enable_irq;
});
// Q => Show/hide IRQ
hotkeys("shift+Q", () => {
this.store.args.enable_irq = !this.store.args.enable_irq;
});
// f => Show/hide filesystem stats
hotkeys('f', () => {
this.store.args.disable_fs = !this.store.args.disable_fs;
});
// f => Show/hide filesystem stats
hotkeys("f", () => {
this.store.args.disable_fs = !this.store.args.disable_fs;
});
// j => Accumulate processes by program
hotkeys('j', () => {
this.store.args.programs = !this.store.args.programs;
});
// j => Accumulate processes by program
hotkeys("j", () => {
this.store.args.programs = !this.store.args.programs;
});
// k => Show/hide connections stats
hotkeys('k', () => {
this.store.args.disable_connections = !this.store.args.disable_connections;
});
// k => Show/hide connections stats
hotkeys("k", () => {
this.store.args.disable_connections =
!this.store.args.disable_connections;
});
// n => Show/hide network stats
hotkeys('n', () => {
this.store.args.disable_network = !this.store.args.disable_network;
});
// n => Show/hide network stats
hotkeys("n", () => {
this.store.args.disable_network = !this.store.args.disable_network;
});
// s => Show/hide sensors stats
hotkeys('s', () => {
this.store.args.disable_sensors = !this.store.args.disable_sensors;
});
// s => Show/hide sensors stats
hotkeys("s", () => {
this.store.args.disable_sensors = !this.store.args.disable_sensors;
});
// 2 => Show/hide left sidebar
hotkeys('2', () => {
this.store.args.disable_left_sidebar = !this.store.args.disable_left_sidebar;
});
// 2 => Show/hide left sidebar
hotkeys("2", () => {
this.store.args.disable_left_sidebar =
!this.store.args.disable_left_sidebar;
});
// z => Enable/disable processes stats
hotkeys('z', () => {
this.store.args.disable_process = !this.store.args.disable_process;
});
// z => Enable/disable processes stats
hotkeys("z", () => {
this.store.args.disable_process = !this.store.args.disable_process;
});
// S => Enable/disable short processes name
hotkeys('shift+S', () => {
this.store.args.process_short_name = !this.store.args.process_short_name;
});
// S => Enable/disable short processes name
hotkeys("shift+S", () => {
this.store.args.process_short_name =
!this.store.args.process_short_name;
});
// D => Enable/disable containers stats
hotkeys('shift+D', () => {
this.store.args.disable_containers = !this.store.args.disable_containers;
});
// D => Enable/disable containers stats
hotkeys("shift+D", () => {
this.store.args.disable_containers =
!this.store.args.disable_containers;
});
// b => Bytes or bits for network I/O
hotkeys('b', () => {
this.store.args.byte = !this.store.args.byte;
});
// b => Bytes or bits for network I/O
hotkeys("b", () => {
this.store.args.byte = !this.store.args.byte;
});
// 'B' => Switch between bit/s and IO/s for Disk IO
hotkeys('shift+B', () => {
this.store.args.diskio_iops = !this.store.args.diskio_iops;
if (this.store.args.diskio_iops) {
this.store.args.diskio_latency = false;
}
});
// 'B' => Switch between bit/s and IO/s for Disk IO
hotkeys("shift+B", () => {
this.store.args.diskio_iops = !this.store.args.diskio_iops;
if (this.store.args.diskio_iops) {
this.store.args.diskio_latency = false;
}
});
// 'L' => Switch to latency for Disk IO
hotkeys('shift+L', () => {
this.store.args.diskio_latency = !this.store.args.diskio_latency;
if (this.store.args.diskio_latency) {
this.store.args.diskio_iops = false;
}
});
// 'L' => Switch to latency for Disk IO
hotkeys("shift+L", () => {
this.store.args.diskio_latency = !this.store.args.diskio_latency;
if (this.store.args.diskio_latency) {
this.store.args.diskio_iops = false;
}
});
// l => Show/hide alert logs
hotkeys('l', () => {
this.store.args.disable_alert = !this.store.args.disable_alert;
});
// l => Show/hide alert logs
hotkeys("l", () => {
this.store.args.disable_alert = !this.store.args.disable_alert;
});
// 1 => Global CPU or per-CPU stats
hotkeys('1', () => {
this.store.args.percpu = !this.store.args.percpu;
});
// 1 => Global CPU or per-CPU stats
hotkeys("1", () => {
this.store.args.percpu = !this.store.args.percpu;
});
// h => Show/hide this help screen
hotkeys('h', () => {
this.store.args.help_tag = !this.store.args.help_tag;
});
// h => Show/hide this help screen
hotkeys("h", () => {
this.store.args.help_tag = !this.store.args.help_tag;
});
// T => View network I/O as combination
hotkeys('shift+T', () => {
this.store.args.network_sum = !this.store.args.network_sum;
});
// T => View network I/O as combination
hotkeys("shift+T", () => {
this.store.args.network_sum = !this.store.args.network_sum;
});
// U => View cumulative network I/O
hotkeys('shift+U', () => {
this.store.args.network_cumul = !this.store.args.network_cumul;
});
// U => View cumulative network I/O
hotkeys("shift+U", () => {
this.store.args.network_cumul = !this.store.args.network_cumul;
});
// F => Show filesystem free space
hotkeys('shift+F', () => {
this.store.args.fs_free_space = !this.store.args.fs_free_space;
});
// F => Show filesystem free space
hotkeys("shift+F", () => {
this.store.args.fs_free_space = !this.store.args.fs_free_space;
});
// 3 => Enable/disable quick look plugin
hotkeys('3', () => {
this.store.args.disable_quicklook = !this.store.args.disable_quicklook;
});
// 3 => Enable/disable quick look plugin
hotkeys("3", () => {
this.store.args.disable_quicklook = !this.store.args.disable_quicklook;
});
// 6 => Enable/disable mean gpu
hotkeys('6', () => {
this.store.args.meangpu = !this.store.args.meangpu;
});
// 6 => Enable/disable mean gpu
hotkeys("6", () => {
this.store.args.meangpu = !this.store.args.meangpu;
});
// G => Enable/disable gpu
hotkeys('shift+G', () => {
this.store.args.disable_gpu = !this.store.args.disable_gpu;
});
// G => Enable/disable gpu
hotkeys("shift+G", () => {
this.store.args.disable_gpu = !this.store.args.disable_gpu;
});
hotkeys('5', () => {
this.store.args.disable_quicklook = !this.store.args.disable_quicklook;
this.store.args.disable_cpu = !this.store.args.disable_cpu;
this.store.args.disable_mem = !this.store.args.disable_mem;
this.store.args.disable_memswap = !this.store.args.disable_memswap;
this.store.args.disable_load = !this.store.args.disable_load;
this.store.args.disable_gpu = !this.store.args.disable_gpu;
});
hotkeys("5", () => {
this.store.args.disable_quicklook = !this.store.args.disable_quicklook;
this.store.args.disable_cpu = !this.store.args.disable_cpu;
this.store.args.disable_mem = !this.store.args.disable_mem;
this.store.args.disable_memswap = !this.store.args.disable_memswap;
this.store.args.disable_load = !this.store.args.disable_load;
this.store.args.disable_gpu = !this.store.args.disable_gpu;
});
// I => Show/hide IP module
hotkeys('shift+I', () => {
this.store.args.disable_ip = !this.store.args.disable_ip;
});
// I => Show/hide IP module
hotkeys("shift+I", () => {
this.store.args.disable_ip = !this.store.args.disable_ip;
});
// P => Enable/disable ports module
hotkeys('shift+P', () => {
this.store.args.disable_ports = !this.store.args.disable_ports;
});
// P => Enable/disable ports module
hotkeys("shift+P", () => {
this.store.args.disable_ports = !this.store.args.disable_ports;
});
// V => Enable/disable VMs stats
hotkeys('shift+V', () => {
this.store.args.disable_vms = !this.store.args.disable_vms;
});
// V => Enable/disable VMs stats
hotkeys("shift+V", () => {
this.store.args.disable_vms = !this.store.args.disable_vms;
});
// 'W' > Enable/Disable Wifi plugin
hotkeys('shift+W', () => {
this.store.args.disable_wifi = !this.store.args.disable_wifi;
});
// 'W' > Enable/Disable Wifi plugin
hotkeys("shift+W", () => {
this.store.args.disable_wifi = !this.store.args.disable_wifi;
});
// 0 => Enable/disable IRIX mode (see issue #3158)
hotkeys('0', () => {
this.store.args.disable_irix = !this.store.args.disable_irix;
});
}
}
// 0 => Enable/disable IRIX mode (see issue #3158)
hotkeys("0", () => {
this.store.args.disable_irix = !this.store.args.disable_irix;
});
},
},
};
</script>

View File

@@ -56,54 +56,59 @@
// import { store } from './store.js';
export default {
data() {
return {
servers: undefined,
};
},
computed: {
serversListLoaded() {
return this.servers !== undefined;
},
},
created() {
this.updateServersList();
},
mounted() {
const GLANCES = window.__GLANCES__ || {};
const refreshTime = isFinite(GLANCES['refresh-time'])
? parseInt(GLANCES['refresh-time'], 10)
: undefined;
this.interval = setInterval(this.updateServersList, refreshTime * 1000)
},
unmounted() {
clearInterval(this.interval)
},
methods: {
updateServersList() {
fetch('api/4/serverslist', { method: 'GET' })
.then((response) => response.json())
.then((response) => (this.servers = response));
},
formatNumber(value) {
if (typeof value === "number" && !isNaN(value)) {
return value.toFixed(1);
}
return value;
},
goToGlances(server) {
if (server.protocol === 'rpc') {
alert("You just click on a Glances RPC server.\nPlease open a terminal and enter the following command line:\n\nglances -c " + String(server.ip) + " -p " + String(server.port))
} else {
window.location.href = server.uri;
}
},
getDecoration(server, column) {
if (server[column + '_decoration'] === undefined) {
return;
}
return server[column + '_decoration'].replace('_LOG', '').toLowerCase();
}
}
data() {
return {
servers: undefined,
};
},
computed: {
serversListLoaded() {
return this.servers !== undefined;
},
},
created() {
this.updateServersList();
},
mounted() {
const GLANCES = window.__GLANCES__ || {};
const refreshTime = isFinite(GLANCES["refresh-time"])
? parseInt(GLANCES["refresh-time"], 10)
: undefined;
this.interval = setInterval(this.updateServersList, refreshTime * 1000);
},
unmounted() {
clearInterval(this.interval);
},
methods: {
updateServersList() {
fetch("api/4/serverslist", { method: "GET" })
.then((response) => response.json())
.then((response) => (this.servers = response));
},
formatNumber(value) {
if (typeof value === "number" && !isNaN(value)) {
return value.toFixed(1);
}
return value;
},
goToGlances(server) {
if (server.protocol === "rpc") {
alert(
"You just click on a Glances RPC server.\nPlease open a terminal and enter the following command line:\n\nglances -c " +
String(server.ip) +
" -p " +
String(server.port),
);
} else {
window.location.href = server.uri;
}
},
getDecoration(server, column) {
if (server[column + "_decoration"] === undefined) {
return;
}
return server[column + "_decoration"].replace("_LOG", "").toLowerCase();
},
},
};
</script>

View File

@@ -1,17 +1,17 @@
/* global module */
if (module.hot) {
module.hot.accept();
module.hot.accept();
}
import '../css/custom.scss';
import '../css/style.scss';
import "../css/custom.scss";
import "../css/style.scss";
import * as bootstrap from 'bootstrap';
import * as bootstrap from "bootstrap";
import { createApp } from 'vue';
import App from './App.vue';
import { createApp } from "vue";
import App from "./App.vue";
import * as filters from "./filters.js";
const app = createApp(App);
app.config.globalProperties.$filters = filters;
app.mount('#app');
app.mount("#app");

View File

@@ -1,17 +1,17 @@
/* global module */
if (module.hot) {
module.hot.accept();
module.hot.accept();
}
import '../css/custom.scss';
import '../css/style.scss';
import "../css/custom.scss";
import "../css/style.scss";
import * as bootstrap from 'bootstrap';
import * as bootstrap from "bootstrap";
import { createApp } from 'vue';
import App from './Browser.vue';
import { createApp } from "vue";
import App from "./Browser.vue";
import * as filters from "./filters.js";
const app = createApp(App);
app.config.globalProperties.$filters = filters;
app.mount('#browser');
app.mount("#browser");

View File

@@ -163,15 +163,15 @@
<script>
export default {
data() {
return {
help: undefined
};
},
mounted() {
fetch('api/4/help', { method: 'GET' })
.then((response) => response.json())
.then((response) => (this.help = response));
}
data() {
return {
help: undefined,
};
},
mounted() {
fetch("api/4/help", { method: "GET" })
.then((response) => response.json())
.then((response) => (this.help = response));
},
};
</script>

View File

@@ -29,97 +29,110 @@
</template>
<script>
import { padStart } from 'lodash';
import { GlancesFavico } from '../services.js';
import { padStart } from "lodash";
import { GlancesFavico } from "../services.js";
export default {
props: {
data: {
type: Object
}
},
computed: {
stats() {
return this.data.stats['alert'];
},
alerts() {
return (this.stats || []).map((alertStats) => {
const alert = {};
alert.state = alertStats.state;
alert.type = alertStats.type;
alert.begin = alertStats.begin * 1000;
alert.end = alertStats.end * 1000;
alert.ongoing = alertStats.end == -1;
alert.min = alertStats.min;
alert.avg = alertStats.avg;
alert.max = alertStats.max;
if (alertStats.top.length > 0) {
alert.top = ': ' + alertStats.top.join(', ');
}
props: {
data: {
type: Object,
},
},
computed: {
stats() {
return this.data.stats["alert"];
},
alerts() {
return (this.stats || []).map((alertStats) => {
const alert = {};
alert.state = alertStats.state;
alert.type = alertStats.type;
alert.begin = alertStats.begin * 1000;
alert.end = alertStats.end * 1000;
alert.ongoing = alertStats.end == -1;
alert.min = alertStats.min;
alert.avg = alertStats.avg;
alert.max = alertStats.max;
if (alertStats.top.length > 0) {
alert.top = ": " + alertStats.top.join(", ");
}
if (!alert.ongoing) {
const duration = alert.end - alert.begin;
const seconds = parseInt((duration / 1000) % 60),
minutes = parseInt((duration / (1000 * 60)) % 60),
hours = parseInt((duration / (1000 * 60 * 60)) % 24);
if (!alert.ongoing) {
const duration = alert.end - alert.begin;
const seconds = parseInt((duration / 1000) % 60),
minutes = parseInt((duration / (1000 * 60)) % 60),
hours = parseInt((duration / (1000 * 60 * 60)) % 24);
alert.duration = padStart(hours, 2, '0') +
':' + padStart(minutes, 2, '0') +
':' + padStart(seconds, 2, '0');
}
alert.duration =
padStart(hours, 2, "0") +
":" +
padStart(minutes, 2, "0") +
":" +
padStart(seconds, 2, "0");
}
return alert;
});
},
hasAlerts() {
return this.countAlerts > 0;
},
countAlerts() {
return this.alerts.length;
},
hasOngoingAlerts() {
return this.countOngoingAlerts > 0;
},
countOngoingAlerts() {
return this.alerts.filter(({ ongoing }) => ongoing).length;
}
},
watch: {
countOngoingAlerts() {
if (this.countOngoingAlerts) {
GlancesFavico.badge(this.countOngoingAlerts);
} else {
GlancesFavico.reset();
}
}
},
methods: {
formatDate(timestamp) {
const tzOffset = new Date().getTimezoneOffset();
const hours = Math.trunc(Math.abs(tzOffset) / 60);
const minutes = Math.abs(tzOffset % 60);
return alert;
});
},
hasAlerts() {
return this.countAlerts > 0;
},
countAlerts() {
return this.alerts.length;
},
hasOngoingAlerts() {
return this.countOngoingAlerts > 0;
},
countOngoingAlerts() {
return this.alerts.filter(({ ongoing }) => ongoing).length;
},
},
watch: {
countOngoingAlerts() {
if (this.countOngoingAlerts) {
GlancesFavico.badge(this.countOngoingAlerts);
} else {
GlancesFavico.reset();
}
},
},
methods: {
formatDate(timestamp) {
const tzOffset = new Date().getTimezoneOffset();
const hours = Math.trunc(Math.abs(tzOffset) / 60);
const minutes = Math.abs(tzOffset % 60);
let tzString = tzOffset <= 0 ? '+' : '-';
tzString += String(hours).padStart(2, '0') + String(minutes).padStart(2, '0');
let tzString = tzOffset <= 0 ? "+" : "-";
tzString +=
String(hours).padStart(2, "0") + String(minutes).padStart(2, "0");
const date = new Date(timestamp);
return String(date.getFullYear()) +
'-' + String(date.getMonth() + 1).padStart(2, '0') +
'-' + String(date.getDate()).padStart(2, '0') +
' ' + String(date.getHours()).padStart(2, '0') +
':' + String(date.getMinutes()).padStart(2, '0') +
':' + String(date.getSeconds()).padStart(2, '0') +
'(' + tzString + ')';
},
clear() {
const requestOptions = {
method: 'POST',
headers: { 'Content-Type': 'application/json' }
};
fetch('api/4/events/clear/all', requestOptions)
.then(response => response.json())
.then(data => product.value = data);
}
}
const date = new Date(timestamp);
return (
String(date.getFullYear()) +
"-" +
String(date.getMonth() + 1).padStart(2, "0") +
"-" +
String(date.getDate()).padStart(2, "0") +
" " +
String(date.getHours()).padStart(2, "0") +
":" +
String(date.getMinutes()).padStart(2, "0") +
":" +
String(date.getSeconds()).padStart(2, "0") +
"(" +
tzString +
")"
);
},
clear() {
const requestOptions = {
method: "POST",
headers: { "Content-Type": "application/json" },
};
fetch("api/4/events/clear/all", requestOptions)
.then((response) => response.json())
.then((data) => (product.value = data));
},
},
};
</script>

View File

@@ -28,42 +28,42 @@
<script>
export default {
props: {
data: {
type: Object
}
},
computed: {
stats() {
return this.data.stats['amps'];
},
processes() {
return this.stats.filter((process) => process.result !== null);
},
hasAmps() {
return this.processes.length > 0;
}
},
methods: {
getNameDecoration(process) {
const count = process.count;
const countMin = process.countmin;
const countMax = process.countmax;
let decoration = 'ok';
if (count > 0) {
if (
(countMin === null || count >= countMin) &&
(countMax === null || count <= countMax)
) {
decoration = 'ok';
} else {
decoration = 'careful';
}
} else {
decoration = countMin === null ? 'ok' : 'critical';
}
return decoration;
}
}
props: {
data: {
type: Object,
},
},
computed: {
stats() {
return this.data.stats["amps"];
},
processes() {
return this.stats.filter((process) => process.result !== null);
},
hasAmps() {
return this.processes.length > 0;
},
},
methods: {
getNameDecoration(process) {
const count = process.count;
const countMin = process.countmin;
const countMax = process.countmax;
let decoration = "ok";
if (count > 0) {
if (
(countMin === null || count >= countMin) &&
(countMax === null || count <= countMax)
) {
decoration = "ok";
} else {
decoration = "careful";
}
} else {
decoration = countMin === null ? "ok" : "critical";
}
return decoration;
},
},
};
</script>

View File

@@ -6,24 +6,24 @@
<script>
export default {
props: {
data: {
type: Object
}
},
computed: {
stats() {
return this.data.stats['cloud'];
},
provider() {
return this.stats['id'] !== undefined ? `${stats['platform']}` : null;
},
instance() {
const { stats } = this;
return this.stats['id'] !== undefined
? `${stats['type']} instance ${stats['name']} (${stats['region']})`
: null;
}
}
props: {
data: {
type: Object,
},
},
computed: {
stats() {
return this.data.stats["cloud"];
},
provider() {
return this.stats["id"] !== undefined ? `${stats["platform"]}` : null;
},
instance() {
const { stats } = this;
return this.stats["id"] !== undefined
? `${stats["type"]} instance ${stats["name"]} (${stats["region"]})`
: null;
},
},
};
</script>

View File

@@ -37,44 +37,44 @@
<script>
export default {
props: {
data: {
type: Object
}
},
computed: {
stats() {
return this.data.stats['connections'];
},
view() {
return this.data.views['connections'];
},
listen() {
return this.stats['LISTEN'];
},
initiated() {
return this.stats['initiated'];
},
established() {
return this.stats['ESTABLISHED'];
},
terminated() {
return this.stats['terminated'];
},
tracked() {
return {
count: this.stats['nf_conntrack_count'],
max: this.stats['nf_conntrack_max']
};
}
},
methods: {
getDecoration(value) {
if (this.view[value] === undefined) {
return;
}
return this.view[value].decoration.toLowerCase();
}
}
props: {
data: {
type: Object,
},
},
computed: {
stats() {
return this.data.stats["connections"];
},
view() {
return this.data.views["connections"];
},
listen() {
return this.stats["LISTEN"];
},
initiated() {
return this.stats["initiated"];
},
established() {
return this.stats["ESTABLISHED"];
},
terminated() {
return this.stats["terminated"];
},
tracked() {
return {
count: this.stats["nf_conntrack_count"],
max: this.stats["nf_conntrack_max"],
};
},
},
methods: {
getDecoration(value) {
if (this.view[value] === undefined) {
return;
}
return this.view[value].decoration.toLowerCase();
},
},
};
</script>

View File

@@ -177,122 +177,124 @@
</template>
<script>
import { orderBy } from 'lodash';
import { GlancesHelper } from '../services.js';
import { store } from '../store.js';
import { orderBy } from "lodash";
import { GlancesHelper } from "../services.js";
import { store } from "../store.js";
export default {
props: {
data: {
type: Object
}
},
data() {
return {
store,
sorter: undefined
};
},
computed: {
args() {
return this.store.args || {};
},
sortProcessesKey() {
return this.args.sort_processes_key;
},
stats() {
return this.data.stats['containers'];
},
views() {
return this.data.views['containers'];
},
containers() {
const { sorter } = this;
const containers = (this.stats || []) //
.map((containerData) => {
// Memory usage no cache is reflected the algorithm used in Docker top
let memory_usage_no_cache;
props: {
data: {
type: Object,
},
},
data() {
return {
store,
sorter: undefined,
};
},
computed: {
args() {
return this.store.args || {};
},
sortProcessesKey() {
return this.args.sort_processes_key;
},
stats() {
return this.data.stats["containers"];
},
views() {
return this.data.views["containers"];
},
containers() {
const { sorter } = this;
const containers = (this.stats || []) //
.map((containerData) => {
// Memory usage no cache is reflected the algorithm used in Docker top
let memory_usage_no_cache;
if (containerData.memory_usage != undefined) {
memory_usage_no_cache = containerData.memory_usage;
if (containerData.memory_inactive_file != undefined) {
memory_usage_no_cache =
memory_usage_no_cache - containerData.memory_inactive_file;
}
} else {
memory_usage_no_cache = undefined;
}
if (containerData.memory_usage != undefined) {
memory_usage_no_cache = containerData.memory_usage;
if (containerData.memory_inactive_file != undefined) {
memory_usage_no_cache =
memory_usage_no_cache - containerData.memory_inactive_file;
}
} else {
memory_usage_no_cache = undefined;
}
return {
id: containerData.id,
name: containerData.name,
status: containerData.status,
uptime: containerData.uptime,
cpu_percent: containerData.cpu.total,
memory_usage: memory_usage_no_cache,
limit: containerData.memory.limit,
io_rx: containerData.io_rx,
io_wx: containerData.io_wx,
network_rx: containerData.network_rx,
network_tx: containerData.network_tx,
ports: containerData.ports,
command: containerData.command,
image: containerData.image,
engine: containerData.engine,
pod_id: containerData.pod_id
};
});
return orderBy(
containers,
[sorter.column].map((col) => {
const sorter = (item) =>
item[col === 'memory_percent' ? 'memory_usage' : col] ?? -Infinity;
return sorter;
}, []),
[sorter.isReverseColumn(sorter.column) ? 'desc' : 'asc']
);
},
showEngine() {
return this.views.show_engine_name;
},
showPod() {
return this.views.show_pod_name;
}
},
watch: {
sortProcessesKey: {
immediate: true,
handler(sortProcessesKey) {
const sortable = ['cpu_percent', 'memory_percent', 'name'];
function isReverseColumn(column) {
return !['name'].includes(column);
}
function getColumnLabel(value) {
const labels = {
io_counters: 'disk IO',
cpu_percent: 'CPU consumption',
memory_usage: 'memory consumption',
cpu_times: 'uptime',
name: 'container name',
None: 'None'
};
return labels[value] || value;
}
if (!sortProcessesKey || sortable.includes(sortProcessesKey)) {
this.sorter = {
column: this.args.sort_processes_key || 'cpu_percent',
auto: !this.args.sort_processes_key,
isReverseColumn,
getColumnLabel
};
}
}
}
},
methods: {
getDisableStats() {
return GlancesHelper.getLimit('containers', 'containers_disable_stats') || [];
}
}
return {
id: containerData.id,
name: containerData.name,
status: containerData.status,
uptime: containerData.uptime,
cpu_percent: containerData.cpu.total,
memory_usage: memory_usage_no_cache,
limit: containerData.memory.limit,
io_rx: containerData.io_rx,
io_wx: containerData.io_wx,
network_rx: containerData.network_rx,
network_tx: containerData.network_tx,
ports: containerData.ports,
command: containerData.command,
image: containerData.image,
engine: containerData.engine,
pod_id: containerData.pod_id,
};
});
return orderBy(
containers,
[sorter.column].map((col) => {
const sorter = (item) =>
item[col === "memory_percent" ? "memory_usage" : col] ?? -Infinity;
return sorter;
}, []),
[sorter.isReverseColumn(sorter.column) ? "desc" : "asc"],
);
},
showEngine() {
return this.views.show_engine_name;
},
showPod() {
return this.views.show_pod_name;
},
},
watch: {
sortProcessesKey: {
immediate: true,
handler(sortProcessesKey) {
const sortable = ["cpu_percent", "memory_percent", "name"];
function isReverseColumn(column) {
return !["name"].includes(column);
}
function getColumnLabel(value) {
const labels = {
io_counters: "disk IO",
cpu_percent: "CPU consumption",
memory_usage: "memory consumption",
cpu_times: "uptime",
name: "container name",
None: "None",
};
return labels[value] || value;
}
if (!sortProcessesKey || sortable.includes(sortProcessesKey)) {
this.sorter = {
column: this.args.sort_processes_key || "cpu_percent",
auto: !this.args.sort_processes_key,
isReverseColumn,
getColumnLabel,
};
}
},
},
},
methods: {
getDisableStats() {
return (
GlancesHelper.getLimit("containers", "containers_disable_stats") || []
);
},
},
};
</script>

View File

@@ -122,85 +122,89 @@ v-if="!isWindows && !isSunOS && soft_interrupts != undefined" scope="col"
<script>
export default {
props: {
data: {
type: Object
}
},
computed: {
stats() {
return this.data.stats['cpu'];
},
view() {
return this.data.views['cpu'];
},
isLinux() {
return this.data.isLinux;
},
isSunOS() {
return this.data.isSunOS;
},
isWindows() {
return this.data.isWindows;
},
total() {
return this.stats.total;
},
user() {
return this.stats.user;
},
system() {
return this.stats.system;
},
idle() {
return this.stats.idle;
},
nice() {
return this.stats.nice;
},
irq() {
return this.stats.irq;
},
iowait() {
return this.stats.iowait;
},
dpc() {
return this.stats.dpc;
},
steal() {
return this.stats.steal;
},
guest() {
return this.stats.guest;
},
ctx_switches() {
const { stats } = this;
return stats.ctx_switches
? Math.floor(stats.ctx_switches / stats.time_since_update)
: null;
},
interrupts() {
const { stats } = this;
return stats.interrupts ? Math.floor(stats.interrupts / stats.time_since_update) : null;
},
soft_interrupts() {
const { stats } = this;
return stats.soft_interrupts
? Math.floor(stats.soft_interrupts / stats.time_since_update)
: null;
},
syscalls() {
const { stats } = this;
return stats.syscalls ? Math.floor(stats.syscalls / stats.time_since_update) : null;
}
},
methods: {
getDecoration(value) {
if (this.view[value] === undefined) {
return;
}
return this.view[value].decoration.toLowerCase();
}
}
props: {
data: {
type: Object,
},
},
computed: {
stats() {
return this.data.stats["cpu"];
},
view() {
return this.data.views["cpu"];
},
isLinux() {
return this.data.isLinux;
},
isSunOS() {
return this.data.isSunOS;
},
isWindows() {
return this.data.isWindows;
},
total() {
return this.stats.total;
},
user() {
return this.stats.user;
},
system() {
return this.stats.system;
},
idle() {
return this.stats.idle;
},
nice() {
return this.stats.nice;
},
irq() {
return this.stats.irq;
},
iowait() {
return this.stats.iowait;
},
dpc() {
return this.stats.dpc;
},
steal() {
return this.stats.steal;
},
guest() {
return this.stats.guest;
},
ctx_switches() {
const { stats } = this;
return stats.ctx_switches
? Math.floor(stats.ctx_switches / stats.time_since_update)
: null;
},
interrupts() {
const { stats } = this;
return stats.interrupts
? Math.floor(stats.interrupts / stats.time_since_update)
: null;
},
soft_interrupts() {
const { stats } = this;
return stats.soft_interrupts
? Math.floor(stats.soft_interrupts / stats.time_since_update)
: null;
},
syscalls() {
const { stats } = this;
return stats.syscalls
? Math.floor(stats.syscalls / stats.time_since_update)
: null;
},
},
methods: {
getDecoration(value) {
if (this.view[value] === undefined) {
return;
}
return this.view[value].decoration.toLowerCase();
},
},
};
</script>

View File

@@ -46,71 +46,78 @@
</template>
<script>
import { orderBy } from 'lodash';
import { store } from '../store.js';
import { bytes } from '../filters.js';
import { orderBy } from "lodash";
import { bytes } from "../filters.js";
import { store } from "../store.js";
export default {
props: {
data: {
type: Object
}
},
data() {
return {
store
};
},
computed: {
args() {
return this.store.args || {};
},
stats() {
return this.data.stats['diskio'];
},
view() {
return this.data.views['diskio'];
},
disks() {
const disks = this.stats.map((diskioData) => {
return {
name: diskioData['disk_name'],
alias: diskioData['alias'] !== undefined ? diskioData['alias'] : null,
bitrate: {
txps: bytes(diskioData['read_bytes_rate_per_sec']),
rxps: bytes(diskioData['write_bytes_rate_per_sec'])
},
count: {
txps: bytes(diskioData['read_count_rate_per_sec']),
rxps: bytes(diskioData['write_count_rate_per_sec'])
},
latency: {
txps: bytes(diskioData['read_latency']),
rxps: bytes(diskioData['write_latency'])
}
};
}).filter(disk => {
const readBytesRate = this.view[disk.name]['read_bytes_rate_per_sec'];
const writeBytesRate = this.view[disk.name]['write_bytes_rate_per_sec'];
return (!readBytesRate || readBytesRate.hidden === false) && (!writeBytesRate || writeBytesRate.hidden === false);
});
return orderBy(disks, ['name']);
},
hasDisks() {
return this.disks.length > 0;
}
},
methods: {
getDecoration(diskName, field) {
if (this.view[diskName][field] == undefined) {
if (this.view[field] == undefined) {
return;
} else {
return this.view[field].decoration.toLowerCase();
}
}
return this.view[diskName][field].decoration.toLowerCase();
}
}
props: {
data: {
type: Object,
},
},
data() {
return {
store,
};
},
computed: {
args() {
return this.store.args || {};
},
stats() {
return this.data.stats["diskio"];
},
view() {
return this.data.views["diskio"];
},
disks() {
const disks = this.stats
.map((diskioData) => {
return {
name: diskioData["disk_name"],
alias:
diskioData["alias"] !== undefined ? diskioData["alias"] : null,
bitrate: {
txps: bytes(diskioData["read_bytes_rate_per_sec"]),
rxps: bytes(diskioData["write_bytes_rate_per_sec"]),
},
count: {
txps: bytes(diskioData["read_count_rate_per_sec"]),
rxps: bytes(diskioData["write_count_rate_per_sec"]),
},
latency: {
txps: bytes(diskioData["read_latency"]),
rxps: bytes(diskioData["write_latency"]),
},
};
})
.filter((disk) => {
const readBytesRate = this.view[disk.name]["read_bytes_rate_per_sec"];
const writeBytesRate =
this.view[disk.name]["write_bytes_rate_per_sec"];
return (
(!readBytesRate || readBytesRate.hidden === false) &&
(!writeBytesRate || writeBytesRate.hidden === false)
);
});
return orderBy(disks, ["name"]);
},
hasDisks() {
return this.disks.length > 0;
},
},
methods: {
getDecoration(diskName, field) {
if (this.view[diskName][field] == undefined) {
if (this.view[field] == undefined) {
return;
} else {
return this.view[field].decoration.toLowerCase();
}
}
return this.view[diskName][field].decoration.toLowerCase();
},
},
};
</script>

View File

@@ -24,45 +24,51 @@
<script>
export default {
props: {
data: {
type: Object
}
},
computed: {
stats() {
return this.data.stats['folders'];
},
folders() {
return this.stats.map((folderData) => {
return {
path: folderData['path'],
size: folderData['size'],
errno: folderData['errno'],
careful: folderData['careful'],
warning: folderData['warning'],
critical: folderData['critical']
};
});
},
hasFolders() {
return this.folders.length > 0;
}
},
methods: {
getDecoration(folder) {
if (folder.errno > 0) {
return 'error';
}
if (folder.critical !== null && folder.size > folder.critical * 1000000) {
return 'critical';
} else if (folder.warning !== null && folder.size > folder.warning * 1000000) {
return 'warning';
} else if (folder.careful !== null && folder.size > folder.careful * 1000000) {
return 'careful';
}
return 'ok';
}
}
props: {
data: {
type: Object,
},
},
computed: {
stats() {
return this.data.stats["folders"];
},
folders() {
return this.stats.map((folderData) => {
return {
path: folderData["path"],
size: folderData["size"],
errno: folderData["errno"],
careful: folderData["careful"],
warning: folderData["warning"],
critical: folderData["critical"],
};
});
},
hasFolders() {
return this.folders.length > 0;
},
},
methods: {
getDecoration(folder) {
if (folder.errno > 0) {
return "error";
}
if (folder.critical !== null && folder.size > folder.critical * 1000000) {
return "critical";
} else if (
folder.warning !== null &&
folder.size > folder.warning * 1000000
) {
return "warning";
} else if (
folder.careful !== null &&
folder.size > folder.careful * 1000000
) {
return "careful";
}
return "ok";
},
},
};
</script>

View File

@@ -43,55 +43,55 @@ v-if="(fs.alias ? fs.alias : fs.mountPoint).length + fs.name.length <= 15"
</template>
<script>
import { orderBy } from 'lodash';
import { store } from '../store.js';
import { orderBy } from "lodash";
import { store } from "../store.js";
export default {
props: {
data: {
type: Object
}
},
data() {
return {
store
};
},
computed: {
args() {
return this.store.args || {};
},
stats() {
return this.data.stats['fs'];
},
view() {
return this.data.views['fs'];
},
fileSystems() {
const fileSystems = this.stats.map((fsData) => {
return {
name: fsData['device_name'],
mountPoint: fsData['mnt_point'],
percent: fsData['percent'],
size: fsData['size'],
used: fsData['used'],
free: fsData['free'],
alias: fsData['alias'] !== undefined ? fsData['alias'] : null
};
});
return orderBy(fileSystems, ['mnt_point']);
},
hasFs() {
return this.fileSystems.length > 0;
}
},
methods: {
getDecoration(mountPoint, field) {
if (this.view[mountPoint][field] == undefined) {
return;
}
return this.view[mountPoint][field].decoration.toLowerCase();
}
}
props: {
data: {
type: Object,
},
},
data() {
return {
store,
};
},
computed: {
args() {
return this.store.args || {};
},
stats() {
return this.data.stats["fs"];
},
view() {
return this.data.views["fs"];
},
fileSystems() {
const fileSystems = this.stats.map((fsData) => {
return {
name: fsData["device_name"],
mountPoint: fsData["mnt_point"],
percent: fsData["percent"],
size: fsData["size"],
used: fsData["used"],
free: fsData["free"],
alias: fsData["alias"] !== undefined ? fsData["alias"] : null,
};
});
return orderBy(fileSystems, ["mnt_point"]);
},
hasFs() {
return this.fileSystems.length > 0;
},
},
methods: {
getDecoration(mountPoint, field) {
if (this.view[mountPoint][field] == undefined) {
return;
}
return this.view[mountPoint][field].decoration.toLowerCase();
},
},
};
</script>

View File

@@ -91,74 +91,74 @@ v-if="gpu.temperature != null" class="col text-end"
</template>
<script>
import { store } from '../store.js';
import { store } from "../store.js";
export default {
props: {
data: {
type: Object
}
},
data() {
return {
store
};
},
computed: {
args() {
return this.store.args || {};
},
stats() {
return this.data.stats['gpu'];
},
view() {
return this.data.views['gpu'];
},
gpus() {
return this.stats;
},
name() {
let name = 'GPU';
const sameName = true;
const { stats } = this;
if (stats.length === 1) {
name = stats[0].name;
} else if (stats.length && sameName) {
name = `${stats.length} GPU ${stats[0].name}`;
}
return name;
},
mean() {
const mean = {
proc: null,
mem: null,
temperature: null
};
const { stats } = this;
if (!stats.length) {
return mean;
}
for (const gpu of stats) {
mean.proc += gpu.proc;
mean.mem += gpu.mem;
mean.temperature += gpu.temperature;
}
mean.proc = mean.proc / stats.length;
mean.mem = mean.mem / stats.length;
mean.temperature = mean.temperature / stats.length;
return mean;
}
},
methods: {
getDecoration(gpuId, value) {
if (this.view[gpuId][value] === undefined) {
return;
}
return this.view[gpuId][value].decoration.toLowerCase();
},
getMeanDecoration(value) {
return 'DEFAULT';
}
}
props: {
data: {
type: Object,
},
},
data() {
return {
store,
};
},
computed: {
args() {
return this.store.args || {};
},
stats() {
return this.data.stats["gpu"];
},
view() {
return this.data.views["gpu"];
},
gpus() {
return this.stats;
},
name() {
let name = "GPU";
const sameName = true;
const { stats } = this;
if (stats.length === 1) {
name = stats[0].name;
} else if (stats.length && sameName) {
name = `${stats.length} GPU ${stats[0].name}`;
}
return name;
},
mean() {
const mean = {
proc: null,
mem: null,
temperature: null,
};
const { stats } = this;
if (!stats.length) {
return mean;
}
for (const gpu of stats) {
mean.proc += gpu.proc;
mean.mem += gpu.mem;
mean.temperature += gpu.temperature;
}
mean.proc = mean.proc / stats.length;
mean.mem = mean.mem / stats.length;
mean.temperature = mean.temperature / stats.length;
return mean;
},
},
methods: {
getDecoration(gpuId, value) {
if (this.view[gpuId][value] === undefined) {
return;
}
return this.view[gpuId][value].decoration.toLowerCase();
},
getMeanDecoration(value) {
return "DEFAULT";
},
},
};
</script>

View File

@@ -6,29 +6,29 @@
</template>
<script>
import { store } from '../store.js';
import { store } from "../store.js";
export default {
props: {
data: {
type: Object
}
},
data() {
return {
store
};
},
computed: {
stats() {
return this.data.stats['system'];
},
hostname() {
return this.stats['hostname'];
},
isDisconnected() {
return this.store.status === 'FAILURE';
}
}
props: {
data: {
type: Object,
},
},
data() {
return {
store,
};
},
computed: {
stats() {
return this.data.stats["system"];
},
hostname() {
return this.stats["hostname"];
},
isDisconnected() {
return this.store.status === "FAILURE";
},
},
};
</script>

View File

@@ -10,30 +10,30 @@
<script>
export default {
props: {
data: {
type: Object
}
},
computed: {
ipStats() {
return this.data.stats['ip'];
},
address() {
return this.ipStats.address;
},
gateway() {
return this.ipStats.gateway;
},
maskCdir() {
return this.ipStats.mask_cidr;
},
publicAddress() {
return this.ipStats.public_address;
},
publicInfo() {
return this.ipStats.public_info_human;
}
}
props: {
data: {
type: Object,
},
},
computed: {
ipStats() {
return this.data.stats["ip"];
},
address() {
return this.ipStats.address;
},
gateway() {
return this.ipStats.gateway;
},
maskCdir() {
return this.ipStats.mask_cidr;
},
publicAddress() {
return this.ipStats.public_address;
},
publicInfo() {
return this.ipStats.public_info_human;
},
},
};
</script>

View File

@@ -19,23 +19,23 @@
<script>
export default {
props: {
data: {
type: Object
}
},
computed: {
stats() {
return this.data.stats['irq'];
},
irqs() {
return this.stats.map((IrqData) => {
return {
irq_line: IrqData['irq_line'],
irq_rate: IrqData['irq_rate']
};
});
}
}
props: {
data: {
type: Object,
},
},
computed: {
stats() {
return this.data.stats["irq"];
},
irqs() {
return this.stats.map((IrqData) => {
return {
irq_line: IrqData["irq_line"],
irq_rate: IrqData["irq_rate"],
};
});
},
},
};
</script>

View File

@@ -31,38 +31,38 @@
<script>
export default {
props: {
data: {
type: Object
}
},
computed: {
stats() {
return this.data.stats['load'];
},
view() {
return this.data.views['load'];
},
cpucore() {
return this.stats['cpucore'];
},
min1() {
return this.stats['min1'];
},
min5() {
return this.stats['min5'];
},
min15() {
return this.stats['min15'];
}
},
methods: {
getDecoration(value) {
if (this.view[value] === undefined) {
return;
}
return this.view[value].decoration.toLowerCase();
}
}
props: {
data: {
type: Object,
},
},
computed: {
stats() {
return this.data.stats["load"];
},
view() {
return this.data.views["load"];
},
cpucore() {
return this.stats["cpucore"];
},
min1() {
return this.stats["min1"];
},
min5() {
return this.stats["min5"];
},
min15() {
return this.stats["min15"];
},
},
methods: {
getDecoration(value) {
if (this.view[value] === undefined) {
return;
}
return this.view[value].decoration.toLowerCase();
},
},
};
</script>

View File

@@ -83,69 +83,71 @@
</template>
<script>
import { store } from '../store.js';
import { store } from "../store.js";
export default {
props: {
data: {
type: Object
}
},
data() {
return {
store
};
},
computed: {
config() {
return this.store.config || {};
},
available_args() {
return this.config !== undefined && this.config.mem !== undefined && this.config.available !== undefined
? this.config.mem.available || false
: false
},
stats() {
return this.data.stats['mem'];
},
view() {
return this.data.views['mem'];
},
percent() {
return this.stats['percent'].toFixed(1);
},
total() {
return this.stats['total'];
},
used() {
return this.stats['used'];
},
available() {
return this.stats['available'];
},
free() {
return this.stats['free'];
},
active() {
return this.stats['active'];
},
inactive() {
return this.stats['inactive'];
},
buffers() {
return this.stats['buffers'];
},
cached() {
return this.stats['cached'];
}
},
methods: {
getDecoration(value) {
if (this.view[value] === undefined) {
return;
}
return this.view[value].decoration.toLowerCase();
}
}
props: {
data: {
type: Object,
},
},
data() {
return {
store,
};
},
computed: {
config() {
return this.store.config || {};
},
available_args() {
return this.config !== undefined &&
this.config.mem !== undefined &&
this.config.available !== undefined
? this.config.mem.available || false
: false;
},
stats() {
return this.data.stats["mem"];
},
view() {
return this.data.views["mem"];
},
percent() {
return this.stats["percent"].toFixed(1);
},
total() {
return this.stats["total"];
},
used() {
return this.stats["used"];
},
available() {
return this.stats["available"];
},
free() {
return this.stats["free"];
},
active() {
return this.stats["active"];
},
inactive() {
return this.stats["inactive"];
},
buffers() {
return this.stats["buffers"];
},
cached() {
return this.stats["cached"];
},
},
methods: {
getDecoration(value) {
if (this.view[value] === undefined) {
return;
}
return this.view[value].decoration.toLowerCase();
},
},
};
</script>

View File

@@ -31,38 +31,38 @@
<script>
export default {
props: {
data: {
type: Object
}
},
computed: {
stats() {
return this.data.stats['memswap'];
},
view() {
return this.data.views['memswap'];
},
percent() {
return this.stats['percent'];
},
total() {
return this.stats['total'];
},
used() {
return this.stats['used'];
},
free() {
return this.stats['free'];
}
},
methods: {
getDecoration(value) {
if (this.view[value] === undefined) {
return;
}
return this.view[value].decoration.toLowerCase();
}
}
props: {
data: {
type: Object,
},
},
computed: {
stats() {
return this.data.stats["memswap"];
},
view() {
return this.data.views["memswap"];
},
percent() {
return this.stats["percent"];
},
total() {
return this.stats["total"];
},
used() {
return this.stats["used"];
},
free() {
return this.stats["free"];
},
},
methods: {
getDecoration(value) {
if (this.view[value] === undefined) {
return;
}
return this.view[value].decoration.toLowerCase();
},
},
};
</script>

View File

@@ -53,65 +53,73 @@ v-show="!args.network_cumul && !args.network_sum" class="text-end"
</template>
<script>
import { orderBy } from 'lodash';
import { store } from '../store.js';
import { bytes } from '../filters.js';
import { orderBy } from "lodash";
import { bytes } from "../filters.js";
import { store } from "../store.js";
export default {
props: {
data: {
type: Object
}
},
data() {
return {
store
};
},
computed: {
args() {
return this.store.args || {};
},
stats() {
return this.data.stats['network'];
},
view() {
return this.data.views['network'];
},
networks() {
const networks = this.stats.map((networkData) => {
const alias = networkData['alias'] !== undefined ? networkData['alias'] : null;
props: {
data: {
type: Object,
},
},
data() {
return {
store,
};
},
computed: {
args() {
return this.store.args || {};
},
stats() {
return this.data.stats["network"];
},
view() {
return this.data.views["network"];
},
networks() {
const networks = this.stats
.map((networkData) => {
const alias =
networkData["alias"] !== undefined ? networkData["alias"] : null;
const network = {
interfaceName: networkData['interface_name'],
ifname: alias ? alias : networkData['interface_name'],
bytes_recv_rate_per_sec: networkData['bytes_recv_rate_per_sec'],
bytes_sent_rate_per_sec: networkData['bytes_sent_rate_per_sec'],
bytes_all_rate_per_sec: networkData['bytes_all_rate_per_sec'],
bytes_recv: networkData['bytes_recv'],
bytes_sent: networkData['bytes_sent'],
bytes_all: networkData['bytes_all']
};
const network = {
interfaceName: networkData["interface_name"],
ifname: alias ? alias : networkData["interface_name"],
bytes_recv_rate_per_sec: networkData["bytes_recv_rate_per_sec"],
bytes_sent_rate_per_sec: networkData["bytes_sent_rate_per_sec"],
bytes_all_rate_per_sec: networkData["bytes_all_rate_per_sec"],
bytes_recv: networkData["bytes_recv"],
bytes_sent: networkData["bytes_sent"],
bytes_all: networkData["bytes_all"],
};
return network;
}).filter(network => {
const bytesRecvRate = this.view[network.interfaceName]['bytes_recv_rate_per_sec'];
const bytesSentRate = this.view[network.interfaceName]['bytes_sent_rate_per_sec'];
return (!bytesRecvRate || bytesRecvRate.hidden === false) && (!bytesSentRate || bytesSentRate.hidden === false);
});
return orderBy(networks, ['interfaceName']);
},
hasNetworks() {
return this.networks.length > 0;
}
},
methods: {
getDecoration(interfaceName, field) {
if (this.view[interfaceName][field] == undefined) {
return;
}
return this.view[interfaceName][field].decoration.toLowerCase();
}
}
return network;
})
.filter((network) => {
const bytesRecvRate =
this.view[network.interfaceName]["bytes_recv_rate_per_sec"];
const bytesSentRate =
this.view[network.interfaceName]["bytes_sent_rate_per_sec"];
return (
(!bytesRecvRate || bytesRecvRate.hidden === false) &&
(!bytesSentRate || bytesSentRate.hidden === false)
);
});
return orderBy(networks, ["interfaceName"]);
},
hasNetworks() {
return this.networks.length > 0;
},
},
methods: {
getDecoration(interfaceName, field) {
if (this.view[interfaceName][field] == undefined) {
return;
}
return this.view[interfaceName][field].decoration.toLowerCase();
},
},
};
</script>

View File

@@ -6,15 +6,15 @@
<script>
export default {
props: {
data: {
type: Object
}
},
computed: {
date_custom() {
return this.data.stats['now']['custom'];
}
}
props: {
data: {
type: Object,
},
},
computed: {
date_custom() {
return this.data.stats["now"]["custom"];
},
},
};
</script>

View File

@@ -32,42 +32,42 @@
</template>
<script>
import { store } from '../store.js';
import { GlancesHelper } from '../services.js';
import { chunk } from 'lodash';
import { chunk } from "lodash";
import { GlancesHelper } from "../services.js";
import { store } from "../store.js";
export default {
props: {
data: {
type: Object
}
},
data() {
return {
store
};
},
computed: {
args() {
return this.store.args || {};
},
config() {
return this.store.config || {};
},
percpuStats() {
return this.data.stats['percpu'];
}
},
methods: {
getUserAlert(cpu) {
return GlancesHelper.getAlert('percpu', 'percpu_user_', cpu.user);
},
getSystemAlert(cpu) {
return GlancesHelper.getAlert('percpu', 'percpu_system_', cpu.system);
},
getIOWaitAlert(cpu) {
return GlancesHelper.getAlert('percpu', 'percpu_iowait_', cpu.system);
}
}
props: {
data: {
type: Object,
},
},
data() {
return {
store,
};
},
computed: {
args() {
return this.store.args || {};
},
config() {
return this.store.config || {};
},
percpuStats() {
return this.data.stats["percpu"];
},
},
methods: {
getUserAlert(cpu) {
return GlancesHelper.getAlert("percpu", "percpu_user_", cpu.user);
},
getSystemAlert(cpu) {
return GlancesHelper.getAlert("percpu", "percpu_system_", cpu.system);
},
getIOWaitAlert(cpu) {
return GlancesHelper.getAlert("percpu", "percpu_iowait_", cpu.system);
},
},
};
</script>

View File

@@ -30,46 +30,46 @@
<script>
export default {
props: {
data: {
type: Object
}
},
computed: {
stats() {
return this.data.stats['ports'];
},
ports() {
return this.stats;
},
hasPorts() {
return this.ports.length > 0;
}
},
methods: {
getPortDecoration(port) {
if (port.status === null) {
return 'careful';
} else if (port.status === false) {
return 'critical';
} else if (port.rtt_warning !== null && port.status > port.rtt_warning) {
return 'warning';
}
return 'ok';
},
getWebDecoration(web) {
const okCodes = [200, 301, 302];
props: {
data: {
type: Object,
},
},
computed: {
stats() {
return this.data.stats["ports"];
},
ports() {
return this.stats;
},
hasPorts() {
return this.ports.length > 0;
},
},
methods: {
getPortDecoration(port) {
if (port.status === null) {
return "careful";
} else if (port.status === false) {
return "critical";
} else if (port.rtt_warning !== null && port.status > port.rtt_warning) {
return "warning";
}
return "ok";
},
getWebDecoration(web) {
const okCodes = [200, 301, 302];
if (web.status === null) {
return 'careful';
} else if (okCodes.indexOf(web.status) === -1) {
return 'critical';
} else if (web.rtt_warning !== null && web.elapsed > web.rtt_warning) {
return 'warning';
}
if (web.status === null) {
return "careful";
} else if (okCodes.indexOf(web.status) === -1) {
return "critical";
} else if (web.rtt_warning !== null && web.elapsed > web.rtt_warning) {
return "warning";
}
return 'ok';
}
}
return "ok";
},
},
};
</script>

View File

@@ -16,75 +16,75 @@
</template>
<script>
import { store } from '../store.js';
import GlancesPluginAmps from './plugin-amps.vue';
import GlancesPluginProcesscount from './plugin-processcount.vue';
import GlancesPluginProcesslist from './plugin-processlist.vue';
import { store } from "../store.js";
import GlancesPluginAmps from "./plugin-amps.vue";
import GlancesPluginProcesscount from "./plugin-processcount.vue";
import GlancesPluginProcesslist from "./plugin-processlist.vue";
export default {
components: {
GlancesPluginAmps,
GlancesPluginProcesscount,
GlancesPluginProcesslist
},
props: {
data: {
type: Object
}
},
data() {
return {
store,
sorter: undefined
};
},
computed: {
args() {
return this.store.args || {};
},
sortProcessesKey() {
return this.args.sort_processes_key;
}
},
watch: {
sortProcessesKey: {
immediate: true,
handler(sortProcessesKey) {
const sortable = [
'cpu_percent',
'memory_percent',
'username',
'timemillis',
'num_threads',
'io_counters',
'name'
];
function isReverseColumn(column) {
return !['username', 'name'].includes(column);
}
function getColumnLabel(value) {
const labels = {
cpu_percent: 'CPU consumption',
memory_percent: 'memory consumption',
username: 'user name',
timemillis: 'process time',
cpu_times: 'process time',
io_counters: 'disk IO',
name: 'process name',
None: 'None'
};
return labels[value] || value;
}
if (!sortProcessesKey || sortable.includes(sortProcessesKey)) {
this.sorter = {
column: this.args.sort_processes_key || 'cpu_percent',
auto: !this.args.sort_processes_key,
isReverseColumn,
getColumnLabel
};
}
}
}
}
components: {
GlancesPluginAmps,
GlancesPluginProcesscount,
GlancesPluginProcesslist,
},
props: {
data: {
type: Object,
},
},
data() {
return {
store,
sorter: undefined,
};
},
computed: {
args() {
return this.store.args || {};
},
sortProcessesKey() {
return this.args.sort_processes_key;
},
},
watch: {
sortProcessesKey: {
immediate: true,
handler(sortProcessesKey) {
const sortable = [
"cpu_percent",
"memory_percent",
"username",
"timemillis",
"num_threads",
"io_counters",
"name",
];
function isReverseColumn(column) {
return !["username", "name"].includes(column);
}
function getColumnLabel(value) {
const labels = {
cpu_percent: "CPU consumption",
memory_percent: "memory consumption",
username: "user name",
timemillis: "process time",
cpu_times: "process time",
io_counters: "disk IO",
name: "process name",
None: "None",
};
return labels[value] || value;
}
if (!sortProcessesKey || sortable.includes(sortProcessesKey)) {
this.sorter = {
column: this.args.sort_processes_key || "cpu_percent",
auto: !this.args.sort_processes_key,
isReverseColumn,
getColumnLabel,
};
}
},
},
},
};
</script>

View File

@@ -12,44 +12,44 @@
</template>
<script>
import { store } from '../store.js';
import { store } from "../store.js";
export default {
props: {
data: {
type: Object
},
sorter: {
type: Object
}
},
data() {
return {
store
};
},
computed: {
args() {
return this.store.args || {};
},
stats() {
return this.data.stats['processcount'];
},
total() {
return this.stats['total'] || 0;
},
running() {
return this.stats['running'] || 0;
},
sleeping() {
return this.stats['sleeping'] || 0;
},
stopped() {
return this.stats['stopped'] || 0;
},
thread() {
return this.stats['thread'] || 0;
}
}
props: {
data: {
type: Object,
},
sorter: {
type: Object,
},
},
data() {
return {
store,
};
},
computed: {
args() {
return this.store.args || {};
},
stats() {
return this.data.stats["processcount"];
},
total() {
return this.stats["total"] || 0;
},
running() {
return this.stats["running"] || 0;
},
sleeping() {
return this.stats["sleeping"] || 0;
},
stopped() {
return this.stats["stopped"] || 0;
},
thread() {
return this.stats["thread"] || 0;
},
},
};
</script>

View File

@@ -380,246 +380,304 @@
</template>
<script>
import { orderBy, last } from 'lodash';
import { timemillis, timedelta, limitTo, number, dictToString } from '../filters.js';
import { GlancesHelper } from '../services.js';
import { store } from '../store.js';
import { last, orderBy } from "lodash";
import {
dictToString,
limitTo,
number,
timedelta,
timemillis,
} from "../filters.js";
import { GlancesHelper } from "../services.js";
import { store } from "../store.js";
export default {
props: {
data: {
type: Object
},
sorter: {
type: Object
}
},
data() {
return {
store
};
},
computed: {
args() {
return this.store.args || {};
},
config() {
return this.store.config || {};
},
stats_processlist() {
return this.data.stats['processlist'];
},
stats_core() {
return this.data.stats['core'];
},
cpucore() {
return (this.stats_core['log'] !== 0) ? this.stats_core['log'] : 1;
},
extended_stats() {
return this.stats_processlist.find(item => item['extended_stats'] === true) || null;
},
processes() {
const { sorter } = this;
const processes = (this.stats_processlist || []).map((process) => {
return this.updateProcess(process, this.data.stats['isWindows'], this.args, this.cpucore);
});
props: {
data: {
type: Object,
},
sorter: {
type: Object,
},
},
data() {
return {
store,
};
},
computed: {
args() {
return this.store.args || {};
},
config() {
return this.store.config || {};
},
stats_processlist() {
return this.data.stats["processlist"];
},
stats_core() {
return this.data.stats["core"];
},
cpucore() {
return this.stats_core["log"] !== 0 ? this.stats_core["log"] : 1;
},
extended_stats() {
return (
this.stats_processlist.find(
(item) => item["extended_stats"] === true,
) || null
);
},
processes() {
const { sorter } = this;
const processes = (this.stats_processlist || []).map((process) => {
return this.updateProcess(
process,
this.data.stats["isWindows"],
this.args,
this.cpucore,
);
});
return orderBy(
processes,
[sorter.column].reduce((retval, col) => {
if (col === 'io_counters') {
col = ['io_read', 'io_write']
}
return retval.concat(col);
}, []),
[sorter.isReverseColumn(sorter.column) ? 'desc' : 'asc']
).slice(0, this.limit);
},
ioReadWritePresentProcesses() {
return (this.stats_processlist || []).some(({ io_counters }) => io_counters);
},
stats_programlist() {
return this.data.stats['programlist'];
},
programs() {
const { sorter } = this;
const isWindows = this.data.stats['isWindows'];
const programs = (this.stats_programlist || []).map((process) => {
process.memvirt = '?';
process.memres = '?';
if (process.memory_info) {
process.memvirt = process.memory_info.vms;
process.memres = process.memory_info.rss;
}
return orderBy(
processes,
[sorter.column].reduce((retval, col) => {
if (col === "io_counters") {
col = ["io_read", "io_write"];
}
return retval.concat(col);
}, []),
[sorter.isReverseColumn(sorter.column) ? "desc" : "asc"],
).slice(0, this.limit);
},
ioReadWritePresentProcesses() {
return (this.stats_processlist || []).some(
({ io_counters }) => io_counters,
);
},
stats_programlist() {
return this.data.stats["programlist"];
},
programs() {
const { sorter } = this;
const isWindows = this.data.stats["isWindows"];
const programs = (this.stats_programlist || []).map((process) => {
process.memvirt = "?";
process.memres = "?";
if (process.memory_info) {
process.memvirt = process.memory_info.vms;
process.memres = process.memory_info.rss;
}
if (isWindows && process.username !== null) {
process.username = last(process.username.split('\\'));
}
if (isWindows && process.username !== null) {
process.username = last(process.username.split("\\"));
}
process.timeforhuman = '?';
if (process.cpu_times) {
process.timeplus = timedelta([process.cpu_times['user'], process.cpu_times['system']]);
process.timeforhuman = process.timeplus.hours.toString().padStart(2, '0') + ':' +
process.timeplus.minutes.toString().padStart(2, '0') + ':' +
process.timeplus.seconds.toString().padStart(2, '0')
}
process.timeforhuman = "?";
if (process.cpu_times) {
process.timeplus = timedelta([
process.cpu_times["user"],
process.cpu_times["system"],
]);
process.timeforhuman =
process.timeplus.hours.toString().padStart(2, "0") +
":" +
process.timeplus.minutes.toString().padStart(2, "0") +
":" +
process.timeplus.seconds.toString().padStart(2, "0");
}
if (process.num_threads === null) {
process.num_threads = -1;
}
if (process.num_threads === null) {
process.num_threads = -1;
}
if (process.cpu_percent === null) {
process.cpu_percent = -1;
}
if (process.cpu_percent === null) {
process.cpu_percent = -1;
}
if (process.memory_percent === null) {
process.memory_percent = -1;
}
if (process.memory_percent === null) {
process.memory_percent = -1;
}
process.io_read = null;
process.io_write = null;
process.io_read = null;
process.io_write = null;
if (process.io_counters) {
process.io_read =
(process.io_counters[0] - process.io_counters[2]) /
process.time_since_update;
process.io_write =
(process.io_counters[1] - process.io_counters[3]) /
process.time_since_update;
}
if (process.io_counters) {
process.io_read =
(process.io_counters[0] - process.io_counters[2]) /
process.time_since_update;
process.io_write =
(process.io_counters[1] - process.io_counters[3]) /
process.time_since_update;
}
process.isNice =
process.nice !== undefined &&
((isWindows && process.nice != 32) || (!isWindows && process.nice != 0));
process.isNice =
process.nice !== undefined &&
((isWindows && process.nice != 32) ||
(!isWindows && process.nice != 0));
if (Array.isArray(process.cmdline)) {
process.cmdline = process.cmdline.join(' ').replace(/\n/g, ' ');
}
if (Array.isArray(process.cmdline)) {
process.cmdline = process.cmdline.join(" ").replace(/\n/g, " ");
}
if (typeof process.cmdline !== "string" || process.cmdline.length === 0) {
process.cmdline = process.name;
}
if (
typeof process.cmdline !== "string" ||
process.cmdline.length === 0
) {
process.cmdline = process.name;
}
return process;
});
return process;
});
return orderBy(
programs,
[sorter.column].reduce((retval, col) => {
if (col === 'io_counters') {
col = ['io_read', 'io_write']
}
return retval.concat(col);
}, []),
[sorter.isReverseColumn(sorter.column) ? 'desc' : 'asc']
).slice(0, this.limit);
},
ioReadWritePresentPrograms() {
return (this.stats_programlist || []).some(({ io_counters }) => io_counters);
},
limit() {
return this.config.outputs !== undefined
? this.config.outputs.max_processes_display
: undefined;
},
focus() {
return this.args !== undefined && this.args.process_focus !== undefined && this.args.process_focus !== null
? this.args.process_focus.split(',')
: this.config.processlist !== undefined && this.config.processlist.focus !== undefined && this.config.processlist.focus !== null
? this.config.processlist.focus.split(',')
: [];
},
is_focus() {
return this.focus.length > 0;
}
},
methods: {
updateProcess(process, isWindows, args, cpucore) {
process.memvirt = '?';
process.memres = '?';
if (process.memory_info) {
process.memvirt = process.memory_info.vms;
process.memres = process.memory_info.rss;
}
return orderBy(
programs,
[sorter.column].reduce((retval, col) => {
if (col === "io_counters") {
col = ["io_read", "io_write"];
}
return retval.concat(col);
}, []),
[sorter.isReverseColumn(sorter.column) ? "desc" : "asc"],
).slice(0, this.limit);
},
ioReadWritePresentPrograms() {
return (this.stats_programlist || []).some(
({ io_counters }) => io_counters,
);
},
limit() {
return this.config.outputs !== undefined
? this.config.outputs.max_processes_display
: undefined;
},
focus() {
return this.args !== undefined &&
this.args.process_focus !== undefined &&
this.args.process_focus !== null
? this.args.process_focus.split(",")
: this.config.processlist !== undefined &&
this.config.processlist.focus !== undefined &&
this.config.processlist.focus !== null
? this.config.processlist.focus.split(",")
: [];
},
is_focus() {
return this.focus.length > 0;
},
},
methods: {
updateProcess(process, isWindows, args, cpucore) {
process.memvirt = "?";
process.memres = "?";
if (process.memory_info) {
process.memvirt = process.memory_info.vms;
process.memres = process.memory_info.rss;
}
if (isWindows && process.username !== null) {
process.username = last(process.username.split('\\'));
}
if (isWindows && process.username !== null) {
process.username = last(process.username.split("\\"));
}
process.timeforhuman = '?';
if (process.cpu_times) {
process.timeplus = timedelta([process.cpu_times['user'], process.cpu_times['system']]);
process.timeforhuman = process.timeplus.hours.toString().padStart(2, '0') + ':' +
process.timeplus.minutes.toString().padStart(2, '0') + ':' +
process.timeplus.seconds.toString().padStart(2, '0')
}
process.timeforhuman = "?";
if (process.cpu_times) {
process.timeplus = timedelta([
process.cpu_times["user"],
process.cpu_times["system"],
]);
process.timeforhuman =
process.timeplus.hours.toString().padStart(2, "0") +
":" +
process.timeplus.minutes.toString().padStart(2, "0") +
":" +
process.timeplus.seconds.toString().padStart(2, "0");
}
if (process.num_threads === null) {
process.num_threads = -1;
}
if (process.num_threads === null) {
process.num_threads = -1;
}
process.irix = 1;
if (process.cpu_percent === null) {
process.cpu_percent = -1;
} else {
if (args.disable_irix) {
process.irix = cpucore
}
}
process.irix = 1;
if (process.cpu_percent === null) {
process.cpu_percent = -1;
} else {
if (args.disable_irix) {
process.irix = cpucore;
}
}
if (process.memory_percent === null) {
process.memory_percent = -1;
}
if (process.memory_percent === null) {
process.memory_percent = -1;
}
process.io_read = null;
process.io_write = null;
process.io_read = null;
process.io_write = null;
if (process.io_counters) {
process.io_read =
(process.io_counters[0] - process.io_counters[2]) /
process.time_since_update;
process.io_write =
(process.io_counters[1] - process.io_counters[3]) /
process.time_since_update;
}
if (process.io_counters) {
process.io_read =
(process.io_counters[0] - process.io_counters[2]) /
process.time_since_update;
process.io_write =
(process.io_counters[1] - process.io_counters[3]) /
process.time_since_update;
}
process.isNice =
process.nice !== undefined &&
((isWindows && process.nice != 32) || (!isWindows && process.nice != 0));
process.isNice =
process.nice !== undefined &&
((isWindows && process.nice != 32) ||
(!isWindows && process.nice != 0));
if (Array.isArray(process.cmdline)) {
process.name = process.name + ' ' + process.cmdline.slice(1).join(' ').replace(/\n/g, ' ');
process.cmdline = process.cmdline.join(' ').replace(/\n/g, ' ');
}
if (Array.isArray(process.cmdline)) {
process.name =
process.name +
" " +
process.cmdline.slice(1).join(" ").replace(/\n/g, " ");
process.cmdline = process.cmdline.join(" ").replace(/\n/g, " ");
}
if (typeof process.cmdline !== "string" || process.cmdline.length === 0) {
process.cmdline = process.name;
}
return process
},
getCpuPercentAlert(process) {
return GlancesHelper.getAlert('processlist', 'processlist_cpu_', process.cpu_percent);
},
getMemoryPercentAlert(process) {
return GlancesHelper.getAlert('processlist', 'processlist_mem_', process.cpu_percent);
},
getDisableStats() {
return GlancesHelper.getLimit('processlist', 'processlist_disable_stats') || [];
},
getDisableVms() {
const ret = GlancesHelper.getLimit('processlist', 'processlist_disable_virtual_memory') || ['False'];
return (ret[0].toLowerCase() === 'true') ? true : false;
},
setExtendedStats(pid) {
fetch('api/4/processes/extended/' + pid.toString(), { method: 'POST' })
.then((response) => response.json());
this.$forceUpdate()
},
disableExtendedStats() {
fetch('api/4/processes/extended/disable', { method: 'POST' })
.then((response) => response.json());
this.$forceUpdate()
}
}
if (typeof process.cmdline !== "string" || process.cmdline.length === 0) {
process.cmdline = process.name;
}
return process;
},
getCpuPercentAlert(process) {
return GlancesHelper.getAlert(
"processlist",
"processlist_cpu_",
process.cpu_percent,
);
},
getMemoryPercentAlert(process) {
return GlancesHelper.getAlert(
"processlist",
"processlist_mem_",
process.cpu_percent,
);
},
getDisableStats() {
return (
GlancesHelper.getLimit("processlist", "processlist_disable_stats") || []
);
},
getDisableVms() {
const ret = GlancesHelper.getLimit(
"processlist",
"processlist_disable_virtual_memory",
) || ["False"];
return ret[0].toLowerCase() === "true" ? true : false;
},
setExtendedStats(pid) {
fetch("api/4/processes/extended/" + pid.toString(), {
method: "POST",
}).then((response) => response.json());
this.$forceUpdate();
},
disableExtendedStats() {
fetch("api/4/processes/extended/disable", { method: "POST" }).then(
(response) => response.json(),
);
this.$forceUpdate();
},
},
};
</script>

View File

@@ -51,73 +51,82 @@
</template>
<script>
import { store } from '../store.js';
import { store } from "../store.js";
export default {
props: {
data: {
type: Object
}
},
data() {
return {
store
};
},
computed: {
args() {
return this.store.args || {};
},
config() {
return this.store.config || {};
},
stats() {
return this.data.stats['quicklook'];
},
view() {
return this.data.views['quicklook'];
},
cpu() {
return this.stats.cpu;
},
cpu_name() {
return this.stats.cpu_name;
},
cpu_hz_current() {
return (this.stats.cpu_hz_current / 1000000).toFixed(0);
},
cpu_hz() {
return (this.stats.cpu_hz / 1000000).toFixed(0);
},
percpus() {
const cpu_list = this.stats.percpu.map(({ cpu_number: number, total }) => ({ number, total }))
const max_cpu_display = parseInt(this.config.percpu.max_cpu_display)
if (this.stats.percpu.length > max_cpu_display) {
var cpu_list_sorted = cpu_list.sort(function (a, b) { return b.total - a.total; })
const other_cpu = {
number: "x",
total: Number((cpu_list_sorted.slice(max_cpu_display).reduce((n, { total }) => n + total, 0) / (this.stats.percpu.length - max_cpu_display)).toFixed(1))
}
// Add the top n this
// and the mean of others CPU
cpu_list_sorted = cpu_list_sorted.slice(0, max_cpu_display)
cpu_list_sorted.push(other_cpu)
}
return this.stats.percpu.length <= max_cpu_display
? cpu_list
: cpu_list_sorted
},
stats_list_after_cpu() {
return this.view.list.filter((key) => !key.includes('cpu'));
},
},
methods: {
getDecoration(value) {
if (this.view[value] === undefined) {
return;
}
return this.view[value].decoration.toLowerCase();
}
}
props: {
data: {
type: Object,
},
},
data() {
return {
store,
};
},
computed: {
args() {
return this.store.args || {};
},
config() {
return this.store.config || {};
},
stats() {
return this.data.stats["quicklook"];
},
view() {
return this.data.views["quicklook"];
},
cpu() {
return this.stats.cpu;
},
cpu_name() {
return this.stats.cpu_name;
},
cpu_hz_current() {
return (this.stats.cpu_hz_current / 1000000).toFixed(0);
},
cpu_hz() {
return (this.stats.cpu_hz / 1000000).toFixed(0);
},
percpus() {
const cpu_list = this.stats.percpu.map(
({ cpu_number: number, total }) => ({ number, total }),
);
const max_cpu_display = parseInt(this.config.percpu.max_cpu_display);
if (this.stats.percpu.length > max_cpu_display) {
var cpu_list_sorted = cpu_list.sort((a, b) => b.total - a.total);
const other_cpu = {
number: "x",
total: Number(
(
cpu_list_sorted
.slice(max_cpu_display)
.reduce((n, { total }) => n + total, 0) /
(this.stats.percpu.length - max_cpu_display)
).toFixed(1),
),
};
// Add the top n this
// and the mean of others CPU
cpu_list_sorted = cpu_list_sorted.slice(0, max_cpu_display);
cpu_list_sorted.push(other_cpu);
}
return this.stats.percpu.length <= max_cpu_display
? cpu_list
: cpu_list_sorted;
},
stats_list_after_cpu() {
return this.view.list.filter((key) => !key.includes("cpu"));
},
},
methods: {
getDecoration(value) {
if (this.view[value] === undefined) {
return;
}
return this.view[value].decoration.toLowerCase();
},
},
};
</script>

View File

@@ -37,54 +37,57 @@
</template>
<script>
import { orderBy } from 'lodash';
import { orderBy } from "lodash";
export default {
props: {
data: {
type: Object
}
},
computed: {
stats() {
return this.data.stats['raid'];
},
disks() {
const disks = Object.entries(this.stats).map(([diskKey, diskData]) => {
const components = Object.entries(diskData.components).map(([name, number]) => {
return {
number: number,
name: name
};
});
return {
name: diskKey,
type: diskData.type == null ? 'UNKNOWN' : diskData.type,
used: diskData.used,
available: diskData.available,
status: diskData.status,
degraded: diskData.used < diskData.available,
config: diskData.config == null ? '' : diskData.config.replace('_', 'A'),
inactive: diskData.status == 'inactive',
components: orderBy(components, ['number'])
};
});
return orderBy(disks, ['name']);
},
hasDisks() {
return this.disks.length > 0;
}
},
methods: {
getAlert(disk) {
if (disk.inactive) {
return 'critical';
}
if (disk.degraded) {
return 'warning';
}
return 'ok';
}
}
props: {
data: {
type: Object,
},
},
computed: {
stats() {
return this.data.stats["raid"];
},
disks() {
const disks = Object.entries(this.stats).map(([diskKey, diskData]) => {
const components = Object.entries(diskData.components).map(
([name, number]) => {
return {
number: number,
name: name,
};
},
);
return {
name: diskKey,
type: diskData.type == null ? "UNKNOWN" : diskData.type,
used: diskData.used,
available: diskData.available,
status: diskData.status,
degraded: diskData.used < diskData.available,
config:
diskData.config == null ? "" : diskData.config.replace("_", "A"),
inactive: diskData.status == "inactive",
components: orderBy(components, ["number"]),
};
});
return orderBy(disks, ["name"]);
},
hasDisks() {
return this.disks.length > 0;
},
},
methods: {
getAlert(disk) {
if (disk.inactive) {
return "critical";
}
if (disk.degraded) {
return "warning";
}
return "ok";
},
},
};
</script>

View File

@@ -22,61 +22,63 @@
</template>
<script>
import { GlancesHelper } from '../services.js';
import { store } from '../store.js';
import { GlancesHelper } from "../services.js";
import { store } from "../store.js";
export default {
props: {
data: {
type: Object
}
},
data() {
return {
store
};
},
computed: {
args() {
return this.store.args || {};
},
stats() {
return this.data.stats['sensors'];
},
view() {
return this.data.views['sensors'];
},
sensors() {
return this.stats
// .filter((sensor) => {
// // prettier-ignore
// const isEmpty = (Array.isArray(sensor.value) && sensor.value.length === 0) || sensor.value === 0;
// return !isEmpty;
// })
.map((sensor) => {
if (
this.args.fahrenheit &&
sensor.type != 'battery' &&
sensor.type != 'fan_speed'
) {
// prettier-ignore
sensor.value = parseFloat(sensor.value * 1.8 + 32).toFixed(1);
sensor.unit = 'F';
}
return sensor;
});
},
hasSensors() {
return this.sensors.length > 0;
}
},
methods: {
getDecoration(key) {
if (this.view[key].value.decoration === undefined) {
return;
}
return this.view[key].value.decoration.toLowerCase();
}
}
props: {
data: {
type: Object,
},
},
data() {
return {
store,
};
},
computed: {
args() {
return this.store.args || {};
},
stats() {
return this.data.stats["sensors"];
},
view() {
return this.data.views["sensors"];
},
sensors() {
return (
this.stats
// .filter((sensor) => {
// // prettier-ignore
// const isEmpty = (Array.isArray(sensor.value) && sensor.value.length === 0) || sensor.value === 0;
// return !isEmpty;
// })
.map((sensor) => {
if (
this.args.fahrenheit &&
sensor.type != "battery" &&
sensor.type != "fan_speed"
) {
// prettier-ignore
sensor.value = parseFloat(sensor.value * 1.8 + 32).toFixed(1);
sensor.unit = "F";
}
return sensor;
})
);
},
hasSensors() {
return this.sensors.length > 0;
},
},
methods: {
getDecoration(key) {
if (this.view[key].value.decoration === undefined) {
return;
}
return this.view[key].value.decoration.toLowerCase();
},
},
};
</script>

View File

@@ -25,28 +25,30 @@
<script>
export default {
props: {
data: {
type: Object
}
},
computed: {
stats() {
return this.data.stats['smart'];
},
drives() {
return (Array.isArray(this.stats) ? this.stats : []).map((data) => {
const name = data.DeviceName;
const details = Object.entries(data)
.filter(([key]) => key !== 'DeviceName')
.sort(([, a], [, b]) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))
.map(([prop, value]) => value);
return { name, details };
});
},
hasDrives() {
return this.drives.length > 0;
}
}
props: {
data: {
type: Object,
},
},
computed: {
stats() {
return this.data.stats["smart"];
},
drives() {
return (Array.isArray(this.stats) ? this.stats : []).map((data) => {
const name = data.DeviceName;
const details = Object.entries(data)
.filter(([key]) => key !== "DeviceName")
.sort(([, a], [, b]) =>
a.name < b.name ? -1 : a.name > b.name ? 1 : 0,
)
.map(([prop, value]) => value);
return { name, details };
});
},
hasDrives() {
return this.drives.length > 0;
},
},
};
</script>

View File

@@ -7,32 +7,32 @@
</template>
<script>
import { store } from '../store.js';
import { store } from "../store.js";
export default {
props: {
data: {
type: Object
}
},
data() {
return {
store
};
},
computed: {
stats() {
return this.data.stats['system'];
},
hostname() {
return this.stats['hostname'];
},
humanReadableName() {
return this.stats['hr_name'];
},
isDisconnected() {
return this.store.status === 'FAILURE';
}
}
props: {
data: {
type: Object,
},
},
data() {
return {
store,
};
},
computed: {
stats() {
return this.data.stats["system"];
},
hostname() {
return this.stats["hostname"];
},
humanReadableName() {
return this.stats["hr_name"];
},
isDisconnected() {
return this.store.status === "FAILURE";
},
},
};
</script>

View File

@@ -6,15 +6,15 @@
<script>
export default {
props: {
data: {
type: Object
}
},
computed: {
value() {
return this.data.stats['uptime'];
}
}
props: {
data: {
type: Object,
},
},
computed: {
value() {
return this.data.stats["uptime"];
},
},
};
</script>

View File

@@ -61,100 +61,103 @@
</template>
<script>
import { orderBy } from 'lodash';
import { store } from '../store.js';
import { orderBy } from "lodash";
import { store } from "../store.js";
export default {
props: {
data: {
type: Object
}
},
data() {
return {
store,
sorter: undefined
};
},
computed: {
args() {
return this.store.args || {};
},
sortProcessesKey() {
return this.args.sort_processes_key;
},
stats() {
return this.data.stats['vms'];
},
views() {
return this.data.views['vms'];
},
vms() {
const { sorter } = this;
const vms = (this.stats || []).map(
(vmData) => {
return {
'id': vmData.id,
'name': vmData.name,
'status': vmData.status != undefined ? vmData.status : '-',
'cpu_count': vmData.cpu_count != undefined ? vmData.cpu_count : '-',
'cpu_time': vmData.cpu_time != undefined ? vmData.cpu_time : '-',
'cpu_time_rate_per_sec': vmData.cpu_time_rate_per_sec != undefined ? vmData.cpu_time_rate_per_sec : '?',
'memory_usage': vmData.memory_usage != undefined ? vmData.memory_usage : '-',
'memory_total': vmData.memory_total != undefined ? vmData.memory_total : '-',
'load_1min': vmData.load_1min != undefined ? vmData.load_1min : '-',
'load_5min': vmData.load_5min != undefined ? vmData.load_5min : '-',
'load_15min': vmData.load_15min != undefined ? vmData.load_15min : '-',
'release': vmData.release,
'image': vmData.image,
'engine': vmData.engine,
'engine_version': vmData.engine_version,
};
}
);
return orderBy(
vms,
[sorter.column].reduce((retval, col) => {
if (col === 'memory_usage') {
col = ['memory_usage'];
}
return retval.concat(col);
}, []),
[sorter.isReverseColumn(sorter.column) ? 'desc' : 'asc']
);
},
showEngine() {
return this.views.show_engine_name;
},
},
watch: {
sortProcessesKey: {
immediate: true,
handler(sortProcessesKey) {
const sortable = ['load_1min', 'cpu_time', 'memory_usage', 'name'];
function isReverseColumn(column) {
return !['name'].includes(column);
}
function getColumnLabel(value) {
const labels = {
load_1min: 'load',
cpu_time: 'CPU time',
memory_usage: 'memory consumption',
name: 'VM name',
None: 'None'
};
return labels[value] || value;
}
if (!sortProcessesKey || sortable.includes(sortProcessesKey)) {
this.sorter = {
column: this.args.sort_processes_key || 'cpu_time',
auto: !this.args.sort_processes_key,
isReverseColumn,
getColumnLabel
};
}
}
}
}
props: {
data: {
type: Object,
},
},
data() {
return {
store,
sorter: undefined,
};
},
computed: {
args() {
return this.store.args || {};
},
sortProcessesKey() {
return this.args.sort_processes_key;
},
stats() {
return this.data.stats["vms"];
},
views() {
return this.data.views["vms"];
},
vms() {
const { sorter } = this;
const vms = (this.stats || []).map((vmData) => {
return {
id: vmData.id,
name: vmData.name,
status: vmData.status != undefined ? vmData.status : "-",
cpu_count: vmData.cpu_count != undefined ? vmData.cpu_count : "-",
cpu_time: vmData.cpu_time != undefined ? vmData.cpu_time : "-",
cpu_time_rate_per_sec:
vmData.cpu_time_rate_per_sec != undefined
? vmData.cpu_time_rate_per_sec
: "?",
memory_usage:
vmData.memory_usage != undefined ? vmData.memory_usage : "-",
memory_total:
vmData.memory_total != undefined ? vmData.memory_total : "-",
load_1min: vmData.load_1min != undefined ? vmData.load_1min : "-",
load_5min: vmData.load_5min != undefined ? vmData.load_5min : "-",
load_15min: vmData.load_15min != undefined ? vmData.load_15min : "-",
release: vmData.release,
image: vmData.image,
engine: vmData.engine,
engine_version: vmData.engine_version,
};
});
return orderBy(
vms,
[sorter.column].reduce((retval, col) => {
if (col === "memory_usage") {
col = ["memory_usage"];
}
return retval.concat(col);
}, []),
[sorter.isReverseColumn(sorter.column) ? "desc" : "asc"],
);
},
showEngine() {
return this.views.show_engine_name;
},
},
watch: {
sortProcessesKey: {
immediate: true,
handler(sortProcessesKey) {
const sortable = ["load_1min", "cpu_time", "memory_usage", "name"];
function isReverseColumn(column) {
return !["name"].includes(column);
}
function getColumnLabel(value) {
const labels = {
load_1min: "load",
cpu_time: "CPU time",
memory_usage: "memory consumption",
name: "VM name",
None: "None",
};
return labels[value] || value;
}
if (!sortProcessesKey || sortable.includes(sortProcessesKey)) {
this.sorter = {
column: this.args.sort_processes_key || "cpu_time",
auto: !this.args.sort_processes_key,
isReverseColumn,
getColumnLabel,
};
}
},
},
},
};
</script>

View File

@@ -20,46 +20,46 @@
</template>
<script>
import { orderBy } from 'lodash';
import { orderBy } from "lodash";
export default {
props: {
data: {
type: Object
}
},
computed: {
stats() {
return this.data.stats['wifi'];
},
view() {
return this.data.views['wifi'];
},
hotspots() {
const hotspots = this.stats
.map((hotspotData) => {
if (hotspotData['ssid'] === '') {
return;
}
return {
ssid: hotspotData['ssid'],
quality_level: hotspotData['quality_level']
};
})
.filter(Boolean);
return orderBy(hotspots, ['ssid']);
},
hasHotpots() {
return this.hotspots.length > 0;
}
},
methods: {
getDecoration(hotpost, field) {
if (this.view[hotpost.ssid][field] === undefined) {
return;
}
return this.view[hotpost.ssid][field].decoration.toLowerCase();
}
}
props: {
data: {
type: Object,
},
},
computed: {
stats() {
return this.data.stats["wifi"];
},
view() {
return this.data.views["wifi"];
},
hotspots() {
const hotspots = this.stats
.map((hotspotData) => {
if (hotspotData["ssid"] === "") {
return;
}
return {
ssid: hotspotData["ssid"],
quality_level: hotspotData["quality_level"],
};
})
.filter(Boolean);
return orderBy(hotspots, ["ssid"]);
},
hasHotpots() {
return this.hotspots.length > 0;
},
},
methods: {
getDecoration(hotpost, field) {
if (this.view[hotpost.ssid][field] === undefined) {
return;
}
return this.view[hotpost.ssid][field].decoration.toLowerCase();
},
},
};
</script>

View File

@@ -1,141 +1,144 @@
import { min } from 'lodash';
import sanitizeHtml from 'sanitize-html';
import { min } from "lodash";
import sanitizeHtml from "sanitize-html";
export function bits(bits, low_precision) {
bits = Math.round(bits) * 8;
return bytes(bits, low_precision) + 'b';
bits = Math.round(bits) * 8;
return bytes(bits, low_precision) + "b";
}
export function bytes(bytes, low_precision) {
low_precision = low_precision || false;
if (isNaN(parseFloat(bytes)) || !isFinite(bytes) || bytes == 0) {
return bytes;
}
low_precision = low_precision || false;
if (isNaN(parseFloat(bytes)) || !isFinite(bytes) || bytes == 0) {
return bytes;
}
const symbols = ['Y', 'Z', 'E', 'P', 'T', 'G', 'M', 'K'];
const prefix = {
Y: 1208925819614629174706176,
Z: 1180591620717411303424,
E: 1152921504606846976,
P: 1125899906842624,
T: 1099511627776,
G: 1073741824,
M: 1048576,
K: 1024
};
const symbols = ["Y", "Z", "E", "P", "T", "G", "M", "K"];
const prefix = {
Y: 1208925819614629174706176,
Z: 1180591620717411303424,
E: 1152921504606846976,
P: 1125899906842624,
T: 1099511627776,
G: 1073741824,
M: 1048576,
K: 1024,
};
for (var i = 0; i < symbols.length; i++) {
var symbol = symbols[i];
var value = bytes / prefix[symbol];
for (var i = 0; i < symbols.length; i++) {
var symbol = symbols[i];
var value = bytes / prefix[symbol];
if (value > 1) {
var decimal_precision = 0;
if (value > 1) {
var decimal_precision = 0;
if (value < 10) {
decimal_precision = 2;
} else if (value < 100) {
decimal_precision = 1;
}
if (value < 10) {
decimal_precision = 2;
} else if (value < 100) {
decimal_precision = 1;
}
if (low_precision) {
if (symbol == 'MK') {
decimal_precision = 0;
} else {
decimal_precision = min([1, decimal_precision]);
}
} else if (symbol == 'K') {
decimal_precision = 0;
}
if (low_precision) {
if (symbol == "MK") {
decimal_precision = 0;
} else {
decimal_precision = min([1, decimal_precision]);
}
} else if (symbol == "K") {
decimal_precision = 0;
}
return parseFloat(value).toFixed(decimal_precision) + symbol;
}
}
return parseFloat(value).toFixed(decimal_precision) + symbol;
}
}
return bytes.toFixed(0);
return bytes.toFixed(0);
}
export function exclamation(input) {
if (input === undefined || input === '') {
return '?';
}
return input;
if (input === undefined || input === "") {
return "?";
}
return input;
}
export function leftPad(value, length, chars) {
length = length || 0;
chars = chars || ' ';
return String(value).padStart(length, chars);
length = length || 0;
chars = chars || " ";
return String(value).padStart(length, chars);
}
export function limitTo(value, limit) {
if (typeof value.slice !== 'function') {
value = String(value);
}
return value.slice(0, limit);
if (typeof value.slice !== "function") {
value = String(value);
}
return value.slice(0, limit);
}
export function minSize(input, max, begin = true) {
max = max || 8;
if (input.length > max) {
if (begin) {
return input.substring(0, max - 1) + '_';
} else {
return '_' + input.substring(input.length - max + 1);
}
}
return input;
max = max || 8;
if (input.length > max) {
if (begin) {
return input.substring(0, max - 1) + "_";
} else {
return "_" + input.substring(input.length - max + 1);
}
}
return input;
}
export function nl2br(input) {
function escapeHTML(html) {
var div = document.createElement('div');
div.innerText = html;
return div.innerHTML;
}
function escapeHTML(html) {
var div = document.createElement("div");
div.innerText = html;
return div.innerHTML;
}
if (typeof input === 'undefined') {
return input;
}
if (typeof input === "undefined") {
return input;
}
var sanitizedInput = escapeHTML(input);
var html = sanitizedInput.replace(/\n/g, '<br>');
var sanitizedInput = escapeHTML(input);
var html = sanitizedInput.replace(/\n/g, "<br>");
return sanitizeHtml(html);
return sanitizeHtml(html);
}
export function number(value, options) {
// If value is undefined or not a number then return '-'
if ((typeof value === 'undefined') || isNaN(value)) {
return '-';
}
// Else
return new Intl.NumberFormat(
"en-US",
typeof options === 'number' ? { maximumFractionDigits: options } : options
).format(value);
// If value is undefined or not a number then return '-'
if (typeof value === "undefined" || isNaN(value)) {
return "-";
}
// Else
return new Intl.NumberFormat(
"en-US",
typeof options === "number" ? { maximumFractionDigits: options } : options,
).format(value);
}
export function timemillis(array) {
var sum = 0.0;
for (var i = 0; i < array.length; i++) {
sum += array[i] * 1000.0;
}
return sum;
var sum = 0.0;
for (var i = 0; i < array.length; i++) {
sum += array[i] * 1000.0;
}
return sum;
}
export function timedelta(value) {
var sum = timemillis(value);
var d = new Date(sum);
var doy = Math.floor((d - new Date(d.getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24);
return {
hours: d.getUTCHours() + (doy - 1) * 24,
minutes: d.getUTCMinutes(),
seconds: d.getUTCSeconds(),
milliseconds: parseInt('' + d.getUTCMilliseconds() / 10)
};
var sum = timemillis(value);
var d = new Date(sum);
var doy = Math.floor(
(d - new Date(d.getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24,
);
return {
hours: d.getUTCHours() + (doy - 1) * 24,
minutes: d.getUTCMinutes(),
seconds: d.getUTCSeconds(),
milliseconds: parseInt("" + d.getUTCMilliseconds() / 10),
};
}
export function dictToString(dict) {
return Object.entries(dict).map(([key, value]) => `${key}: ${value}`).join(' / ');
return Object.entries(dict)
.map(([key, value]) => `${key}: ${value}`)
.join(" / ");
}

View File

@@ -1,132 +1,140 @@
import { store } from './store.js';
import Favico from 'favico.js';
import Favico from "favico.js";
import { store } from "./store.js";
// prettier-ignore
const fetchAll = () => fetch('api/4/all', { method: 'GET' }).then((response) => response.json());
const fetchAll = () =>
fetch("api/4/all", { method: "GET" }).then((response) => response.json());
// prettier-ignore
const fetchAllViews = () => fetch('api/4/all/views', { method: 'GET' }).then((response) => response.json());
const fetchAllViews = () =>
fetch("api/4/all/views", { method: "GET" }).then((response) =>
response.json(),
);
// prettier-ignore
const fetchAllLimits = () => fetch('api/4/all/limits', { method: 'GET' }).then((response) => response.json());
const fetchAllLimits = () =>
fetch("api/4/all/limits", { method: "GET" }).then((response) =>
response.json(),
);
// prettier-ignore
const fetchArgs = () => fetch('api/4/args', { method: 'GET' }).then((response) => response.json());
const fetchArgs = () =>
fetch("api/4/args", { method: "GET" }).then((response) => response.json());
// prettier-ignore
const fetchConfig = () => fetch('api/4/config', { method: 'GET' }).then((response) => response.json());
const fetchConfig = () =>
fetch("api/4/config", { method: "GET" }).then((response) => response.json());
class GlancesHelperService {
limits = {};
limitSuffix = ['critical', 'careful', 'warning'];
limits = {};
limitSuffix = ["critical", "careful", "warning"];
setLimits(limits) {
this.limits = limits;
}
setLimits(limits) {
this.limits = limits;
}
getLimit(pluginName, limitName) {
if (this.limits[pluginName] != undefined) {
if (this.limits[pluginName][limitName] != undefined) {
return this.limits[pluginName][limitName]
}
}
return null
}
getLimit(pluginName, limitName) {
if (this.limits[pluginName] != undefined) {
if (this.limits[pluginName][limitName] != undefined) {
return this.limits[pluginName][limitName];
}
}
return null;
}
getAlert(pluginName, limitNamePrefix, current, maximum, log) {
current = current || 0;
maximum = maximum || 100;
log = log || false;
getAlert(pluginName, limitNamePrefix, current, maximum, log) {
current = current || 0;
maximum = maximum || 100;
log = log || false;
var log_str = log ? '_log' : '';
var value = (current * 100) / maximum;
var log_str = log ? "_log" : "";
var value = (current * 100) / maximum;
if (this.limits[pluginName] != undefined) {
for (var i = 0; i < this.limitSuffix.length; i++) {
var limitName = limitNamePrefix + this.limitSuffix[i];
var limit = this.limits[pluginName][limitName];
if (value >= limit) {
var pos = limitName.lastIndexOf('_');
var className = limitName.substring(pos + 1);
return className + log_str;
}
}
}
if (this.limits[pluginName] != undefined) {
for (var i = 0; i < this.limitSuffix.length; i++) {
var limitName = limitNamePrefix + this.limitSuffix[i];
var limit = this.limits[pluginName][limitName];
if (value >= limit) {
var pos = limitName.lastIndexOf("_");
var className = limitName.substring(pos + 1);
return className + log_str;
}
}
}
return 'ok' + log_str;
}
return "ok" + log_str;
}
getAlertLog(pluginName, limitNamePrefix, current, maximum) {
return this.getAlert(pluginName, limitNamePrefix, current, maximum, true);
}
getAlertLog(pluginName, limitNamePrefix, current, maximum) {
return this.getAlert(pluginName, limitNamePrefix, current, maximum, true);
}
}
export const GlancesHelper = new GlancesHelperService();
class GlancesStatsService {
data = undefined;
data = undefined;
init(REFRESH_TIME = 60) {
let timeout = undefined;
const fetchData = () => {
store.status = 'PENDING';
return Promise.all([fetchAll(), fetchAllViews()])
.then((response) => {
const data = {
stats: response[0],
views: response[1],
isBsd: response[0].system?.os_name === 'FreeBSD',
isLinux: response[0].system?.os_name === 'Linux',
isSunOS: response[0].system?.os_name === 'SunOS',
isMac: response[0].system?.os_name === 'Darwin',
isWindows: response[0].system?.os_name === 'Windows'
};
this.data = data;
store.data = data;
store.status = 'SUCCESS';
})
.catch((error) => {
console.log(error);
store.status = 'FAILURE';
})
.then(() => {
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(fetchData, REFRESH_TIME * 1000); // in milliseconds
});
};
fetchData();
init(REFRESH_TIME = 60) {
let timeout;
const fetchData = () => {
store.status = "PENDING";
return Promise.all([fetchAll(), fetchAllViews()])
.then((response) => {
const data = {
stats: response[0],
views: response[1],
isBsd: response[0].system?.os_name === "FreeBSD",
isLinux: response[0].system?.os_name === "Linux",
isSunOS: response[0].system?.os_name === "SunOS",
isMac: response[0].system?.os_name === "Darwin",
isWindows: response[0].system?.os_name === "Windows",
};
this.data = data;
store.data = data;
store.status = "SUCCESS";
})
.catch((error) => {
console.log(error);
store.status = "FAILURE";
})
.then(() => {
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(fetchData, REFRESH_TIME * 1000); // in milliseconds
});
};
fetchData();
fetchAllLimits().then((response) => {
GlancesHelper.setLimits(response);
});
fetchAllLimits().then((response) => {
GlancesHelper.setLimits(response);
});
fetchArgs().then((response = {}) => {
store.args = { ...store.args, ...response };
});
fetchArgs().then((response = {}) => {
store.args = { ...store.args, ...response };
});
fetchConfig().then((response = {}) => {
store.config = { ...store.config, ...response };
});
}
fetchConfig().then((response = {}) => {
store.config = { ...store.config, ...response };
});
}
getData() {
return this.data;
}
getData() {
return this.data;
}
}
export const GlancesStats = new GlancesStatsService();
class GlancesFavicoService {
constructor() {
this.favico = new Favico({
animation: 'none'
});
}
badge(nb) {
this.favico.badge(nb);
}
reset() {
this.favico.reset();
}
constructor() {
this.favico = new Favico({
animation: "none",
});
}
badge(nb) {
this.favico.badge(nb);
}
reset() {
this.favico.reset();
}
}
export const GlancesFavico = new GlancesFavicoService();

View File

@@ -1,8 +1,8 @@
import { reactive } from 'vue';
import { reactive } from "vue";
export const store = reactive({
args: undefined,
config: undefined,
data: undefined,
status: 'IDLE'
args: undefined,
config: undefined,
data: undefined,
status: "IDLE",
});

View File

@@ -1,24 +1,16 @@
{
"topMenu": [
"quicklook",
"cpu",
"percpu",
"gpu",
"mem",
"memswap",
"load"
],
"leftMenu": [
"network",
"ports",
"wifi",
"connections",
"diskio",
"fs",
"irq",
"folders",
"raid",
"smart",
"sensors"
]
"topMenu": ["quicklook", "cpu", "percpu", "gpu", "mem", "memswap", "load"],
"leftMenu": [
"network",
"ports",
"wifi",
"connections",
"diskio",
"fs",
"irq",
"folders",
"raid",
"smart",
"sensors"
]
}

View File

@@ -1,41 +1,41 @@
{
"private": true,
"dependencies": {
"bootstrap": "^5.3.5",
"favico.js": "^0.3.10",
"hotkeys-js": "^3.13.9",
"lodash": "^4.17.21",
"sanitize-html": "^2.16.0",
"vue": "^3.5.13"
},
"devDependencies": {
"@vue/compiler-sfc": "^3.5.13",
"copy-webpack-plugin": "^13.0.0",
"css-loader": "^7.1.2",
"del": "^8.0.0",
"eslint": "^9.25.0",
"eslint-config-prettier": "^10.1.2",
"eslint-plugin-vue": "^10.0.0",
"globals": "^16.0.0",
"html-webpack-plugin": "^5.6.3",
"less": "^4.3.0",
"less-loader": "^12.2.0",
"sass": "^1.86.3",
"sass-loader": "^16.0.5",
"style-loader": "^4.0.0",
"typescript-eslint": "^8.30.1",
"url-loader": "^4.1.1",
"vue-loader": "^17.4.2",
"webpack": "^5.99.6",
"webpack-cli": "^6.0.1",
"webpack-dev-server": "^5.2.1"
},
"scripts": {
"build": "webpack --progress --mode=production",
"start": "webpack serve --mode=development",
"watch": "webpack --progress --watch",
"lint": "eslint ./ --ext .js,.vue",
"lint-fix": "eslint ./ --ext .js,.vue --fix",
"clean": "rm -rf node_modules"
}
"private": true,
"dependencies": {
"bootstrap": "^5.3.5",
"favico.js": "^0.3.10",
"hotkeys-js": "^3.13.9",
"lodash": "^4.17.21",
"sanitize-html": "^2.16.0",
"vue": "^3.5.13"
},
"devDependencies": {
"@vue/compiler-sfc": "^3.5.13",
"copy-webpack-plugin": "^13.0.0",
"css-loader": "^7.1.2",
"del": "^8.0.0",
"eslint": "^9.25.0",
"eslint-config-prettier": "^10.1.2",
"eslint-plugin-vue": "^10.0.0",
"globals": "^16.0.0",
"html-webpack-plugin": "^5.6.3",
"less": "^4.3.0",
"less-loader": "^12.2.0",
"sass": "^1.86.3",
"sass-loader": "^16.0.5",
"style-loader": "^4.0.0",
"typescript-eslint": "^8.30.1",
"url-loader": "^4.1.1",
"vue-loader": "^17.4.2",
"webpack": "^5.99.6",
"webpack-cli": "^6.0.1",
"webpack-dev-server": "^5.2.1"
},
"scripts": {
"build": "webpack --progress --mode=production",
"start": "webpack serve --mode=development",
"watch": "webpack --progress --watch",
"lint": "eslint ./ --ext .js,.vue",
"lint-fix": "eslint ./ --ext .js,.vue --fix",
"clean": "rm -rf node_modules"
}
}

View File

@@ -1,86 +1,90 @@
const webpack = require('webpack');
const webpack = require("webpack");
const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const TerserWebpackPlugin = require('terser-webpack-plugin');
const { VueLoaderPlugin } = require('vue-loader');
const HtmlWebpackPlugin = require("html-webpack-plugin");
const TerserWebpackPlugin = require("terser-webpack-plugin");
const { VueLoaderPlugin } = require("vue-loader");
const PORT = process.env.PORT || 61209;
module.exports = (_, env) => {
const isProd = env.mode === 'production';
const isProd = env.mode === "production";
return {
mode: isProd ? 'production' : 'development',
entry: {
glances: "./js/app.js",
browser: "./js/browser.js"
},
output: {
path: path.join(__dirname, "public"),
filename: "[name].js",
publicPath: '/',
clean: true
},
devtool: isProd ? false : 'eval-source-map',
module: {
rules: [
{
test: /\.vue$/i,
loader: 'vue-loader'
},
{
test: /\.scss$/i,
use: [{
loader: "style-loader",
}, {
loader: "css-loader",
}, {
loader: "sass-loader",
}]
},
{
test: /\.css$/i,
use: [{
loader: "style-loader",
}, {
loader: "css-loader",
}]
}
],
},
plugins: [
new webpack.DefinePlugin({
__VUE_OPTIONS_API__: true,
__VUE_PROD_DEVTOOLS__: false,
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
}),
new CopyWebpackPlugin({
patterns: [
{ from: "./images/favicon.ico" }
]
}),
!isProd && new HtmlWebpackPlugin({
template: './templates/index.html',
inject: false
}),
isProd && new TerserWebpackPlugin({ extractComments: false }),
new VueLoaderPlugin()
].filter(Boolean),
devServer: {
client: {
overlay: false
},
host: '0.0.0.0',
port: PORT,
hot: true,
proxy: [
{
context: ['/api'],
target: 'http://0.0.0.0:61208'
}
]
}
};
return {
mode: isProd ? "production" : "development",
entry: {
glances: "./js/app.js",
browser: "./js/browser.js",
},
output: {
path: path.join(__dirname, "public"),
filename: "[name].js",
publicPath: "/",
clean: true,
},
devtool: isProd ? false : "eval-source-map",
module: {
rules: [
{
test: /\.vue$/i,
loader: "vue-loader",
},
{
test: /\.scss$/i,
use: [
{
loader: "style-loader",
},
{
loader: "css-loader",
},
{
loader: "sass-loader",
},
],
},
{
test: /\.css$/i,
use: [
{
loader: "style-loader",
},
{
loader: "css-loader",
},
],
},
],
},
plugins: [
new webpack.DefinePlugin({
__VUE_OPTIONS_API__: true,
__VUE_PROD_DEVTOOLS__: false,
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false,
}),
new CopyWebpackPlugin({
patterns: [{ from: "./images/favicon.ico" }],
}),
!isProd &&
new HtmlWebpackPlugin({
template: "./templates/index.html",
inject: false,
}),
isProd && new TerserWebpackPlugin({ extractComments: false }),
new VueLoaderPlugin(),
].filter(Boolean),
devServer: {
client: {
overlay: false,
},
host: "0.0.0.0",
port: PORT,
hot: true,
proxy: [
{
context: ["/api"],
target: "http://0.0.0.0:61208",
},
],
},
};
};

View File

@@ -1,8 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
],
"prHourlyLimit": 3,
"updateLockFiles": false
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"],
"prHourlyLimit": 3,
"updateLockFiles": false
}

14
tests-data/issues/issue3322-homepage/run-homepage.sh Normal file → Executable file
View File

@@ -1,7 +1,9 @@
#!/bin/sh
docker run --rm \
--name homepage \
-p 3000:3000 \
-e HOMEPAGE_ALLOWED_HOSTS=localhost:3000,0.0.0.0:3000 \
-v ./config:/app/config \
-v /var/run/docker.sock:/var/run/docker.sock \
ghcr.io/gethomepage/homepage:latest
--name homepage \
-p 3000:3000 \
-e HOMEPAGE_ALLOWED_HOSTS=localhost:3000,0.0.0.0:3000 \
-v ./config:/app/config \
-v /var/run/docker.sock:/var/run/docker.sock \
ghcr.io/gethomepage/homepage:latest

View File

@@ -1,9 +1,11 @@
#!/bin/sh
docker run -d \
--name homeassistant \
--privileged \
--restart=unless-stopped \
-e TZ=Europe/Paris \
-v ./config:/config \
-v /run/dbus:/run/dbus:ro \
--network=host \
ghcr.io/home-assistant/home-assistant:stable
--name homeassistant \
--privileged \
--restart=unless-stopped \
-e TZ=Europe/Paris \
-v ./config:/config \
-v /run/dbus:/run/dbus:ro \
--network=host \
ghcr.io/home-assistant/home-assistant:stable

2
tests-data/tools/find-duplicate-lines.sh Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/bin/sh
find ./glances/ -type f -name "*.py" -exec sh -c '
duplicate_found=0
for file; do

View File

@@ -19,7 +19,7 @@ for i in {1..30}; do
break
fi
if [ $i -eq 30 ]; then
if [ "$i" -eq 30 ]; then
echo "Error: Timed out waiting for InfluxDB to start"
docker stop influxdb-v1-for-glances
docker rm influxdb-v1-for-glances
@@ -68,4 +68,4 @@ echo "Stopping and removing InfluxDB container..."
docker stop influxdb-v1-for-glances
docker rm influxdb-v1-for-glances
echo "Script completed successfully!"
echo "Script completed successfully!"

View File

@@ -18,7 +18,7 @@ sleep 5
# Create the token
echo "Creating InfluxDB token..."
TOKEN_RETURN=$(docker exec influxdb-v3-for-glances influxdb3 create token --admin)
TOKEN=$(echo -n $TOKEN_RETURN | awk '{ print $6 }')
TOKEN=$(echo -n "$TOKEN_RETURN" | awk '{ print $6 }')
echo "Token: $TOKEN"
# Create a new configuration for the test

View File

@@ -1,7 +1,7 @@
#!/bin/sh
#!/bin/bash
if [ $(id -u) -ne 0 ]; then
echo -e "* ERROR: User $(whoami) is not root, and does not have sudo privileges"
if [ "$(id -u)" != "0" ]; then
echo "* ERROR: User $(whoami) is not root, and does not have sudo privileges"
exit 1
fi
@@ -14,9 +14,9 @@ fi
python setup.py install --record install.record
for i in $(cat install.record); do
rm $i
done
while IFS= read -r i; do
rm "$i"
done < install.record
echo -e "\n\n* SUCCESS: Uninstall complete."
rm install.record