diff options
author | nicolargo <nicolas@nicolargo.com> | 2022-11-19 16:08:18 +0100 |
---|---|---|
committer | nicolargo <nicolas@nicolargo.com> | 2022-11-19 16:08:18 +0100 |
commit | 70aa46d4a0b6ad8ff6f4aa02eaad1d938ab891e3 (patch) | |
tree | dfdcb8b54cd2247ea7c895049487969b44a1b082 | |
parent | d6818c9c3afeb82c574c7c79dbd23a9a2adbede6 (diff) | |
parent | ea60836cc9bc540202a7d2783d8bd43bd0e06bd2 (diff) |
Solve conflicts
43 files changed, 632 insertions, 761 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5c6cc2ed..2d9d1376 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -96,7 +96,7 @@ jobs: strategy: fail-fast: false matrix: - os: ['debian', 'alpine'] + os: ['alpine'] tag: ${{ fromJson(needs.create_Docker_builds.outputs.tags) }} steps: - name: Checkout @@ -139,7 +139,7 @@ jobs: uses: docker/build-push-action@v3 with: push: ${{ env.PUSH_BRANCH == 'true' }} - tags: "${{ env.DEFAULT_DOCKER_IMAGE }}:${{ matrix.os != 'debian' && format('{0}-', matrix.os) || '' }}${{ matrix.tag.tag }}" + tags: "${{ env.DEFAULT_DOCKER_IMAGE }}:${{ matrix.os != 'alpine' && format('{0}-', matrix.os) || '' }}${{ matrix.tag.tag }}" build-args: | CHANGING_ARG=${{ github.sha }} context: . @@ -74,6 +74,18 @@ trace-malloc: ## Trace the malloc() calls memory-leak: ## Profile memory leaks ./venv/bin/python -m glances -C ./conf/glances.conf --memory-leak +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" + ./venv/bin/mprof run -T 1 -C run.py -C ./conf/glances.conf --stop-after 2400 --quiet + ./venv/bin/mprof plot --output ./docs/_static/glances-memory-profiling-with-history.png + rm -f mprofile_*.dat + @echo "2/2 - Start memory profiling with the history option disable" + ./venv/bin/mprof run -T 1 -C run.py -C ./conf/glances.conf --disable-history --stop-after 2400 --quiet + ./venv/bin/mprof plot --output ./docs/_static/glances-memory-profiling-without-history.png + rm -f mprofile_*.dat + # =================================================================== # Docs # =================================================================== @@ -118,18 +130,13 @@ flatpak: venv-dev-upgrade ## Generate FlatPack JSON file # Docker # =================================================================== -docker: docker-alpine docker-debian +docker: docker-alpine ## Generate local docker images -docker-alpine: +docker-alpine: ## Generate local docker images (Alpine) docker build --target full -f ./docker-files/alpine.Dockerfile -t glances:local-alpine-full . docker build --target minimal -f ./docker-files/alpine.Dockerfile -t glances:local-alpine-minimal . docker build --target dev -f ./docker-files/alpine.Dockerfile -t glances:local-alpine-dev . -docker-debian: - docker build --target full -f ./docker-files/debian.Dockerfile -t glances:local-debian-full . - docker build --target minimal -f ./docker-files/debian.Dockerfile -t glances:local-debian-minimal . - docker build --target dev -f ./docker-files/debian.Dockerfile -t glances:local-debian-dev . - # =================================================================== # Run # =================================================================== @@ -152,15 +159,6 @@ run-docker-alpine-full: ## Start Glances Alpine Docker full in console mode run-docker-alpine-dev: ## Start Glances Alpine Docker dev in console mode docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it glances:local-alpine-dev -run-docker-debian-minimal: ## Start Glances Debian Docker minimal in console mode - docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it glances:local-debian-minimal - -run-docker-debian-full: ## Start Glances Debian Docker full in console mode - docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it glances:local-debian-full - -run-docker-debian-dev: ## Start Glances Debian Docker dev in console mode - docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it glances:local-debian-dev - run-webserver: ## Start Glances in Web server mode ./venv/bin/python -m glances -C ./conf/glances.conf -w @@ -9,6 +9,32 @@ Version 3.3.1 Under development, see milestone https://github.com/nicolargo/glances/milestone/61 =============== +Version 3.3.0.4 +=============== + +Refactor the Docker images factory, from now, only Alpine image wll be provided. + +The following Docker images (nicolargo/glances) are availables: + +- *latest-full* for a full Alpine Glances image (latest release) with all dependencies +- *latest* for a basic Alpine Glances (latest release) version with minimal dependencies (Bottle and Docker) +- *dev* for a basic Alpine Glances image (based on development branch) with all dependencies (Warning: may be instable) + +=============== +Version 3.3.0.2 +=============== + +Bug corrected: + * Password files in same configuration dir in effect #2143 + * Fail to load config file on Python 3.10 #2176 + +=============== +Version 3.3.0.1 +=============== + +Just a version to rebuild the Docker images. + +=============== Version 3.3.0 =============== @@ -57,12 +57,25 @@ Glances is written in Python and uses libraries to grab information from your system. It is based on an open architecture where developers can add new plugins or exports modules. +Project sponsorship +=================== + +You can help me to achieve my goals of improving this open-source project +or just say "thank you" by: + +- sponsor me using one-time or monthly tier Github sponsors_ page +- send me some pieces of bitcoin: 185KN9FCix3svJYp7JQM7hRMfSKyeaJR4X +- buy me a gift on my wishlist_ page + +Any and all contributions are greatly appreciated. + Requirements ============ - ``python>=3.4`` - ``psutil>=5.3.0`` (better with latest version) - ``defusedxml`` (in order to monkey patch xmlrpc) +- ``ujson`` (an optimized alternative to the standard json module) *Note for Python 2 users* @@ -175,25 +188,20 @@ If you want to support other distributions, please contribute to `glancesautoins Docker: the fun way ------------------- -Glances containers are availables. You can use it to monitor your -server and all your other containers! +Glances Docker images are availables. You can use it to monitor your +server and all your containers ! Get the Glances container: .. code-block:: console - docker pull nicolargo/glances:alpine-latest-full + docker pull nicolargo/glances:latest-full The following tags are availables: -- *alpine-latest-full* for a full Alpine Glances image (latest release) with all dependencies -- *latest-full* for a full Debian Glances image (latest release) with all dependencies -- *alpine-latest* for a basic Alpine Glances (latest release) version with minimal dependencies -- *latest* for a basic Debian Glances image (latest release) with minimal dependencies -- *alpine-dev* for a basic Alpine Glances image (development branch) with all dependencies -- *dev* for a basic Debian Glances image (development branch) with all dependencies - -You can also specify a version (example: *alpine-3.2.7-full*). +- *latest-full* for a full Alpine Glances image (latest release) with all dependencies +- *latest* for a basic Alpine Glances (latest release) version with minimal dependencies (Bottle and Docker) +- *dev* for a basic Alpine Glances image (based on development branch) with all dependencies (Warning: may be instable) Run last version of Glances container in *console mode*: @@ -436,15 +444,6 @@ There is also a chat dedicated to the Glances developers: .. image:: https://badges.gitter.im/Join%20Chat.svg :target: https://gitter.im/nicolargo/glances?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge -Donation -======== - -If you like this open-source project, you can become a sponsor. - -See the Github sponsors_ page (one-time or monthly tier available). - -Or send me some bitcoins: 185KN9FCix3svJYp7JQM7hRMfSKyeaJR4X - Author ====== @@ -467,5 +466,6 @@ Glances is distributed under the LGPL version 3 license. See ``COPYING`` for mor .. _wiki: https://github.com/nicolargo/glances/wiki/How-to-contribute-to-Glances-%3F .. _package: https://repology.org/metapackage/glances/packages .. _sponsors: https://github.com/sponsors/nicolargo +.. _wishlist: https://www.amazon.fr/hz/wishlist/ls/BWAAQKWFR3FI?ref_=wl_share .. _issue2021: https://github.com/nicolargo/glances/issues/2021#issuecomment-1197831157 .. _issue2021comment: https://github.com/nicolargo/glances/issues/2021#issuecomment-1197831157
\ No newline at end of file diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..5b2c9628 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,34 @@ +# Security Policy + +## Supported Versions + +Use this section to tell people about which versions of your project are +currently being supported with security updates. + +| Version | Support security updates | +| ------- | ------------------------ | +| 3.x | :white_check_mark: | +| < 3.0 | :x: | + +## Reporting a Vulnerability + +If there are any vulnerabilities in {{cookiecutter.project_name}}, don't hesitate to report them. + + 1. Describe the vulnerability. + + * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) + * Full paths of source file(s) related to the manifestation of the issue + * The location of the affected source code (tag/branch/commit or direct URL) + * Any special configuration required to reproduce the issue + * Step-by-step instructions to reproduce the issue + * Proof-of-concept or exploit code (if possible) + * Impact of the issue, including how an attacker might exploit the issue + + 2. If you have a fix, that is most welcome -- please attach or summarize it in your message! + + 3. We will evaluate the vulnerability and, if necessary, release a fix or mitigating steps to address it. We will contact you to let you know the outcome, and will credit you in the report. + + 4. Please do not disclose the vulnerability publicly until a fix is released! + +Once we have either a) published a fix, or b) declined to address the vulnerability for whatever reason, you are free to publicly disclose it. + diff --git a/conf/glances.conf b/conf/glances.conf index 85326e33..d40a9715 100644 --- a/conf/glances.conf +++ b/conf/glances.conf @@ -10,8 +10,8 @@ refresh=2 # Does Glances should check if a newer version is available on PyPI ? check_update=true # History size (maximum number of values) -# Default is 3600 seconds (1 hour) -history_size=3600 +# Default is 1200 values (~1h with the default refresh rate) +history_size=1200 ############################################################################## # User interface diff --git a/dev-requirements.txt b/dev-requirements.txt index 30fbb37a..b78acaa3 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -6,3 +6,6 @@ flake8 autopep8 autoflake codespell +memory-profiler +matplotlib +setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability
\ No newline at end of file diff --git a/doc-requirements.txt b/doc-requirements.txt index f5288255..f5d4f9f4 100644 --- a/doc-requirements.txt +++ b/doc-requirements.txt @@ -1,3 +1,4 @@ sphinx sphinx_rtd_theme -reuse
\ No newline at end of file +reuse +setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability
\ No newline at end of file diff --git a/docker-compose/Dockerfile b/docker-compose/Dockerfile index 9d2426a1..81caa69a 100644 --- a/docker-compose/Dockerfile +++ b/docker-compose/Dockerfile @@ -1,3 +1,3 @@ -FROM nicolargo/glances:alpine-dev +FROM nicolargo/glances:latest as glancesminimal COPY glances.conf /glances/conf/glances.conf CMD python -m glances -C /glances/conf/glances.conf $GLANCES_OPT diff --git a/docker-compose/docker-compose-with-traefik.yml b/docker-compose/docker-compose-with-traefik.yml index 91a1d551..db29890f 100644 --- a/docker-compose/docker-compose-with-traefik.yml +++ b/docker-compose/docker-compose-with-traefik.yml @@ -15,7 +15,7 @@ services: - "traefik.frontend.rule=Host:whoami.docker.localhost" monitoring: - image: nicolargo/glances:alpine-dev + image: nicolargo/glances:dev restart: unless-stopped pid: host privileged: true diff --git a/docker-files/alpine.Dockerfile b/docker-files/alpine.Dockerfile index 90fe159e..23d301e8 100644 --- a/docker-files/alpine.Dockerfile +++ b/docker-files/alpine.Dockerfile @@ -8,7 +8,7 @@ # Ex: Python 3.10 for Alpine 3.16 # Note: ENV is for future running containers. ARG for building your Docker image. -ARG IMAGE_VERSION=3.16 +ARG IMAGE_VERSION=3.17 ARG PYTHON_VERSION=3.10 FROM alpine:${IMAGE_VERSION} as build ARG PYTHON_VERSION @@ -33,12 +33,15 @@ RUN apk add --no-cache \ FROM build as buildRequirements ARG PYTHON_VERSION + COPY requirements.txt . -COPY webui-requirements.txt . RUN pip3 install --no-cache-dir --user -r requirements.txt + # Minimal means no webui, but it break what is done previously (see #2155) # So install the webui requirements... +COPY webui-requirements.txt . RUN pip3 install --no-cache-dir --user -r webui-requirements.txt + # As minimal image we want to monitor others docker containers RUN pip3 install --no-cache-dir --user docker @@ -70,9 +73,8 @@ COPY ./docker-compose/glances.conf /etc/glances.conf # EXPOSE PORT (XMLRPC / WebUI) EXPOSE 61209 61208 -WORKDIR /glances - # Define default command. +WORKDIR /glances CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT ############################################################################## @@ -85,6 +87,8 @@ ARG PYTHON_VERSION RUN apk add --no-cache \ python3 \ + py3-packaging \ + py3-dateutil \ curl \ lm-sensors \ wireless-tools \ @@ -94,10 +98,11 @@ COPY --from=buildRequirements /root/.local/bin /usr/local/bin/ COPY --from=buildRequirements /root/.local/lib/python${PYTHON_VERSION}/site-packages /usr/lib/python${PYTHON_VERSION}/site-packages/ COPY ./docker-compose/glances.conf /etc/glances.conf -# EXPOSE PORT (XMLRPC only because WebUI is not available) -EXPOSE 61209 +# EXPOSE PORT (XMLRPC / WebUI) +EXPOSE 61209 61208 # Define default command. +WORKDIR /glances CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT ############################################################################## @@ -122,7 +127,6 @@ EXPOSE 61209 61208 RUN ln -sf /dev/stdout /tmp/glances-root.log \ && ln -sf /dev/stderr /var/log/error.log -WORKDIR /glances - # Define default command. +WORKDIR /glances CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT diff --git a/docker-files/debian.Dockerfile b/docker-files/debian.Dockerfile deleted file mode 100644 index 9087bcf7..00000000 --- a/docker-files/debian.Dockerfile +++ /dev/null @@ -1,130 +0,0 @@ -# -# Glances Dockerfile (based on Debian) -# -# https://github.com/nicolargo/glances -# - -# WARNING: the version should be set. -# Ex: Python 3.11 for 3.11-slim-buster -# Note: ENV is for future running containers. ARG for building your Docker image. - -ARG PYTHON_IMAGE_VERSION=3.11 -ARG IMAGE_VERSION=${PYTHON_IMAGE_VERSION}-slim-buster -FROM python:${IMAGE_VERSION} as build -ARG PYTHON_VERSION - -# Install package -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - python3-dev \ - curl \ - build-essential \ - lm-sensors \ - wireless-tools \ - smartmontools \ - iputils-ping && \ - apt-get clean && rm -rf /var/lib/apt/lists/* - -############################################################################## -# Install the dependencies beforehand to make them cacheable - -FROM build as buildRequirements -ARG PYTHON_VERSION -COPY requirements.txt . -COPY webui-requirements.txt . -RUN pip3 install --no-cache-dir --user -r requirements.txt -# Minimal means no webui, but it break what is done previously (see #2155) -# So install the webui requirements... -RUN pip3 install --no-cache-dir --user -r webui-requirements.txt -# As minimal image we want to monitor others docker containers -RUN pip3 install --no-cache-dir --user docker - -# Force install otherwise it could be cached without rerun -ARG CHANGING_ARG -RUN pip3 install --no-cache-dir --user glances - -############################################################################## - -FROM build as buildOptionalRequirements -ARG PYTHON_VERSION - -COPY requirements.txt . -COPY optional-requirements.txt . -RUN CASS_DRIVER_NO_CYTHON=1 pip3 install --no-cache-dir --user -r optional-requirements.txt - -############################################################################## -# full image -############################################################################## - -FROM build as full -ARG PYTHON_VERSION -ARG PYTHON_IMAGE_VERSION - -COPY --from=buildRequirements /root/.local/bin /usr/local/bin/ -COPY --from=buildRequirements /root/.local/lib/python${PYTHON_IMAGE_VERSION}/site-packages /usr/local/lib/python${PYTHON_IMAGE_VERSION}/site-packages/ -COPY --from=buildOptionalRequirements /root/.local/lib/python${PYTHON_IMAGE_VERSION}/site-packages /usr/local/lib/python${PYTHON_IMAGE_VERSION}/site-packages/ -COPY ./docker-compose/glances.conf /etc/glances.conf - -# EXPOSE PORT (XMLRPC / WebUI) -EXPOSE 61209 61208 - -WORKDIR /glances - -# Define default command. -CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT - -############################################################################## -# minimal image -############################################################################## - -# Create running images without any building dependency -FROM python:${IMAGE_VERSION} as minimal -ARG PYTHON_VERSION -ARG PYTHON_IMAGE_VERSION - -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - curl \ - lm-sensors \ - wireless-tools \ - smartmontools \ - iputils-ping && \ - apt-get clean && rm -rf /var/lib/apt/lists/* - -COPY --from=buildRequirements /root/.local/bin /usr/local/bin/ -COPY --from=buildRequirements /root/.local/lib/python${PYTHON_IMAGE_VERSION}/site-packages /usr/local/lib/python${PYTHON_IMAGE_VERSION}/site-packages/ -COPY ./docker-compose/glances.conf /etc/glances.conf - -# EXPOSE PORT (XMLRPC) -EXPOSE 61209 - -# Define default command. -CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT - -############################################################################## -# dev image -############################################################################## - -FROM full as dev -ARG PYTHON_VERSION -ARG PYTHON_IMAGE_VERSION - -COPY --from=buildRequirements /root/.local/bin /usr/local/bin/ -COPY --from=buildRequirements /root/.local/lib/python${PYTHON_IMAGE_VERSION}/site-packages /usr/lib/python${PYTHON_IMAGE_VERSION}/site-packages/ -COPY --from=buildOptionalRequirements /root/.local/lib/python${PYTHON_IMAGE_VERSION}/site-packages /usr/lib/python${PYTHON_IMAGE_VERSION}/site-packages/ -COPY ./docker-compose/glances.conf /etc/glances.conf - -# Copy the current Glances source code -COPY . /glances - -# EXPOSE PORT (XMLRPC / WebUI) -EXPOSE 61209 61208 - -# Forward access and error logs to Docker's log collector -RUN ln -sf /dev/stdout /tmp/glances-root.log \ - && ln -sf /dev/stderr /var/log/error.log - -WORKDIR /glances - -# Define default command. -CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT diff --git a/docs/_static/glances-memory-profiling-with-history.png b/docs/_static/glances-memory-profiling-with-history.png Binary files differnew file mode 100644 index 00000000..8d9c8d7b --- /dev/null +++ b/docs/_static/glances-memory-profiling-with-history.png diff --git a/docs/_static/glances-memory-profiling-without-history.png b/docs/_static/glances-memory-profiling-without-history.png Binary files differnew file mode 100644 index 00000000..795b7820 --- /dev/null +++ b/docs/_static/glances-memory-profiling-without-history.png diff --git a/docs/api.rst b/docs/api.rst index 0b92372d..1d844ca3 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -60,6 +60,25 @@ Get the plugins list:: "uptime", "wifi"] +GET alert +--------- + +Get plugin stats:: + + # curl http://localhost:61208/api/3/alert + [[1667486328.0, + -1, + "WARNING", + "MEM", + 70.7784407976031, + 70.7784407976031, + 70.7784407976031, + 70.7784407976031, + 1, + [], + "", + "memory_percent"]] + GET amps -------- @@ -74,7 +93,7 @@ Get plugin stats:: "refresh": 3.0, "regex": True, "result": None, - "timer": 0.8619787693023682}, + "timer": 0.8428387641906738}, {"count": 0, "countmax": 20.0, "countmin": None, @@ -83,7 +102,7 @@ Get plugin stats:: "refresh": 3.0, "regex": True, "result": None, - "timer": 0.8618190288543701}] + "timer": 0.8426706790924072}] Get a specific field:: @@ -101,7 +120,7 @@ Get a specific item when field matchs the given value:: "refresh": 3.0, "regex": True, "result": None, - "timer": 0.8619787693023682}]} + "timer": 0.8428387641906738}]} GET core -------- @@ -131,19 +150,19 @@ Get plugin stats:: "ctx_switches": 0, "guest": 0.0, "guest_nice": 0.0, - "idle": 24.9, + "idle": 47.3, "interrupts": 0, - "iowait": 0.2, + "iowait": 0.0, "irq": 0.0, "nice": 0.0, "soft_interrupts": 0, - "softirq": 0.2, + "softirq": 0.3, "steal": 0.0, "syscalls": 0, - "system": 4.9, + "system": 9.2, "time_since_update": 1, - "total": 74.5, - "user": 69.9} + "total": 40.1, + "user": 43.2} Fields descriptions: @@ -166,7 +185,7 @@ Fields descriptions: Get a specific field:: # curl http://localhost:61208/api/3/cpu/total - {"total": 74.5} + {"total": 40.1} GET diskio ---------- @@ -211,30 +230,17 @@ GET docker Get plugin stats:: # curl http://localhost:61208/api/3/docker - [{"Command": ["/entrypoint.sh", "telegraf"], - "Id": "9230f84acadbb7bc8c087d0827389c9a87bb7c7022a1a299dcf4a5f3a441f1d3", - "Image": ["telegraf:latest"], + [{"Command": ["/portainer"], + "Id": "3abd51c615968482d9ccff5afc629f267f6dda113ed68b75b432615fae3b49fb", + "Image": ["portainer/portainer-ce:2.9.3"], "Status": "running", - "Uptime": "23 hours", + "Uptime": "4 days", "cpu_percent": 0.0, "io_r": None, "io_w": None, "key": "name", - "memory_usage": 30109696, - "name": "telegraf", - "network_rx": None, - "network_tx": None}, - {"Command": ["/run.sh"], - "Id": "09d96704c3e6b6cb21657d990e3c8ae1e44bac779ded141efb8fed899563dd66", - "Image": ["grafana/grafana:latest"], - "Stat |