2018-12-27 12:10:26 +03:00
|
|
|
PORT?=8008
|
2021-06-12 10:42:02 +03:00
|
|
|
LASTTAG = $(shell git describe --tags --abbrev=0)
|
2018-12-27 12:10:26 +03:00
|
|
|
|
2022-07-06 00:34:58 +03:00
|
|
|
# if the command is only `make`, the default tasks will be the printing of the help.
|
|
|
|
.DEFAULT_GOAL := help
|
|
|
|
|
|
|
|
.PHONY: help
|
|
|
|
help: ## List all make commands available
|
|
|
|
@grep -E '^[\.a-zA-Z_%-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk -F ":" '{print $1}' | grep -v % | sed 's/\\//g' | sort | awk 'BEGIN {FS = ":[^:]*?##"}; {printf "\033[1;34mmake %-50s\033[0m %s\n", $$1, $$2}'
|
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
# ===================================================================
|
|
|
|
# Virtualenv
|
|
|
|
# ===================================================================
|
2018-12-27 12:10:26 +03:00
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
venv-python: venv-full-python venv-min-python venv-dev-python ## Install all Python 3 venv
|
2018-12-27 12:10:26 +03:00
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
venv: venv-full venv-min venv-dev ## Install all Python 3 dependencies
|
2018-12-27 12:10:26 +03:00
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
venv-upgrade: venv-full-upgrade venv-min-upgrade venv-dev-upgrade ## Upgrade all Python 3 dependencies
|
2021-04-11 11:39:30 +03:00
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
# For full installation (with optional dependencies)
|
|
|
|
|
|
|
|
venv-full-python: ## Install Python 3 venv
|
|
|
|
virtualenv -p /usr/bin/python3 venv
|
|
|
|
|
|
|
|
venv-full: venv-python ## Install Python 3 run-time dependencies
|
2021-05-23 10:04:41 +03:00
|
|
|
./venv/bin/pip install -r requirements.txt
|
|
|
|
./venv/bin/pip install -r optional-requirements.txt
|
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
venv-full-upgrade: ## Upgrade Python 3 run-time dependencies
|
|
|
|
./venv/bin/pip install --upgrade pip
|
2021-05-23 10:04:41 +03:00
|
|
|
./venv/bin/pip install --upgrade -r requirements.txt
|
|
|
|
./venv/bin/pip install --upgrade -r optional-requirements.txt
|
|
|
|
|
2023-05-17 12:35:46 +03:00
|
|
|
# For minimal installation (without optional dependencies)
|
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
venv-min-python: ## Install Python 3 venv minimal
|
2023-05-17 12:35:46 +03:00
|
|
|
virtualenv -p /usr/bin/python3 venv-min
|
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
venv-min: venv-min-python ## Install Python 3 minimal run-time dependencies
|
|
|
|
./venv-min/bin/pip install -r requirements.txt
|
2023-05-17 12:35:46 +03:00
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
venv-min-upgrade: ## Upgrade Python 3 minimal run-time dependencies
|
|
|
|
./venv-min/bin/pip install --upgrade pip
|
|
|
|
./venv-min/bin/pip install --upgrade -r requirements.txt
|
|
|
|
|
|
|
|
# For development
|
|
|
|
|
|
|
|
venv-dev-python: ## Install Python 3 venv
|
|
|
|
virtualenv -p /usr/bin/python3 venv-dev
|
|
|
|
|
|
|
|
venv-dev: venv-python ## Install Python 3 dev dependencies
|
|
|
|
./venv-dev/bin/pip install -r dev-requirements.txt
|
|
|
|
./venv-dev/bin/pip install -r doc-requirements.txt
|
|
|
|
|
|
|
|
venv-dev-upgrade: ## Upgrade Python 3 dev dependencies
|
|
|
|
./venv-dev/bin/pip install --upgrade pip
|
|
|
|
./venv-dev/bin/pip install --upgrade -r dev-requirements.txt
|
|
|
|
./venv-dev/bin/pip install --upgrade -r doc-requirements.txt
|
2023-05-17 12:35:46 +03:00
|
|
|
|
2022-08-20 10:39:49 +03:00
|
|
|
# ===================================================================
|
|
|
|
# Tests
|
|
|
|
# ===================================================================
|
|
|
|
|
2022-09-09 11:20:38 +03:00
|
|
|
test: ## Run unit tests
|
|
|
|
./venv/bin/python ./unitest.py
|
|
|
|
./venv/bin/python ./unitest-restful.py
|
|
|
|
./venv/bin/python ./unitest-xmlrpc.py
|
|
|
|
./venv/bin/python -m black ./glances --check --exclude outputs/static
|
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
test-with-upgrade: venv-upgrade venv-dev-upgrade ## Upgrade deps and run unit tests
|
2021-06-12 10:42:02 +03:00
|
|
|
./venv/bin/python ./unitest.py
|
|
|
|
./venv/bin/python ./unitest-restful.py
|
|
|
|
./venv/bin/python ./unitest-xmlrpc.py
|
2022-03-20 11:13:02 +03:00
|
|
|
./venv/bin/python -m black ./glances --check --exclude outputs/static
|
2023-05-17 16:42:39 +03:00
|
|
|
|
|
|
|
test-min: ## Run unit tests in minimal environment
|
|
|
|
./venv-min/bin/python ./unitest.py
|
|
|
|
|
|
|
|
test-min-with-upgrade: venv-min-upgrade ## Upgrade deps and run unit tests in minimal environment
|
|
|
|
./venv-min/bin/python ./unitest.py
|
2021-11-29 19:00:30 +03:00
|
|
|
|
2023-11-26 12:02:30 +03:00
|
|
|
test-restful-api: ## Run unit tests of the RESTful API
|
2023-12-02 18:41:52 +03:00
|
|
|
./venv/bin/python ./unitest-restful.py
|
2023-11-26 12:02:30 +03:00
|
|
|
|
2022-08-20 10:39:49 +03:00
|
|
|
# ===================================================================
|
2023-12-09 13:07:33 +03:00
|
|
|
# Linters, profilers and cyber security
|
2022-08-20 10:39:49 +03:00
|
|
|
# ===================================================================
|
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
format: ## Format the code
|
|
|
|
@git ls-files 'glances/*.py' | xargs ./venv-dev/bin/python -m autopep8 --in-place --jobs 0 --global-config=.flake8
|
|
|
|
@git ls-files 'glances/*.py' | xargs ./venv-dev/bin/python -m autoflake --in-place --remove-all-unused-imports --remove-unused-variables --remove-duplicate-keys --exclude="compat.py,globals.py"
|
|
|
|
./venv-dev/bin/python -m black ./glances --exclude outputs/static
|
2021-05-29 19:48:27 +03:00
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
flake8: ## Run flake8 linter.
|
|
|
|
@git ls-files 'glances/ *.py' | xargs ./venv-dev/bin/python -m flake8 --config=.flake8
|
2022-08-20 10:39:49 +03:00
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
ruff: ## Run Ruff (fastest) linter.
|
|
|
|
./venv-dev/bin/python -m ruff check . --config=./pyproject.toml
|
2023-05-01 11:12:09 +03:00
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
codespell: ## Run codespell to fix common misspellings in text files
|
|
|
|
./venv-dev/bin/codespell -S .git,./docs/_build,./Glances.egg-info,./venv*,./glances/outputs,*.svg -L hart,bu,te,statics
|
2022-10-16 11:43:11 +03:00
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
semgrep: ## Run semgrep to find bugs and enforce code standards
|
2023-12-16 17:00:04 +03:00
|
|
|
./venv-dev/bin/semgrep scan --config=auto
|
2023-02-04 18:08:22 +03:00
|
|
|
|
2022-08-20 10:39:49 +03:00
|
|
|
profiling: ## How to start the profiling of the Glances software
|
2024-03-09 18:50:26 +03:00
|
|
|
@echo "Start a Glances instance and get its PID"
|
|
|
|
@echo "Run: sudo ./venv-dev/bin/py-spy record -o ./docs/_static/glances-flame.svg -d 60 -s --pid <GLANCES PID>"
|
|
|
|
@echo "Open the SVG file (./docs/_static/glances-flame.svg) with a Web browser"
|
2022-08-20 10:39:49 +03:00
|
|
|
|
|
|
|
trace-malloc: ## Trace the malloc() calls
|
|
|
|
@echo "Malloc test is running, please wait ~30 secondes..."
|
|
|
|
./venv/bin/python -m glances -C ./conf/glances.conf --trace-malloc --stop-after 15 --quiet
|
|
|
|
|
|
|
|
memory-leak: ## Profile memory leaks
|
|
|
|
./venv/bin/python -m glances -C ./conf/glances.conf --memory-leak
|
|
|
|
|
2022-11-12 19:15:44 +03:00
|
|
|
memory-profiling: ## Profile memory usage
|
|
|
|
@echo "It's a very long test (~4 hours)..."
|
|
|
|
rm -f mprofile_*.dat
|
|
|
|
@echo "1/2 - Start memory profiling with the history option enable"
|
2023-05-17 16:42:39 +03:00
|
|
|
./venv-dev/bin/mprof run -T 1 -C run.py -C ./conf/glances.conf --stop-after 2400 --quiet
|
|
|
|
./venv-dev/bin/mprof plot --output ./docs/_static/glances-memory-profiling-with-history.png
|
2022-11-12 19:15:44 +03:00
|
|
|
rm -f mprofile_*.dat
|
|
|
|
@echo "2/2 - Start memory profiling with the history option disable"
|
2023-05-17 16:42:39 +03:00
|
|
|
./venv-dev/bin/mprof run -T 1 -C run.py -C ./conf/glances.conf --disable-history --stop-after 2400 --quiet
|
|
|
|
./venv-dev/bin/mprof plot --output ./docs/_static/glances-memory-profiling-without-history.png
|
2022-11-12 19:15:44 +03:00
|
|
|
rm -f mprofile_*.dat
|
|
|
|
|
2023-12-09 13:07:33 +03:00
|
|
|
# Trivy installation: https://aquasecurity.github.io/trivy/latest/getting-started/installation/
|
|
|
|
trivy: ## Run Trivy to find vulnerabilities in container images
|
|
|
|
trivy fs .
|
|
|
|
|
2022-08-20 10:39:49 +03:00
|
|
|
# ===================================================================
|
|
|
|
# Docs
|
|
|
|
# ===================================================================
|
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
docs: ## Create the documentation
|
2021-07-17 10:31:07 +03:00
|
|
|
./venv/bin/python -m glances -C ./conf/glances.conf --api-doc > ./docs/api.rst
|
|
|
|
cd docs && ./build.sh && cd ..
|
2021-05-29 19:48:27 +03:00
|
|
|
|
2022-07-09 10:03:39 +03:00
|
|
|
docs-server: docs ## Start a Web server to serve the documentation
|
2021-05-29 19:48:27 +03:00
|
|
|
(sleep 2 && sensible-browser "http://localhost:$(PORT)") &
|
2021-11-11 12:46:56 +03:00
|
|
|
cd docs/_build/html/ && ../../../venv/bin/python -m http.server $(PORT)
|
2021-05-29 19:48:27 +03:00
|
|
|
|
2022-08-20 10:39:49 +03:00
|
|
|
release-note: ## Generate release note
|
|
|
|
git --no-pager log $(LASTTAG)..HEAD --first-parent --pretty=format:"* %s"
|
|
|
|
@echo "\n"
|
|
|
|
git --no-pager shortlog -s -n $(LASTTAG)..HEAD
|
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
install: ## Open a Web Browser to the installation procedure
|
|
|
|
sensible-browser "https://github.com/nicolargo/glances#installation"
|
|
|
|
|
2022-08-20 10:39:49 +03:00
|
|
|
# ===================================================================
|
|
|
|
# WebUI
|
2023-05-17 16:42:39 +03:00
|
|
|
# Follow ./glances/outputs/static/README.md for more information
|
2022-08-20 10:39:49 +03:00
|
|
|
# ===================================================================
|
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
webui: ## Build the Web UI
|
2021-11-11 12:46:29 +03:00
|
|
|
cd glances/outputs/static/ && npm ci && npm run build
|
2021-05-29 19:48:27 +03:00
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
webui-audit: ## Audit the Web UI
|
2022-07-29 14:17:03 +03:00
|
|
|
cd glances/outputs/static/ && npm audit
|
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
webui-audit-fix: ## Fix audit the Web UI
|
2022-10-22 10:46:11 +03:00
|
|
|
cd glances/outputs/static/ && npm audit fix && npm ci && npm run build
|
|
|
|
|
2022-08-20 10:39:49 +03:00
|
|
|
# ===================================================================
|
|
|
|
# Packaging
|
|
|
|
# ===================================================================
|
|
|
|
|
|
|
|
flatpak: venv-dev-upgrade ## Generate FlatPack JSON file
|
|
|
|
git clone https://github.com/flatpak/flatpak-builder-tools.git
|
|
|
|
./venv/bin/python ./flatpak-builder-tools/pip/flatpak-pip-generator glances
|
|
|
|
rm -rf ./flatpak-builder-tools
|
|
|
|
@echo "Now follow: https://github.com/flathub/flathub/wiki/App-Submission"
|
|
|
|
|
2024-02-03 11:59:31 +03:00
|
|
|
# Snap package is automaticaly build on the Snapcraft.io platform
|
|
|
|
# https://snapcraft.io/glances
|
|
|
|
# But you can try an offline build with the following command
|
|
|
|
snapcraft:
|
|
|
|
snapcraft
|
|
|
|
|
2022-09-15 12:02:11 +03:00
|
|
|
# ===================================================================
|
|
|
|
# Docker
|
|
|
|
# ===================================================================
|
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
docker: docker-alpine docker-ubuntu ## Generate local docker images
|
2022-10-29 11:55:59 +03:00
|
|
|
|
2024-04-27 11:04:00 +03:00
|
|
|
docker-alpine: docker-alpine-full docker-alpine-minimal docker-alpine-dev ## Generate local docker images (Alpine)
|
|
|
|
|
|
|
|
docker-alpine-full: ## Generate local docker image (Alpine full)
|
2022-09-15 12:02:11 +03:00
|
|
|
docker build --target full -f ./docker-files/alpine.Dockerfile -t glances:local-alpine-full .
|
2024-04-27 11:04:00 +03:00
|
|
|
|
|
|
|
docker-alpine-minimal: ## Generate local docker image (Alpine minimal)
|
2022-09-15 12:02:11 +03:00
|
|
|
docker build --target minimal -f ./docker-files/alpine.Dockerfile -t glances:local-alpine-minimal .
|
2024-04-27 11:04:00 +03:00
|
|
|
|
|
|
|
docker-alpine-dev: ## Generate local docker image (Alpine dev)
|
2022-09-15 12:02:11 +03:00
|
|
|
docker build --target dev -f ./docker-files/alpine.Dockerfile -t glances:local-alpine-dev .
|
|
|
|
|
2024-04-27 11:04:00 +03:00
|
|
|
docker-ubuntu: docker-ubuntu-full docker-ubuntu-minimal docker-ubuntu-dev ## Generate local docker images (Ubuntu)
|
|
|
|
|
|
|
|
docker-ubuntu-full: ## Generate local docker image (Ubuntu full)
|
2023-01-05 08:19:42 +03:00
|
|
|
docker build --target full -f ./docker-files/ubuntu.Dockerfile -t glances:local-ubuntu-full .
|
2024-04-27 11:04:00 +03:00
|
|
|
|
|
|
|
docker-ubuntu-minimal: ## Generate local docker image (Ubuntu minimal)
|
2023-01-05 08:19:42 +03:00
|
|
|
docker build --target minimal -f ./docker-files/ubuntu.Dockerfile -t glances:local-ubuntu-minimal .
|
2024-04-27 11:04:00 +03:00
|
|
|
|
|
|
|
docker-ubuntu-dev: ## Generate local docker image (Ubuntu dev)
|
2023-01-05 08:19:42 +03:00
|
|
|
docker build --target dev -f ./docker-files/ubuntu.Dockerfile -t glances:local-ubuntu-dev .
|
|
|
|
|
2022-08-20 10:39:49 +03:00
|
|
|
# ===================================================================
|
|
|
|
# Run
|
|
|
|
# ===================================================================
|
|
|
|
|
2022-07-09 10:03:39 +03:00
|
|
|
run: ## Start Glances in console mode (also called standalone)
|
2021-05-23 10:04:41 +03:00
|
|
|
./venv/bin/python -m glances -C ./conf/glances.conf
|
|
|
|
|
2022-07-09 10:03:39 +03:00
|
|
|
run-debug: ## Start Glances in debug console mode (also called standalone)
|
2021-05-23 10:04:41 +03:00
|
|
|
./venv/bin/python -m glances -C ./conf/glances.conf -d
|
|
|
|
|
2022-09-11 19:04:04 +03:00
|
|
|
run-local-conf: ## Start Glances in console mode with the system conf file
|
|
|
|
./venv/bin/python -m glances
|
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
run-min: ## Start minimal Glances in console mode (also called standalone)
|
|
|
|
./venv-min/bin/python -m glances -C ./conf/glances.conf
|
|
|
|
|
|
|
|
run-min-debug: ## Start minimal Glances in debug console mode (also called standalone)
|
|
|
|
./venv-min/bin/python -m glances -C ./conf/glances.conf -d
|
|
|
|
|
|
|
|
run-min-local-conf: ## Start minimal Glances in console mode with the system conf file
|
|
|
|
./venv-min/bin/python -m glances
|
|
|
|
|
2022-09-15 12:02:11 +03:00
|
|
|
run-docker-alpine-minimal: ## Start Glances Alpine Docker minimal in console mode
|
2023-05-14 00:15:40 +03:00
|
|
|
docker run --rm -e TZ="${TZ}" -e GLANCES_OPT="" -v /run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it glances:local-alpine-minimal
|
2022-09-15 12:02:11 +03:00
|
|
|
|
|
|
|
run-docker-alpine-full: ## Start Glances Alpine Docker full in console mode
|
2023-05-14 00:15:40 +03:00
|
|
|
docker run --rm -e TZ="${TZ}" -e GLANCES_OPT="" -v /run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it glances:local-alpine-full
|
2022-09-15 12:02:11 +03:00
|
|
|
|
|
|
|
run-docker-alpine-dev: ## Start Glances Alpine Docker dev in console mode
|
2023-05-14 00:15:40 +03:00
|
|
|
docker run --rm -e TZ="${TZ}" -e GLANCES_OPT="" -v /run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it glances:local-alpine-dev
|
2022-09-15 12:02:11 +03:00
|
|
|
|
2023-01-14 11:15:36 +03:00
|
|
|
run-docker-ubuntu-minimal: ## Start Glances Ubuntu Docker minimal in console mode
|
2023-05-14 00:15:40 +03:00
|
|
|
docker run --rm -e TZ="${TZ}" -e GLANCES_OPT="" -v /run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it glances:local-ubuntu-minimal
|
2023-01-14 11:15:36 +03:00
|
|
|
|
|
|
|
run-docker-ubuntu-full: ## Start Glances Ubuntu Docker full in console mode
|
2023-05-14 00:15:40 +03:00
|
|
|
docker run --rm -e TZ="${TZ}" -e GLANCES_OPT="" -v /run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it glances:local-ubuntu-full
|
2023-01-14 11:15:36 +03:00
|
|
|
|
|
|
|
run-docker-ubuntu-dev: ## Start Glances Ubuntu Docker dev in console mode
|
2023-05-14 00:15:40 +03:00
|
|
|
docker run --rm -e TZ="${TZ}" -e GLANCES_OPT="" -v /run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it glances:local-ubuntu-dev
|
2023-01-14 11:15:36 +03:00
|
|
|
|
2022-07-09 10:03:39 +03:00
|
|
|
run-webserver: ## Start Glances in Web server mode
|
2021-05-23 10:04:41 +03:00
|
|
|
./venv/bin/python -m glances -C ./conf/glances.conf -w
|
|
|
|
|
2024-04-27 18:38:56 +03:00
|
|
|
run-webserver-local-conf: ## Start Glances in Web server mode with the system conf file
|
|
|
|
./venv/bin/python -m glances -w
|
|
|
|
|
2022-07-09 10:03:39 +03:00
|
|
|
run-restapiserver: ## Start Glances in REST API server mode
|
2021-07-16 16:39:24 +03:00
|
|
|
./venv/bin/python -m glances -C ./conf/glances.conf -w --disable-webui
|
|
|
|
|
2022-07-09 10:03:39 +03:00
|
|
|
run-server: ## Start Glances in server mode (RPC)
|
2021-05-23 10:04:41 +03:00
|
|
|
./venv/bin/python -m glances -C ./conf/glances.conf -s
|
|
|
|
|
2022-07-09 10:03:39 +03:00
|
|
|
run-client: ## Start Glances in client mode (RPC)
|
2021-05-23 10:04:41 +03:00
|
|
|
./venv/bin/python -m glances -C ./conf/glances.conf -c localhost
|
|
|
|
|
2022-07-09 10:03:39 +03:00
|
|
|
run-browser: ## Start Glances in browser mode (RPC)
|
2021-06-13 11:49:01 +03:00
|
|
|
./venv/bin/python -m glances -C ./conf/glances.conf --browser
|
|
|
|
|
2023-04-29 11:01:44 +03:00
|
|
|
run-issue: ## Start Glances in issue mode
|
|
|
|
./venv/bin/python -m glances -C ./conf/glances.conf --issue
|
|
|
|
|
2022-07-09 10:03:39 +03:00
|
|
|
show-version: ## Show Glances version number
|
2021-06-13 11:49:01 +03:00
|
|
|
./venv/bin/python -m glances -C ./conf/glances.conf -V
|
|
|
|
|
2023-05-17 16:42:39 +03:00
|
|
|
.PHONY: test docs docs-server venv venv-min venv-dev
|