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: 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 - repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.1 rev: v0.14.1
hooks: hooks:
# Run the linter.
- id: ruff-check - id: ruff-check
name: "🐍 python · Linter with Ruff"
types_or: [ python, pyi ] types_or: [ python, pyi ]
args: [ --fix, --exit-non-zero-on-fix ] args: [ --fix, --exit-non-zero-on-fix ]
# Run the formatter.
- id: ruff-format - id: ruff-format
name: "🐍 python · Format with Ruff"
types_or: [ python, pyi ] 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 - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0 rev: v6.0.0
hooks: hooks:
- id: check-ast - id: check-executables-have-shebangs
- id: check-docstring-first name: "📁 filesystem/⚙️ exec · Verify shebang presence"
- id: check-json
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable - 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 - id: check-toml
name: "📄 formats/toml · Validate TOML files"
- id: check-yaml - id: check-yaml
name: "📄 formats/yaml · Validate YAML syntax"
- id: debug-statements - id: debug-statements
name: "🐍 python/🪲 debug · Detect debug statements"
- id: detect-private-key - id: detect-private-key
name: "🔐 security · Detect private keys"
- id: mixed-line-ending - id: mixed-line-ending
name: "📄 text/↩️ newline · Normalize line endings"
- id: requirements-txt-fixer - id: requirements-txt-fixer
name: "🐍 python/📦 deps · Sort requirements.txt"
- repo: local - repo: local
hooks: 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 - 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 entry: bash tests-data/tools/find-duplicate-lines.sh
language: system language: system
types: [python] 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. # if the command is only `make`, the default tasks will be the printing of the help.
.DEFAULT_GOAL := 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 help: ## List all make commands available
@grep -E '^[\.a-zA-Z_%-]+:.*?## .*$$' $(MAKEFILE_LIST) | \ @grep -E '^[\.a-zA-Z_%-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk -F ":" '{print $1}' | \ awk -F ":" '{print $1}' | \
grep -v % | \ grep -v % | sed 's/\\//g' | sort | \
sed 's/\\//g' | \
sort | \
awk 'BEGIN {FS = ":[^:]*?##"}; {printf "\033[1;34mmake %-50s\033[0m %s\n", $$1, $$2}' 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 # 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 /bin/bash tests-data/tools/find-duplicate-lines.sh
format: ## Format the code format: ## Format the code

View File

@ -135,9 +135,7 @@
"justifyMode": "auto", "justifyMode": "auto",
"orientation": "horizontal", "orientation": "horizontal",
"reduceOptions": { "reduceOptions": {
"calcs": [ "calcs": ["lastNotNull"],
"lastNotNull"
],
"fields": "", "fields": "",
"values": false "values": false
}, },
@ -152,9 +150,7 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
} }
], ],
@ -167,9 +163,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["cpucore"],
"cpucore"
],
"type": "field" "type": "field"
}, },
{ {
@ -254,11 +248,7 @@
"links": [], "links": [],
"options": { "options": {
"legend": { "legend": {
"calcs": [ "calcs": ["mean", "max", "min"],
"mean",
"max",
"min"
],
"displayMode": "table", "displayMode": "table",
"placement": "right" "placement": "right"
}, },
@ -275,15 +265,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -296,9 +282,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["min1"],
"min1"
],
"type": "field" "type": "field"
}, },
{ {
@ -324,15 +308,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -346,9 +326,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["min1"],
"min1"
],
"type": "field" "type": "field"
}, },
{ {
@ -374,15 +352,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -396,9 +370,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["min1"],
"min1"
],
"type": "field" "type": "field"
}, },
{ {
@ -476,9 +448,7 @@
"justifyMode": "auto", "justifyMode": "auto",
"orientation": "horizontal", "orientation": "horizontal",
"reduceOptions": { "reduceOptions": {
"calcs": [ "calcs": ["mean"],
"mean"
],
"fields": "", "fields": "",
"values": false "values": false
}, },
@ -493,9 +463,7 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
} }
], ],
@ -508,9 +476,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["total"],
"total"
],
"type": "field" "type": "field"
}, },
{ {
@ -612,15 +578,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -633,9 +595,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["user"],
"user"
],
"type": "field" "type": "field"
}, },
{ {
@ -660,15 +620,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -681,9 +637,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["system"],
"system"
],
"type": "field" "type": "field"
}, },
{ {
@ -709,15 +663,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -730,9 +680,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["iowait"],
"iowait"
],
"type": "field" "type": "field"
}, },
{ {
@ -870,15 +818,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -892,9 +836,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["used"],
"used"
],
"type": "field" "type": "field"
}, },
{ {
@ -919,15 +861,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -941,9 +879,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["total"],
"total"
],
"type": "field" "type": "field"
}, },
{ {
@ -1032,11 +968,7 @@
"links": [], "links": [],
"options": { "options": {
"legend": { "legend": {
"calcs": [ "calcs": ["mean", "max", "min"],
"mean",
"max",
"min"
],
"displayMode": "list", "displayMode": "list",
"placement": "bottom" "placement": "bottom"
}, },
@ -1053,15 +985,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["null"],
"null"
],
"type": "fill" "type": "fill"
} }
], ],
@ -1077,9 +1005,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["eth0.rx"],
"eth0.rx"
],
"type": "field" "type": "field"
}, },
{ {
@ -1098,15 +1024,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["null"],
"null"
],
"type": "fill" "type": "fill"
} }
], ],
@ -1120,9 +1042,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["eth0.tx"],
"eth0.tx"
],
"type": "field" "type": "field"
}, },
{ {
@ -1255,9 +1175,7 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
} }
], ],
@ -1271,9 +1189,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["used"],
"used"
],
"type": "field" "type": "field"
}, },
{ {
@ -1292,9 +1208,7 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
} }
], ],
@ -1308,9 +1222,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["total"],
"total"
],
"type": "field" "type": "field"
}, },
{ {
@ -1393,11 +1305,7 @@
"links": [], "links": [],
"options": { "options": {
"legend": { "legend": {
"calcs": [ "calcs": ["mean", "max", "min"],
"mean",
"max",
"min"
],
"displayMode": "list", "displayMode": "list",
"placement": "bottom" "placement": "bottom"
}, },
@ -1414,15 +1322,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -1436,9 +1340,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["sda2.read_bytes"],
"sda2.read_bytes"
],
"type": "field" "type": "field"
}, },
{ {
@ -1457,15 +1359,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -1479,9 +1377,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["sda2.write_bytes"],
"sda2.write_bytes"
],
"type": "field" "type": "field"
}, },
{ {
@ -1614,15 +1510,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -1635,9 +1527,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["used"],
"used"
],
"type": "field" "type": "field"
}, },
{ {
@ -1668,15 +1558,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -1689,9 +1575,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["size"],
"size"
],
"type": "field" "type": "field"
}, },
{ {
@ -1778,9 +1662,7 @@
"justifyMode": "auto", "justifyMode": "auto",
"orientation": "horizontal", "orientation": "horizontal",
"reduceOptions": { "reduceOptions": {
"calcs": [ "calcs": ["mean"],
"mean"
],
"fields": "", "fields": "",
"values": false "values": false
}, },
@ -1795,9 +1677,7 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
} }
], ],
@ -1810,9 +1690,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["percent"],
"percent"
],
"type": "field" "type": "field"
}, },
{ {
@ -1890,15 +1768,11 @@
"dsType": "influxdb", "dsType": "influxdb",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["null"],
"null"
],
"type": "fill" "type": "fill"
} }
], ],
@ -1911,9 +1785,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["value"],
"value"
],
"type": "field" "type": "field"
}, },
{ {
@ -1996,15 +1868,11 @@
"dsType": "influxdb", "dsType": "influxdb",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["null"],
"null"
],
"type": "fill" "type": "fill"
} }
], ],
@ -2017,9 +1885,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["value"],
"value"
],
"type": "field" "type": "field"
}, },
{ {
@ -2204,15 +2070,11 @@
"alias": "MEM", "alias": "MEM",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -2227,9 +2089,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["memory_usage"],
"memory_usage"
],
"type": "field" "type": "field"
}, },
{ {
@ -2256,15 +2116,11 @@
"alias": "CPU%", "alias": "CPU%",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -2279,9 +2135,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["cpu_percent"],
"cpu_percent"
],
"type": "field" "type": "field"
}, },
{ {
@ -2433,17 +2287,7 @@
"1d" "1d"
], ],
"status": "Stable", "status": "Stable",
"time_options": [ "time_options": ["5m", "15m", "1h", "6h", "12h", "24h", "2d", "7d", "30d"],
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
],
"type": "timepicker" "type": "timepicker"
}, },
"timezone": "browser", "timezone": "browser",

