What a sexy pre-commit config file !

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,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
const fetchAll = () => fetch('api/4/all', { method: 'GET' }).then((response) => response.json());
const fetchAll = () =>
fetch("api/4/all", { method: "GET" }).then((response) => response.json());
// prettier-ignore
const fetchAllViews = () => fetch('api/4/all/views', { method: 'GET' }).then((response) => response.json());
const fetchAllViews = () =>
fetch("api/4/all/views", { method: "GET" }).then((response) =>
response.json(),
);
// prettier-ignore
const fetchAllLimits = () => fetch('api/4/all/limits', { method: 'GET' }).then((response) => response.json());
const fetchAllLimits = () =>
fetch("api/4/all/limits", { method: "GET" }).then((response) =>
response.json(),
);
// prettier-ignore
const fetchArgs = () => fetch('api/4/args', { method: 'GET' }).then((response) => response.json());
const fetchArgs = () =>
fetch("api/4/args", { method: "GET" }).then((response) => response.json());
// prettier-ignore
const fetchConfig = () => fetch('api/4/config', { method: 'GET' }).then((response) => response.json());
const fetchConfig = () =>
fetch("api/4/config", { method: "GET" }).then((response) => response.json());
class GlancesHelperService {
limits = {};
limitSuffix = ['critical', 'careful', 'warning'];
limitSuffix = ["critical", "careful", "warning"];
setLimits(limits) {
this.limits = limits;
@ -24,10 +32,10 @@ class GlancesHelperService {
getLimit(pluginName, limitName) {
if (this.limits[pluginName] != 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) {
@ -35,7 +43,7 @@ class GlancesHelperService {
maximum = maximum || 100;
log = log || false;
var log_str = log ? '_log' : '';
var log_str = log ? "_log" : "";
var value = (current * 100) / maximum;
if (this.limits[pluginName] != undefined) {
@ -43,14 +51,14 @@ class GlancesHelperService {
var limitName = limitNamePrefix + this.limitSuffix[i];
var limit = this.limits[pluginName][limitName];
if (value >= limit) {
var pos = limitName.lastIndexOf('_');
var pos = limitName.lastIndexOf("_");
var className = limitName.substring(pos + 1);
return className + log_str;
}
}
}
return 'ok' + log_str;
return "ok" + log_str;
}
getAlertLog(pluginName, limitNamePrefix, current, maximum) {
@ -64,27 +72,27 @@ class GlancesStatsService {
data = undefined;
init(REFRESH_TIME = 60) {
let timeout = undefined;
let timeout;
const fetchData = () => {
store.status = 'PENDING';
store.status = "PENDING";
return Promise.all([fetchAll(), fetchAllViews()])
.then((response) => {
const data = {
stats: response[0],
views: response[1],
isBsd: response[0].system?.os_name === 'FreeBSD',
isLinux: response[0].system?.os_name === 'Linux',
isSunOS: response[0].system?.os_name === 'SunOS',
isMac: response[0].system?.os_name === 'Darwin',
isWindows: response[0].system?.os_name === 'Windows'
isBsd: response[0].system?.os_name === "FreeBSD",
isLinux: response[0].system?.os_name === "Linux",
isSunOS: response[0].system?.os_name === "SunOS",
isMac: response[0].system?.os_name === "Darwin",
isWindows: response[0].system?.os_name === "Windows",
};
this.data = data;
store.data = data;
store.status = 'SUCCESS';
store.status = "SUCCESS";
})
.catch((error) => {
console.log(error);
store.status = 'FAILURE';
store.status = "FAILURE";
})
.then(() => {
if (timeout) {
@ -118,7 +126,7 @@ export const GlancesStats = new GlancesStatsService();
class GlancesFavicoService {
constructor() {
this.favico = new Favico({
animation: 'none'
animation: "none",
});
}
badge(nb) {

View File

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

View File

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

View File

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

View File

@ -1,8 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
],
"extends": ["config:recommended"],
"prHourlyLimit": 3,
"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 \
--name homepage \
-p 3000:3000 \

View File

@ -1,3 +1,5 @@
#!/bin/sh
docker run -d \
--name homeassistant \
--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 '
duplicate_found=0
for file; do

View File

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

View File

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

View File

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