diff options
50 files changed, 1097 insertions, 864 deletions
@@ -1,20 +1,7 @@ [flake8] - +exclude = .git,__pycache__,docs/,build,dist ignore = - W504 # line break after binary operator - - # --- flake8-bugbear plugin - B007 # Loop control variable 'keyword' not used within the loop body. If this is intended, start the name with an underscore. - B014 # Redundant exception types in `except (IOError, OSError) as err:`. Write `except OSError as err:`, which catches exactly the same exceptions. - B008 # Do not perform function calls in argument defaults. - - # --- flake8-blind-except plugin - B902 # blind except Exception: statement - - # --- flake8-quotes plugin - Q000 # Double quotes found but single quotes preferred - - # --- flake8-quotes naming; disable all except N804 and N805 + W504, B007, B014, B008, B902, Q000, N801, N802, N803, N806, N807, N811, N812, N813, N814, N815, N816, N817, N818 # lines should not exceed 120 characters diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2d9d1376..06c83b9a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -104,7 +104,7 @@ jobs: - name: Retrieve Repository Docker metadata id: docker_meta - uses: crazy-max/ghaction-docker-meta@v4.1.1 + uses: crazy-max/ghaction-docker-meta@v4.3.0 with: images: ${{ env.DEFAULT_DOCKER_IMAGE }} labels: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 77841f0c..219a4731 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10"] + python-version: ["2.7", "3.7", "3.8", "3.9", "3.10", "3.11"] steps: @@ -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,13 +130,18 @@ flatpak: venv-dev-upgrade ## Generate FlatPack JSON file # Docker # =================================================================== -docker: docker-alpine +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-ubuntu: ## Generate local docker images (Ubuntu) + docker build --target full -f ./docker-files/ubuntu.Dockerfile -t glances:local-ubuntu-full . + docker build --target minimal -f ./docker-files/ubuntu.Dockerfile -t glances:local-ubuntu-minimal . + docker build --target dev -f ./docker-files/ubuntu.Dockerfile -t glances:local-ubuntu-dev . + # =================================================================== # Run # =================================================================== @@ -147,6 +164,15 @@ 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-ubuntu-minimal: ## Start Glances Ubuntu 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-ubuntu-minimal + +run-docker-ubuntu-full: ## Start Glances Ubuntu 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-ubuntu-full + +run-docker-ubuntu-dev: ## Start Glances Ubuntu 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-ubuntu-dev + run-webserver: ## Start Glances in Web server mode ./venv/bin/python -m glances -C ./conf/glances.conf -w @@ -6,7 +6,61 @@ Version 3.3.1 =============== - Under development, see milestone https://github.com/nicolargo/glances/milestone/61 +Enhancements: + + * Minor change on the help screen + * Refactor some loop in the processes function + * Replace json by ujson #2201 + +Bug corrected: + + * Unable to see docker related information #2180 + * CSV export dependent on sort order for docker container cpu #2156 + * Error when process list is displayed in Programs mode #2209 + * Console formatting permanently messed up when other text printed #2211 + * API GET uptime returns formatted string, not seconds as the doc says #2158 + * Glances UI is breaking for multiline commands #2189 + +Documentation and CI: + + * Add unitary test for memory profiling + * Update memory profile chart + * Add run-docker-ubuntu-* in Makefile + * The open-web-browser option was missing dashes #2219 + * Correct regexp in glances.conf file example + * What is CW from network #2222 (related to discussion #2221) + * Change Glances repology URL + * Add example for the date format + * Correct Flake8 configuration file + * Drop UT for Python 3.5 and 3.6 (no more available in Ubuntu 22.04) + * Correct unitary test with Python 3.5 + * Update Makefile with comments + * Update Python minimal requirement for py3nvlm + * Update security policy (user can open private issue directly in Github) + * Add a simple run script. Entry point for IDE debuger + +Cyber security update: + + * Security alert on ujson < 5.4 + * Merge pull request #2243 from nicolargo/renovate/nvidia-cuda-12.x + * Merge pull request #2244 from nicolargo/renovate/crazy-max-ghaction-docker-meta-4.x + * Merge pull request #2228 from nicolargo/renovate/zeroconf-0.x + * Merge pull request #2242 from nicolargo/renovate/crazy-max-ghaction-docker-meta-4.x + * Merge pull request #2239 from mfridge/action-command-split + * Merge pull request #2165 from nicolargo/renovate/zeroconf-0.x + * Merge pull request #2199 from nicolargo/renovate/alpine-3.x + * Merge pull request #2202 from chncaption/oscs_fix_cdr0ts8au51t49so8c6g + * Bump loader-utils from 2.0.0 to 2.0.3 in /glances/outputs/static #2187 - Update Web lib + +Contributors for this version: + + * Nicolargo + * renovate[bot] + * chncaption + * fkwong + * *mfridge + +And also a big thanks to @RazCrimson (https://github.com/RazCrimson) for the support to the Glances community ! =============== Version 3.3.0.4 @@ -75,6 +75,7 @@ Requirements - ``python>=2.7`` or ``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) - ``future`` (for Python 2 support) *Note for Python 2.6 users* @@ -469,7 +470,7 @@ Glances is distributed under the LGPL version 3 license. See ``COPYING`` for mor .. _readthedocs: https://glances.readthedocs.io/ .. _forum: https://groups.google.com/forum/?hl=en#!forum/glances-users .. _wiki: https://github.com/nicolargo/glances/wiki/How-to-contribute-to-Glances-%3F -.. _package: https://repology.org/metapackage/glances/packages +.. _package: https://repology.org/project/glances/versions .. _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 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..835b84d9 100644 --- a/conf/glances.conf +++ b/conf/glances.conf @@ -10,8 +10,10 @@ 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 +# Set the way Glances should display the date (default is %Y-%m-%d %H:%M:%S %Z) +#strftime_format="%Y-%m-%d %H:%M:%S %Z" ############################################################################## # User interface @@ -212,7 +214,7 @@ critical=-85 disable=False # Define the list of hidden disks (comma-separated regexp) #hide=sda2,sda5,loop.* -hide=loop.*,/dev/loop* +hide=loop.*,/dev/loop.* # Define the list of disks to be show (comma-separated) #show=sda.* # Alias for sda1 @@ -305,6 +307,7 @@ battery_critical=95 #core 0_fans_speed_alias=CPU Core 0 fan #or #core 0_alias=CPU Core 0 +#core 1_alias=CPU Core 1 [processcount] disable=False 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/glances.conf b/docker-compose/glances.conf index 6f6e4180..0ee06cbd 100644 --- a/docker-compose/glances.conf +++ b/docker-compose/glances.conf @@ -10,8 +10,10 @@ refresh=2 # Does Glances should check if a newer version is available on PyPI ? check_update=false # 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 +# Set the way Glances should display the date (default is %Y-%m-%d %H:%M:%S %Z) +#strftime_format="%Y-%m-%d %H:%M:%S %Z" ############################################################################## # User interface @@ -212,7 +214,7 @@ critical=-85 disable=False # Define the list of hidden disks (comma-separated regexp) #hide=sda2,sda5,loop.* -hide=loop.*,/dev/loop* +hide=loop.*,/dev/loop.* # Define the list of disks to be show (comma-separated) #show=sda.* # Alias for sda1 diff --git a/docker-files/alpine.Dockerfile b/docker-files/alpine.Dockerfile index e7b14a49..c44983b7 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 @@ -89,6 +89,7 @@ RUN apk add --no-cache \ python3 \ py3-packaging \ py3-dateutil \ + py3-requests \ curl \ lm-sensors \ wireless-tools \ diff --git a/docker-files/ubuntu.Dockerfile b/docker-files/ubuntu.Dockerfile new file mode 100644 index 00000000..24817387 --- /dev/null +++ b/docker-files/ubuntu.Dockerfile @@ -0,0 +1,144 @@ +# +# Glances Dockerfile (based on Ubuntu) +# +# https://github.com/nicolargo/glances +# + +# WARNING: the versions should be set. +# Ex: Python 3.10 for Ubuntu 22.04 +# Note: ENV is for future running containers. ARG for building your Docker image. + +ARG IMAGE_VERSION=12.0.0-base-ubuntu22.04 +ARG PYTHON_VERSION=3.10 +ARG PIP_MIRROR=https://mirrors.aliyun.com/pypi/simple/ +FROM nvidia/cuda:${IMAGE_VERSION} as build + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + python3 \ + python3-dev \ + python3-pip \ + python3-wheel \ + musl-dev \ + build-essential \ + libzmq5 \ + curl \ + lm-sensors \ + wireless-tools \ + net-tools \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +############################################################################## +# Install the dependencies beforehand to make them cacheable + +FROM build as buildRequirements +ARG PYTHON_VERSION +ARG PIP_MIRROR + +ARG PIP_MIRROR=https://mirrors.aliyun.com/pypi/simple/ + +COPY requirements.txt . +RUN python${PYTHON_VERSION} -m pip install --no-cache-dir --user -r requirements.txt -i ${PIP_MIRROR} + +# Minimal means no webui, but it break what is done previously (see #2155) +# So install the webui requirements... +COPY webui-requirements.txt . +RUN python${PYTHON_VERSION} -m pip install --no-cache-dir --user -r webui-requirements.txt -i ${PIP_MIRROR} + +# As minimal image we want to monitor others docker containers +RUN python${PYTHON_VERSION} -m pip install --no-cache-dir --user docker -i ${PIP_MIRROR} + +# Force install otherwise it could be cached without rerun +ARG CHANGING_ARG +RUN python${PYTHON_VERSION} -m pip install --no-cache-dir --user glances -i ${PIP_MIRROR} + +############################################################################## + +FROM build as buildOptionalRequirements +ARG PYTHON_VERSION +ARG PIP_MIRROR + +COPY requirements.txt . +COPY optional-requirements.txt . +RUN CASS_DRIVER_NO_CYTHON=1 pip3 install --no-cache-dir --user -r optional-requirements.txt -i ${PIP_MIRROR} + +############################################################################## +# full image +############################################################################## + +FROM build as full +ARG PYTHON_VERSION + +COPY --from=buildRequirements /root/.local/bin /root/.local/bin/ +COPY --from=buildRequirements /root/.local/lib/python${PYTHON_VERSION}/site-packages /root/.local/lib/python${PYTHON_VERSION}/site-packages/ +COPY --from=buildOptionalRequirements /root/.local/lib/python${PYTHON_VERSION}/site-packages /root/.local/lib/python${PYTHON_VERSION}/site-packages/ +COPY ./docker-compose/glances.conf /etc/glances.conf + +# EXPOSE PORT (XMLRPC / WebUI) +EXPOSE 61209 61208 + +# Define default command. +WORKDIR /glances +CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT + +############################################################################## +# minimal image +############################################################################## + +# Create running images without any building dependency +FROM nvidia/cuda:${IMAGE_VERSION} as minimal +ARG PYTHON_VERSION + +ARG DEBIAN_FRONTEND=noninteractive +ENV TZ=Asia/Shanghai + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + python3 \ + python3-packaging \ + python3-dateutil \ + python3-requests \ + curl \ + lm-sensors \ + wireless-tools \ + net-tools \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=buildRequirements /root/.local/bin /root/.local/bin/ +COPY --from=buildRequirements /root/.local/lib/python${PYTHON_VERSION}/site-packages /root/.local/lib/python${PYTHON_VERSION}/site-packages/ +COPY ./docker-compose/glances.conf /etc/glances.conf + +# EXPOSE PORT (XMLRPC / WebUI) +EXPOSE 61209 61208 + +# Define default command. +WORKDIR /glances +CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT + +############################################################################## +# dev image +############################################################################## + +FROM full as dev +ARG PYTHON_VERSION + +COPY --from=buildRequirements /root/.local/bin /root/.local/bin/ +COPY --from=buildRequirements /root/.local/lib/python${PYTHON_VERSION}/site-packages /root/.local/lib/python${PYTHON_VERSION}/site-packages/ +COPY --from=buildOptionalRequirements /root/.local/lib/python${PYTHON_VERSION}/site-packages /root/.local/lib/python${PYTHON_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 + +# Define default command. +WORKDIR /glances +CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT diff --git a/docs/_static/glances-flame.svg b/docs/_static/glances-flame.svg index 72744ff4..c450cb3b 100644 --- a/docs/_static/glances-flame.svg +++ b/docs/_static/glances-flame.svg @@ -1,4 +1,4 @@ -<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg version="1.1" width="1200" height="538" onload="init(evt)" viewBox="0 0 1200 538" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:fg="http://github.com/jonhoo/inferno"><!--Flame graph stack visualization. See https://github.com/brendangregg/FlameGraph for latest version, and http://www.brendangregg.com/flamegraphs.html for examples.--><!--NOTES: --><defs><linearGradient id="background" y1="0" y2="1" x1="0" x2="0"><stop stop-color="#eeeeee" offset="5%"/><stop stop-color="#eeeeb0" offset="95%"/></linearGradient></defs><style type="text/css"> +<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg version="1.1" width="1200" height="634" onload="init(evt)" viewBox="0 0 1200 634" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:fg="http://github.com/jonhoo/inferno"><!--Flame graph stack visualization. See https://github.com/brendangregg/FlameGraph for latest version, and http://www.brendangregg.com/flamegraphs.html for examples.--><!--NOTES: --><defs><linearGradient id="background" y1="0" y2="1" x1="0" x2="0"><stop stop-color="#eeeeee" offset="5%"/><stop stop-color="#eeeeb0" offset="95%"/></linearGradient></defs><style type="text/css"> text { font-family:"Verdana"; font-size:12px; fill:rgb(0,0,0); } #title { text-anchor:middle; font-size:17px; } #matched { text-anchor:end; } @@ -412,4 +412,4 @@ function search(term) { function format_percent(n) { return n.toFixed(4) + "%"; } -]]></script><rect x="0" y="0" width="100%" height="538" fill="url(#background)"/><text id="title" x="50.0000%" y="24.00">./venv/bin/py-spy record -o ./docs/_static/glances-flame.svg -d 60 -s --pid 122543</text><text id="details" x="10" y="40.00"> </text><text id="unzoom" class="hide" x="10" y="24.00">Reset Zoom</text><text id="search" x="1190" y="24.00">Search</text><text id="matched" x="1190" y="527.00"> </text><svg id="frames" x="10" width="1180" total_samples="423"><g><title>wrapper (glances/plugins/glances_plugin.py:1108) (1 samples, 0.24%)</title><rect x="0.0000%" y="212" width="0.2364%" height="15" fill="rgb(227,0,7)" fg:x="0" fg:w="1"/><text x="0.2500%" y="222.50"></text></g><g><title>finished (glances/timer.py:56) (1 samples, 0.24%)</title><rect x="0.0000%" y="228" width="0.2364%" height="15" fill="rgb(217,0,24)" fg:x="0" fg:w="1"/><text x="0.2500%" y="238.50"></text></g><g><title>read_procfs (psutil/_pslinux.py:1106) (3 samples, 0.71%)</title><rect x="0.2364%" y="292" width="0.7092%" height="15" fill=" |