View File

@ -124,9 +124,7 @@
"justifyMode": "auto", "justifyMode": "auto",
"orientation": "horizontal", "orientation": "horizontal",
"reduceOptions": { "reduceOptions": {
"calcs": [ "calcs": ["mean"],
"mean"
],
"fields": "", "fields": "",
"values": false "values": false
}, },
@ -146,9 +144,7 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
} }
], ],
@ -161,9 +157,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["cpucore"],
"cpucore"
],
"type": "field" "type": "field"
}, },
{ {
@ -254,11 +248,7 @@
"id": 4, "id": 4,
"options": { "options": {
"legend": { "legend": {
"calcs": [ "calcs": ["mean", "max", "min"],
"mean",
"max",
"min"
],
"displayMode": "table", "displayMode": "table",
"placement": "right", "placement": "right",
"showLegend": true "showLegend": true
@ -281,15 +271,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -302,9 +288,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["min1"],
"min1"
],
"type": "field" "type": "field"
}, },
{ {
@ -334,15 +318,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -355,9 +335,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["min5"],
"min5"
],
"type": "field" "type": "field"
}, },
{ {
@ -387,15 +365,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -408,9 +382,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["min15"],
"min15"
],
"type": "field" "type": "field"
}, },
{ {
@ -486,9 +458,7 @@
"justifyMode": "auto", "justifyMode": "auto",
"orientation": "horizontal", "orientation": "horizontal",
"reduceOptions": { "reduceOptions": {
"calcs": [ "calcs": ["mean"],
"mean"
],
"fields": "", "fields": "",
"values": false "values": false
}, },
@ -508,9 +478,7 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
} }
], ],
@ -523,9 +491,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["total"],
"total"
],
"type": "field" "type": "field"
}, },
{ {
@ -639,15 +605,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -660,9 +622,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["user"],
"user"
],
"type": "field" "type": "field"
}, },
{ {
@ -691,15 +651,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -712,9 +668,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["system"],
"system"
],
"type": "field" "type": "field"
}, },
{ {
@ -744,15 +698,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -765,9 +715,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["iowait"],
"iowait"
],
"type": "field" "type": "field"
}, },
{ {
@ -899,15 +847,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -921,9 +865,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["used"],
"used"
],
"type": "field" "type": "field"
}, },
{ {
@ -952,15 +894,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -974,9 +912,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["total"],
"total"
],
"type": "field" "type": "field"
}, },
{ {
@ -1068,11 +1004,7 @@
"id": 9, "id": 9,
"options": { "options": {
"legend": { "legend": {
"calcs": [ "calcs": ["mean", "max", "min"],
"mean",
"max",
"min"
],
"displayMode": "list", "displayMode": "list",
"placement": "bottom", "placement": "bottom",
"showLegend": true "showLegend": true
@ -1095,15 +1027,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["null"],
"null"
],
"type": "fill" "type": "fill"
} }
], ],
@ -1118,9 +1046,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["eth0.rx"],
"eth0.rx"
],
"type": "field" "type": "field"
}, },
{ {
@ -1143,15 +1069,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["null"],
"null"
],
"type": "fill" "type": "fill"
} }
], ],
@ -1165,9 +1087,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["eth0.tx"],
"eth0.tx"
],
"type": "field" "type": "field"
}, },
{ {
@ -1293,9 +1213,7 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
} }
], ],
@ -1309,9 +1227,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["used"],
"used"
],
"type": "field" "type": "field"
}, },
{ {
@ -1334,9 +1250,7 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
} }
], ],
@ -1350,9 +1264,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["total"],
"total"
],
"type": "field" "type": "field"
}, },
{ {
@ -1438,11 +1350,7 @@
"id": 10, "id": 10,
"options": { "options": {
"legend": { "legend": {
"calcs": [ "calcs": ["mean", "max", "min"],
"mean",
"max",
"min"
],
"displayMode": "list", "displayMode": "list",
"placement": "bottom", "placement": "bottom",
"showLegend": true "showLegend": true
@ -1465,15 +1373,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -1487,9 +1391,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["sda2.read_bytes"],
"sda2.read_bytes"
],
"type": "field" "type": "field"
}, },
{ {
@ -1512,15 +1414,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -1534,9 +1432,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["sda2.write_bytes"],
"sda2.write_bytes"
],
"type": "field" "type": "field"
}, },
{ {
@ -1678,15 +1574,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -1699,9 +1591,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["used"],
"used"
],
"type": "field" "type": "field"
}, },
{ {
@ -1736,15 +1626,11 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -1757,9 +1643,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["size"],
"size"
],
"type": "field" "type": "field"
}, },
{ {
@ -1844,9 +1728,7 @@
"justifyMode": "auto", "justifyMode": "auto",
"orientation": "horizontal", "orientation": "horizontal",
"reduceOptions": { "reduceOptions": {
"calcs": [ "calcs": ["mean"],
"mean"
],
"fields": "", "fields": "",
"values": false "values": false
}, },
@ -1866,9 +1748,7 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
} }
], ],
@ -1881,9 +1761,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["percent"],
"percent"
],
"type": "field" "type": "field"
}, },
{ {
@ -1967,9 +1845,7 @@
"justifyMode": "auto", "justifyMode": "auto",
"orientation": "horizontal", "orientation": "horizontal",
"reduceOptions": { "reduceOptions": {
"calcs": [ "calcs": ["mean"],
"mean"
],
"fields": "", "fields": "",
"values": false "values": false
}, },
@ -1989,9 +1865,7 @@
"function": "mean", "function": "mean",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["auto"],
"auto"
],
"type": "time" "type": "time"
} }
], ],
@ -2005,9 +1879,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["percent"],
"percent"
],
"type": "field" "type": "field"
}, },
{ {
@ -2155,21 +2027,15 @@
"dsType": "influxdb", "dsType": "influxdb",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["label::tag"],
"label::tag"
],
"type": "tag" "type": "tag"
}, },
{ {
"params": [ "params": ["null"],
"null"
],
"type": "fill" "type": "fill"
} }
], ],
@ -2181,9 +2047,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["value"],
"value"
],
"type": "field" "type": "field"
}, },
{ {
@ -2303,21 +2167,15 @@
"dsType": "influxdb", "dsType": "influxdb",
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["label::tag"],
"label::tag"
],
"type": "tag" "type": "tag"
}, },
{ {
"params": [ "params": ["null"],
"null"
],
"type": "fill" "type": "fill"
} }
], ],
@ -2329,9 +2187,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["value"],
"value"
],
"type": "field" "type": "field"
}, },
{ {
@ -2574,15 +2430,11 @@
}, },
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -2597,9 +2449,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["cpu_percent"],
"cpu_percent"
],
"type": "field" "type": "field"
}, },
{ {
@ -2630,15 +2480,11 @@
}, },
"groupBy": [ "groupBy": [
{ {
"params": [ "params": ["$__interval"],
"$__interval"
],
"type": "time" "type": "time"
}, },
{ {
"params": [ "params": ["none"],
"none"
],
"type": "fill" "type": "fill"
} }
], ],
@ -2653,9 +2499,7 @@
"select": [ "select": [
[ [
{ {
"params": [ "params": ["memory_usage"],
"memory_usage"
],
"type": "field" "type": "field"
}, },
{ {
@ -2800,17 +2644,7 @@
"1d" "1d"
], ],
"status": "Stable", "status": "Stable",
"time_options": [ "time_options": ["5m", "15m", "1h", "6h", "12h", "24h", "2d", "7d", "30d"],
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
],
"type": "timepicker" "type": "timepicker"
}, },
"timezone": "browser", "timezone": "browser",

View File

@ -5,7 +5,9 @@
"formatters": { "formatters": {
"standard": { "format": "%(asctime)s -- %(levelname)s -- %(message)s" }, "standard": { "format": "%(asctime)s -- %(levelname)s -- %(message)s" },
"short": { "format": "%(levelname)s -- %(message)s" }, "short": { "format": "%(levelname)s -- %(message)s" },
"long": {"format": "%(asctime)s -- %(levelname)s -- %(message)s (%(funcName)s in %(filename)s)"}, "long": {
"format": "%(asctime)s -- %(levelname)s -- %(message)s (%(funcName)s in %(filename)s)"
},
"free": { "format": "%(message)s" } "free": { "format": "%(message)s" }
}, },
"handlers": { "handlers": {

File diff suppressed because one or more lines are too long

View File

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

View File

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

View File

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

View File

@ -90,41 +90,40 @@
</template> </template>
<script> <script>
import hotkeys from 'hotkeys-js'; import hotkeys from "hotkeys-js";
import { GlancesStats } from './services.js'; import GlancesHelp from "./components/help.vue";
import { store } from './store.js'; 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 uiconfig from "./uiconfig.json";
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';
export default { export default {
components: { components: {
@ -156,11 +155,11 @@ export default {
GlancesPluginSystem, GlancesPluginSystem,
GlancesPluginUptime, GlancesPluginUptime,
GlancesPluginVms, GlancesPluginVms,
GlancesPluginWifi GlancesPluginWifi,
}, },
data() { data() {
return { return {
store store,
}; };
}, },
computed: { computed: {
@ -184,31 +183,34 @@ export default {
}, },
title() { title() {
const { data } = this; const { data } = this;
const title = (data.stats && data.stats.system && data.stats.system.hostname) || ''; const title =
return title ? `${title} - Glances` : 'Glances'; (data.stats && data.stats.system && data.stats.system.hostname) || "";
return title ? `${title} - Glances` : "Glances";
}, },
topMenu() { topMenu() {
return this.config.outputs !== undefined && this.config.outputs.top_menu !== undefined return this.config.outputs !== undefined &&
? this.config.outputs.top_menu.split(',') this.config.outputs.top_menu !== undefined
? this.config.outputs.top_menu.split(",")
: uiconfig.topMenu; : uiconfig.topMenu;
}, },
leftMenu() { leftMenu() {
return this.config.outputs !== undefined && this.config.outputs.left_menu !== undefined return this.config.outputs !== undefined &&
? this.config.outputs.left_menu.split(',') this.config.outputs.left_menu !== undefined
? this.config.outputs.left_menu.split(",")
: uiconfig.leftMenu; : uiconfig.leftMenu;
} },
}, },
watch: { watch: {
title() { title() {
if (document) { if (document) {
document.title = this.title; document.title = this.title;
} }
} },
}, },
mounted() { mounted() {
const GLANCES = window.__GLANCES__ || {}; const GLANCES = window.__GLANCES__ || {};
const refreshTime = isFinite(GLANCES['refresh-time']) const refreshTime = isFinite(GLANCES["refresh-time"])
? parseInt(GLANCES['refresh-time'], 10) ? parseInt(GLANCES["refresh-time"], 10)
: undefined; : undefined;
GlancesStats.init(refreshTime); GlancesStats.init(refreshTime);
this.setupHotKeys(); this.setupHotKeys();
@ -219,107 +221,111 @@ export default {
methods: { methods: {
setupHotKeys() { setupHotKeys() {
// a => Sort processes/containers automatically // a => Sort processes/containers automatically
hotkeys('a', () => { hotkeys("a", () => {
this.store.args.sort_processes_key = null; this.store.args.sort_processes_key = null;
}); });
// c => Sort processes/containers by CPU% // c => Sort processes/containers by CPU%
hotkeys('c', () => { hotkeys("c", () => {
this.store.args.sort_processes_key = 'cpu_percent'; this.store.args.sort_processes_key = "cpu_percent";
}); });
// m => Sort processes/containers by MEM% // m => Sort processes/containers by MEM%
hotkeys('m', () => { hotkeys("m", () => {
this.store.args.sort_processes_key = 'memory_percent'; this.store.args.sort_processes_key = "memory_percent";
}); });
// u => Sort processes/containers by user // u => Sort processes/containers by user
hotkeys('u', () => { hotkeys("u", () => {
this.store.args.sort_processes_key = 'username'; this.store.args.sort_processes_key = "username";
}); });
// p => Sort processes/containers by name // p => Sort processes/containers by name
hotkeys('p', () => { hotkeys("p", () => {
this.store.args.sort_processes_key = 'name'; this.store.args.sort_processes_key = "name";
}); });
// i => Sort processes/containers by I/O rate // i => Sort processes/containers by I/O rate
hotkeys('i', () => { hotkeys("i", () => {
this.store.args.sort_processes_key = 'io_counters'; this.store.args.sort_processes_key = "io_counters";
}); });
// t => Sort processes/containers by time // t => Sort processes/containers by time
hotkeys('t', () => { hotkeys("t", () => {
this.store.args.sort_processes_key = 'timemillis'; this.store.args.sort_processes_key = "timemillis";
}); });
// A => Enable/disable AMPs // A => Enable/disable AMPs
hotkeys('shift+A', () => { hotkeys("shift+A", () => {
this.store.args.disable_amps = !this.store.args.disable_amps; this.store.args.disable_amps = !this.store.args.disable_amps;
}); });
// d => Show/hide disk I/O stats // d => Show/hide disk I/O stats
hotkeys('d', () => { hotkeys("d", () => {
this.store.args.disable_diskio = !this.store.args.disable_diskio; this.store.args.disable_diskio = !this.store.args.disable_diskio;
}); });
// Q => Show/hide IRQ // Q => Show/hide IRQ
hotkeys('shift+Q', () => { hotkeys("shift+Q", () => {
this.store.args.enable_irq = !this.store.args.enable_irq; this.store.args.enable_irq = !this.store.args.enable_irq;
}); });
// f => Show/hide filesystem stats // f => Show/hide filesystem stats
hotkeys('f', () => { hotkeys("f", () => {
this.store.args.disable_fs = !this.store.args.disable_fs; this.store.args.disable_fs = !this.store.args.disable_fs;
}); });
// j => Accumulate processes by program // j => Accumulate processes by program
hotkeys('j', () => { hotkeys("j", () => {
this.store.args.programs = !this.store.args.programs; this.store.args.programs = !this.store.args.programs;
}); });
// k => Show/hide connections stats // k => Show/hide connections stats
hotkeys('k', () => { hotkeys("k", () => {
this.store.args.disable_connections = !this.store.args.disable_connections; this.store.args.disable_connections =
!this.store.args.disable_connections;
}); });
// n => Show/hide network stats // n => Show/hide network stats
hotkeys('n', () => { hotkeys("n", () => {
this.store.args.disable_network = !this.store.args.disable_network; this.store.args.disable_network = !this.store.args.disable_network;
}); });
// s => Show/hide sensors stats // s => Show/hide sensors stats
hotkeys('s', () => { hotkeys("s", () => {
this.store.args.disable_sensors = !this.store.args.disable_sensors; this.store.args.disable_sensors = !this.store.args.disable_sensors;
}); });
// 2 => Show/hide left sidebar // 2 => Show/hide left sidebar
hotkeys('2', () => { hotkeys("2", () => {
this.store.args.disable_left_sidebar = !this.store.args.disable_left_sidebar; this.store.args.disable_left_sidebar =
!this.store.args.disable_left_sidebar;
}); });
// z => Enable/disable processes stats // z => Enable/disable processes stats
hotkeys('z', () => { hotkeys("z", () => {
this.store.args.disable_process = !this.store.args.disable_process; this.store.args.disable_process = !this.store.args.disable_process;
}); });
// S => Enable/disable short processes name // S => Enable/disable short processes name
hotkeys('shift+S', () => { hotkeys("shift+S", () => {
this.store.args.process_short_name = !this.store.args.process_short_name; this.store.args.process_short_name =
!this.store.args.process_short_name;
}); });
// D => Enable/disable containers stats // D => Enable/disable containers stats
hotkeys('shift+D', () => { hotkeys("shift+D", () => {
this.store.args.disable_containers = !this.store.args.disable_containers; this.store.args.disable_containers =
!this.store.args.disable_containers;
}); });
// b => Bytes or bits for network I/O // b => Bytes or bits for network I/O
hotkeys('b', () => { hotkeys("b", () => {
this.store.args.byte = !this.store.args.byte; this.store.args.byte = !this.store.args.byte;
}); });
// 'B' => Switch between bit/s and IO/s for Disk IO // 'B' => Switch between bit/s and IO/s for Disk IO
hotkeys('shift+B', () => { hotkeys("shift+B", () => {
this.store.args.diskio_iops = !this.store.args.diskio_iops; this.store.args.diskio_iops = !this.store.args.diskio_iops;
if (this.store.args.diskio_iops) { if (this.store.args.diskio_iops) {
this.store.args.diskio_latency = false; this.store.args.diskio_latency = false;
@ -327,7 +333,7 @@ export default {
}); });
// 'L' => Switch to latency for Disk IO // 'L' => Switch to latency for Disk IO
hotkeys('shift+L', () => { hotkeys("shift+L", () => {
this.store.args.diskio_latency = !this.store.args.diskio_latency; this.store.args.diskio_latency = !this.store.args.diskio_latency;
if (this.store.args.diskio_latency) { if (this.store.args.diskio_latency) {
this.store.args.diskio_iops = false; this.store.args.diskio_iops = false;
@ -335,51 +341,51 @@ export default {
}); });
// l => Show/hide alert logs // l => Show/hide alert logs
hotkeys('l', () => { hotkeys("l", () => {
this.store.args.disable_alert = !this.store.args.disable_alert; this.store.args.disable_alert = !this.store.args.disable_alert;
}); });
// 1 => Global CPU or per-CPU stats // 1 => Global CPU or per-CPU stats
hotkeys('1', () => { hotkeys("1", () => {
this.store.args.percpu = !this.store.args.percpu; this.store.args.percpu = !this.store.args.percpu;
}); });
// h => Show/hide this help screen // h => Show/hide this help screen
hotkeys('h', () => { hotkeys("h", () => {
this.store.args.help_tag = !this.store.args.help_tag; this.store.args.help_tag = !this.store.args.help_tag;
}); });
// T => View network I/O as combination // T => View network I/O as combination
hotkeys('shift+T', () => { hotkeys("shift+T", () => {
this.store.args.network_sum = !this.store.args.network_sum; this.store.args.network_sum = !this.store.args.network_sum;
}); });
// U => View cumulative network I/O // U => View cumulative network I/O
hotkeys('shift+U', () => { hotkeys("shift+U", () => {
this.store.args.network_cumul = !this.store.args.network_cumul; this.store.args.network_cumul = !this.store.args.network_cumul;
}); });
// F => Show filesystem free space // F => Show filesystem free space
hotkeys('shift+F', () => { hotkeys("shift+F", () => {
this.store.args.fs_free_space = !this.store.args.fs_free_space; this.store.args.fs_free_space = !this.store.args.fs_free_space;
}); });
// 3 => Enable/disable quick look plugin // 3 => Enable/disable quick look plugin
hotkeys('3', () => { hotkeys("3", () => {
this.store.args.disable_quicklook = !this.store.args.disable_quicklook; this.store.args.disable_quicklook = !this.store.args.disable_quicklook;
}); });
// 6 => Enable/disable mean gpu // 6 => Enable/disable mean gpu
hotkeys('6', () => { hotkeys("6", () => {
this.store.args.meangpu = !this.store.args.meangpu; this.store.args.meangpu = !this.store.args.meangpu;
}); });
// G => Enable/disable gpu // G => Enable/disable gpu
hotkeys('shift+G', () => { hotkeys("shift+G", () => {
this.store.args.disable_gpu = !this.store.args.disable_gpu; this.store.args.disable_gpu = !this.store.args.disable_gpu;
}); });
hotkeys('5', () => { hotkeys("5", () => {
this.store.args.disable_quicklook = !this.store.args.disable_quicklook; this.store.args.disable_quicklook = !this.store.args.disable_quicklook;
this.store.args.disable_cpu = !this.store.args.disable_cpu; this.store.args.disable_cpu = !this.store.args.disable_cpu;
this.store.args.disable_mem = !this.store.args.disable_mem; this.store.args.disable_mem = !this.store.args.disable_mem;
@ -389,30 +395,30 @@ export default {
}); });
// I => Show/hide IP module // I => Show/hide IP module
hotkeys('shift+I', () => { hotkeys("shift+I", () => {
this.store.args.disable_ip = !this.store.args.disable_ip; this.store.args.disable_ip = !this.store.args.disable_ip;
}); });
// P => Enable/disable ports module // P => Enable/disable ports module
hotkeys('shift+P', () => { hotkeys("shift+P", () => {
this.store.args.disable_ports = !this.store.args.disable_ports; this.store.args.disable_ports = !this.store.args.disable_ports;
}); });
// V => Enable/disable VMs stats // V => Enable/disable VMs stats
hotkeys('shift+V', () => { hotkeys("shift+V", () => {
this.store.args.disable_vms = !this.store.args.disable_vms; this.store.args.disable_vms = !this.store.args.disable_vms;
}); });
// 'W' > Enable/Disable Wifi plugin // 'W' > Enable/Disable Wifi plugin
hotkeys('shift+W', () => { hotkeys("shift+W", () => {
this.store.args.disable_wifi = !this.store.args.disable_wifi; this.store.args.disable_wifi = !this.store.args.disable_wifi;
}); });
// 0 => Enable/disable IRIX mode (see issue #3158) // 0 => Enable/disable IRIX mode (see issue #3158)
hotkeys('0', () => { hotkeys("0", () => {
this.store.args.disable_irix = !this.store.args.disable_irix; this.store.args.disable_irix = !this.store.args.disable_irix;
}); });
} },
} },
}; };
</script> </script>

View File

@ -71,17 +71,17 @@ export default {
}, },
mounted() { mounted() {
const GLANCES = window.__GLANCES__ || {}; const GLANCES = window.__GLANCES__ || {};
const refreshTime = isFinite(GLANCES['refresh-time']) const refreshTime = isFinite(GLANCES["refresh-time"])
? parseInt(GLANCES['refresh-time'], 10) ? parseInt(GLANCES["refresh-time"], 10)
: undefined; : undefined;
this.interval = setInterval(this.updateServersList, refreshTime * 1000) this.interval = setInterval(this.updateServersList, refreshTime * 1000);
}, },
unmounted() { unmounted() {
clearInterval(this.interval) clearInterval(this.interval);
}, },
methods: { methods: {
updateServersList() { updateServersList() {
fetch('api/4/serverslist', { method: 'GET' }) fetch("api/4/serverslist", { method: "GET" })
.then((response) => response.json()) .then((response) => response.json())
.then((response) => (this.servers = response)); .then((response) => (this.servers = response));
}, },
@ -92,18 +92,23 @@ export default {
return value; return value;
}, },
goToGlances(server) { goToGlances(server) {
if (server.protocol === 'rpc') { 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)) 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 { } else {
window.location.href = server.uri; window.location.href = server.uri;
} }
}, },
getDecoration(server, column) { getDecoration(server, column) {
if (server[column + '_decoration'] === undefined) { if (server[column + "_decoration"] === undefined) {
return; return;
} }
return server[column + '_decoration'].replace('_LOG', '').toLowerCase(); return server[column + "_decoration"].replace("_LOG", "").toLowerCase();
} },
} },
}; };
</script> </script>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -177,20 +177,20 @@
</template> </template>
<script> <script>
import { orderBy } from 'lodash'; import { orderBy } from "lodash";
import { GlancesHelper } from '../services.js'; import { GlancesHelper } from "../services.js";
import { store } from '../store.js'; import { store } from "../store.js";
export default { export default {
props: { props: {
data: { data: {
type: Object type: Object,
} },
}, },
data() { data() {
return { return {
store, store,
sorter: undefined sorter: undefined,
}; };
}, },
computed: { computed: {
@ -201,10 +201,10 @@ export default {
return this.args.sort_processes_key; return this.args.sort_processes_key;
}, },
stats() { stats() {
return this.data.stats['containers']; return this.data.stats["containers"];
}, },
views() { views() {
return this.data.views['containers']; return this.data.views["containers"];
}, },
containers() { containers() {
const { sorter } = this; const { sorter } = this;
@ -239,17 +239,17 @@ export default {
command: containerData.command, command: containerData.command,
image: containerData.image, image: containerData.image,
engine: containerData.engine, engine: containerData.engine,
pod_id: containerData.pod_id pod_id: containerData.pod_id,
}; };
}); });
return orderBy( return orderBy(
containers, containers,
[sorter.column].map((col) => { [sorter.column].map((col) => {
const sorter = (item) => const sorter = (item) =>
item[col === 'memory_percent' ? 'memory_usage' : col] ?? -Infinity; item[col === "memory_percent" ? "memory_usage" : col] ?? -Infinity;
return sorter; return sorter;
}, []), }, []),
[sorter.isReverseColumn(sorter.column) ? 'desc' : 'asc'] [sorter.isReverseColumn(sorter.column) ? "desc" : "asc"],
); );
}, },
showEngine() { showEngine() {
@ -257,42 +257,44 @@ export default {
}, },
showPod() { showPod() {
return this.views.show_pod_name; return this.views.show_pod_name;
} },
}, },
watch: { watch: {
sortProcessesKey: { sortProcessesKey: {
immediate: true, immediate: true,
handler(sortProcessesKey) { handler(sortProcessesKey) {
const sortable = ['cpu_percent', 'memory_percent', 'name']; const sortable = ["cpu_percent", "memory_percent", "name"];
function isReverseColumn(column) { function isReverseColumn(column) {
return !['name'].includes(column); return !["name"].includes(column);
} }
function getColumnLabel(value) { function getColumnLabel(value) {
const labels = { const labels = {
io_counters: 'disk IO', io_counters: "disk IO",
cpu_percent: 'CPU consumption', cpu_percent: "CPU consumption",
memory_usage: 'memory consumption', memory_usage: "memory consumption",
cpu_times: 'uptime', cpu_times: "uptime",
name: 'container name', name: "container name",
None: 'None' None: "None",
}; };
return labels[value] || value; return labels[value] || value;
} }
if (!sortProcessesKey || sortable.includes(sortProcessesKey)) { if (!sortProcessesKey || sortable.includes(sortProcessesKey)) {
this.sorter = { this.sorter = {
column: this.args.sort_processes_key || 'cpu_percent', column: this.args.sort_processes_key || "cpu_percent",
auto: !this.args.sort_processes_key, auto: !this.args.sort_processes_key,
isReverseColumn, isReverseColumn,
getColumnLabel getColumnLabel,
}; };
} }
} },
} },
}, },
methods: { methods: {
getDisableStats() { getDisableStats() {
return GlancesHelper.getLimit('containers', 'containers_disable_stats') || []; return (
} GlancesHelper.getLimit("containers", "containers_disable_stats") || []
} );
},
},
}; };
</script> </script>

View File

@ -124,15 +124,15 @@ v-if="!isWindows && !isSunOS && soft_interrupts != undefined" scope="col"
export default { export default {
props: { props: {
data: { data: {
type: Object type: Object,
} },
}, },
computed: { computed: {
stats() { stats() {
return this.data.stats['cpu']; return this.data.stats["cpu"];
}, },
view() { view() {
return this.data.views['cpu']; return this.data.views["cpu"];
}, },
isLinux() { isLinux() {
return this.data.isLinux; return this.data.isLinux;
@ -181,7 +181,9 @@ export default {
}, },
interrupts() { interrupts() {
const { stats } = this; const { stats } = this;
return stats.interrupts ? Math.floor(stats.interrupts / stats.time_since_update) : null; return stats.interrupts
? Math.floor(stats.interrupts / stats.time_since_update)
: null;
}, },
soft_interrupts() { soft_interrupts() {
const { stats } = this; const { stats } = this;
@ -191,8 +193,10 @@ export default {
}, },
syscalls() { syscalls() {
const { stats } = this; const { stats } = this;
return stats.syscalls ? Math.floor(stats.syscalls / stats.time_since_update) : null; return stats.syscalls
} ? Math.floor(stats.syscalls / stats.time_since_update)
: null;
},
}, },
methods: { methods: {
getDecoration(value) { getDecoration(value) {
@ -200,7 +204,7 @@ export default {
return; return;
} }
return this.view[value].decoration.toLowerCase(); return this.view[value].decoration.toLowerCase();
} },
} },
}; };
</script> </script>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,12 +12,12 @@
export default { export default {
props: { props: {
data: { data: {
type: Object type: Object,
} },
}, },
computed: { computed: {
ipStats() { ipStats() {
return this.data.stats['ip']; return this.data.stats["ip"];
}, },
address() { address() {
return this.ipStats.address; return this.ipStats.address;
@ -33,7 +33,7 @@ export default {
}, },
publicInfo() { publicInfo() {
return this.ipStats.public_info_human; return this.ipStats.public_info_human;
} },
} },
}; };
</script> </script>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,9 @@
import { min } from 'lodash'; import { min } from "lodash";
import sanitizeHtml from 'sanitize-html'; import sanitizeHtml from "sanitize-html";
export function bits(bits, low_precision) { export function bits(bits, low_precision) {
bits = Math.round(bits) * 8; bits = Math.round(bits) * 8;
return bytes(bits, low_precision) + 'b'; return bytes(bits, low_precision) + "b";
} }
export function bytes(bytes, low_precision) { export function bytes(bytes, low_precision) {
@ -12,7 +12,7 @@ export function bytes(bytes, low_precision) {
return bytes; return bytes;
} }
const symbols = ['Y', 'Z', 'E', 'P', 'T', 'G', 'M', 'K']; const symbols = ["Y", "Z", "E", "P", "T", "G", "M", "K"];
const prefix = { const prefix = {
Y: 1208925819614629174706176, Y: 1208925819614629174706176,
Z: 1180591620717411303424, Z: 1180591620717411303424,
@ -21,7 +21,7 @@ export function bytes(bytes, low_precision) {
T: 1099511627776, T: 1099511627776,
G: 1073741824, G: 1073741824,
M: 1048576, M: 1048576,
K: 1024 K: 1024,
}; };
for (var i = 0; i < symbols.length; i++) { for (var i = 0; i < symbols.length; i++) {
@ -38,12 +38,12 @@ export function bytes(bytes, low_precision) {
} }
if (low_precision) { if (low_precision) {
if (symbol == 'MK') { if (symbol == "MK") {
decimal_precision = 0; decimal_precision = 0;
} else { } else {
decimal_precision = min([1, decimal_precision]); decimal_precision = min([1, decimal_precision]);
} }
} else if (symbol == 'K') { } else if (symbol == "K") {
decimal_precision = 0; decimal_precision = 0;
} }
@ -55,20 +55,20 @@ export function bytes(bytes, low_precision) {
} }
export function exclamation(input) { export function exclamation(input) {
if (input === undefined || input === '') { if (input === undefined || input === "") {
return '?'; return "?";
} }
return input; return input;
} }
export function leftPad(value, length, chars) { export function leftPad(value, length, chars) {
length = length || 0; length = length || 0;
chars = chars || ' '; chars = chars || " ";
return String(value).padStart(length, chars); return String(value).padStart(length, chars);
} }
export function limitTo(value, limit) { export function limitTo(value, limit) {
if (typeof value.slice !== 'function') { if (typeof value.slice !== "function") {
value = String(value); value = String(value);
} }
return value.slice(0, limit); return value.slice(0, limit);
@ -78,9 +78,9 @@ export function minSize(input, max, begin = true) {
max = max || 8; max = max || 8;
if (input.length > max) { if (input.length > max) {
if (begin) { if (begin) {
return input.substring(0, max - 1) + '_'; return input.substring(0, max - 1) + "_";
} else { } else {
return '_' + input.substring(input.length - max + 1); return "_" + input.substring(input.length - max + 1);
} }
} }
return input; return input;
@ -88,30 +88,30 @@ export function minSize(input, max, begin = true) {
export function nl2br(input) { export function nl2br(input) {
function escapeHTML(html) { function escapeHTML(html) {
var div = document.createElement('div'); var div = document.createElement("div");
div.innerText = html; div.innerText = html;
return div.innerHTML; return div.innerHTML;
} }
if (typeof input === 'undefined') { if (typeof input === "undefined") {
return input; return input;
} }
var sanitizedInput = escapeHTML(input); var sanitizedInput = escapeHTML(input);
var html = sanitizedInput.replace(/\n/g, '<br>'); var html = sanitizedInput.replace(/\n/g, "<br>");
return sanitizeHtml(html); return sanitizeHtml(html);
} }
export function number(value, options) { export function number(value, options) {
// If value is undefined or not a number then return '-' // If value is undefined or not a number then return '-'
if ((typeof value === 'undefined') || isNaN(value)) { if (typeof value === "undefined" || isNaN(value)) {
return '-'; return "-";
} }
// Else // Else
return new Intl.NumberFormat( return new Intl.NumberFormat(
"en-US", "en-US",
typeof options === 'number' ? { maximumFractionDigits: options } : options typeof options === "number" ? { maximumFractionDigits: options } : options,
).format(value); ).format(value);
} }
@ -126,16 +126,19 @@ export function timemillis(array) {
export function timedelta(value) { export function timedelta(value) {
var sum = timemillis(value); var sum = timemillis(value);
var d = new Date(sum); var d = new Date(sum);
var doy = Math.floor((d - new Date(d.getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24); var doy = Math.floor(
(d - new Date(d.getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24,
);
return { return {
hours: d.getUTCHours() + (doy - 1) * 24, hours: d.getUTCHours() + (doy - 1) * 24,
minutes: d.getUTCMinutes(), minutes: d.getUTCMinutes(),
seconds: d.getUTCSeconds(), seconds: d.getUTCSeconds(),
milliseconds: parseInt('' + d.getUTCMilliseconds() / 10) milliseconds: parseInt("" + d.getUTCMilliseconds() / 10),
}; };
} }
export function dictToString(dict) { 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,21 +1,29 @@
import { store } from './store.js'; import Favico from "favico.js";
import Favico from 'favico.js'; import { store } from "./store.js";
// prettier-ignore // 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 // 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 // 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 // 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 // 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 { class GlancesHelperService {
limits = {}; limits = {};
limitSuffix = ['critical', 'careful', 'warning']; limitSuffix = ["critical", "careful", "warning"];
setLimits(limits) { setLimits(limits) {
this.limits = limits; this.limits = limits;
@ -24,10 +32,10 @@ class GlancesHelperService {
getLimit(pluginName, limitName) { getLimit(pluginName, limitName) {
if (this.limits[pluginName] != undefined) { if (this.limits[pluginName] != undefined) {
if (this.limits[pluginName][limitName] != undefined) { if (this.limits[pluginName][limitName] != undefined) {
return this.limits[pluginName][limitName] return this.limits[pluginName][limitName];
} }
} }
return null return null;
} }
getAlert(pluginName, limitNamePrefix, current, maximum, log) { getAlert(pluginName, limitNamePrefix, current, maximum, log) {
@ -35,7 +43,7 @@ class GlancesHelperService {
maximum = maximum || 100; maximum = maximum || 100;
log = log || false; log = log || false;
var log_str = log ? '_log' : ''; var log_str = log ? "_log" : "";
var value = (current * 100) / maximum; var value = (current * 100) / maximum;
if (this.limits[pluginName] != undefined) { if (this.limits[pluginName] != undefined) {
@ -43,14 +51,14 @@ class GlancesHelperService {
var limitName = limitNamePrefix + this.limitSuffix[i]; var limitName = limitNamePrefix + this.limitSuffix[i];
var limit = this.limits[pluginName][limitName]; var limit = this.limits[pluginName][limitName];
if (value >= limit) { if (value >= limit) {
var pos = limitName.lastIndexOf('_'); var pos = limitName.lastIndexOf("_");
var className = limitName.substring(pos + 1); var className = limitName.substring(pos + 1);
return className + log_str; return className + log_str;
} }
} }
} }
return 'ok' + log_str; return "ok" + log_str;
} }
getAlertLog(pluginName, limitNamePrefix, current, maximum) { getAlertLog(pluginName, limitNamePrefix, current, maximum) {
@ -64,27 +72,27 @@ class GlancesStatsService {
data = undefined; data = undefined;
init(REFRESH_TIME = 60) { init(REFRESH_TIME = 60) {
let timeout = undefined; let timeout;
const fetchData = () => { const fetchData = () => {
store.status = 'PENDING'; store.status = "PENDING";
return Promise.all([fetchAll(), fetchAllViews()]) return Promise.all([fetchAll(), fetchAllViews()])
.then((response) => { .then((response) => {
const data = { const data = {
stats: response[0], stats: response[0],
views: response[1], views: response[1],
isBsd: response[0].system?.os_name === 'FreeBSD', isBsd: response[0].system?.os_name === "FreeBSD",
isLinux: response[0].system?.os_name === 'Linux', isLinux: response[0].system?.os_name === "Linux",
isSunOS: response[0].system?.os_name === 'SunOS', isSunOS: response[0].system?.os_name === "SunOS",
isMac: response[0].system?.os_name === 'Darwin', isMac: response[0].system?.os_name === "Darwin",
isWindows: response[0].system?.os_name === 'Windows' isWindows: response[0].system?.os_name === "Windows",
}; };
this.data = data; this.data = data;
store.data = data; store.data = data;
store.status = 'SUCCESS'; store.status = "SUCCESS";
}) })
.catch((error) => { .catch((error) => {
console.log(error); console.log(error);
store.status = 'FAILURE'; store.status = "FAILURE";
}) })
.then(() => { .then(() => {
if (timeout) { if (timeout) {
@ -118,7 +126,7 @@ export const GlancesStats = new GlancesStatsService();
class GlancesFavicoService { class GlancesFavicoService {
constructor() { constructor() {
this.favico = new Favico({ this.favico = new Favico({
animation: 'none' animation: "none",
}); });
} }
badge(nb) { badge(nb) {

View File

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

View File

@ -1,13 +1,5 @@
{ {
"topMenu": [ "topMenu": ["quicklook", "cpu", "percpu", "gpu", "mem", "memswap", "load"],
"quicklook",
"cpu",
"percpu",
"gpu",
"mem",
"memswap",
"load"
],
"leftMenu": [ "leftMenu": [
"network", "network",
"ports", "ports",

View File

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

View File

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

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

@ -1,3 +1,5 @@
#!/bin/sh
docker run --rm \ docker run --rm \
--name homepage \ --name homepage \
-p 3000:3000 \ -p 3000:3000 \

View File

@ -1,3 +1,5 @@
#!/bin/sh
docker run -d \ docker run -d \
--name homeassistant \ --name homeassistant \
--privileged \ --privileged \

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 ' find ./glances/ -type f -name "*.py" -exec sh -c '
duplicate_found=0 duplicate_found=0
for file; do for file; do

View File

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

View File

@ -18,7 +18,7 @@ sleep 5
# Create the token # Create the token
echo "Creating InfluxDB token..." echo "Creating InfluxDB token..."
TOKEN_RETURN=$(docker exec influxdb-v3-for-glances influxdb3 create token --admin) 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" echo "Token: $TOKEN"
# Create a new configuration for the test # Create a new configuration for the test

View File

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