Commit Graph

6608 Commits

Author SHA1 Message Date
nicolargo e46eb765ff Update documentation lint 2025-07-05 10:32:11 +02:00
nicolargo 82a829d0c4 Update documentation 2025-07-05 10:32:11 +02:00
nicolargo 155452e223 Glances 4.3.2_rc01 2025-07-05 10:32:11 +02:00
nicolargo 15a94f04da Improve Restful API documentation embeded in FastAPI #2632 2025-07-05 10:32:11 +02:00
nicolargo 813785ff82 Change the way Docker start Glances 2025-07-05 10:32:11 +02:00
nicolargo 28e82eb237 Lint Dockerfile 2025-07-05 10:32:11 +02:00
nicolargo 1268b58bbc Glances breaks if Podman container is started while it is running #3199 2025-07-05 10:32:11 +02:00
nicolargo 1434d3ad5c Avoid none in rate computation 2025-07-05 10:32:11 +02:00
nicolargo 28ae053e4b Glances Central Browser should use name instead of IP adress for redirection #3103 2025-07-05 10:32:11 +02:00
nicolargo cd71b45089 Add container inactive_file & limit to InfluxDB2 export #3206 2025-07-05 10:32:11 +02:00
nicolargo 1365d600a3 (postgre)SQL export support / TimeScaleDB #2814 2025-07-05 10:32:11 +02:00
nicolargo 7c13ae17fa Implement a basic memory cache with TTL for API call (set to ~1 second) #3202 2025-07-05 10:32:11 +02:00
nicolargo b888dc55e8 Correct key() by keys() 2025-07-05 10:32:11 +02:00
Boris Okassa ed2e1cdefb exports: outputs: Removed iterator helpers
Related to #3181
Signed-off-by: Boris Okassa <borisokassa@yahoo.fr>
2025-07-05 10:32:11 +02:00
renovate[bot] 505a90f8da fix(deps): update dependency pysnmp-lextudio to <6.3.1 2025-07-05 10:32:11 +02:00
snyk-bot cac2e0b884 fix: dev-requirements.txt to reduce vulnerabilities
The following vulnerabilities are fixed by pinning transitive dependencies:
- https://snyk.io/vuln/SNYK-PYTHON-H11-10293728
2025-07-05 10:32:11 +02:00
snyk-bot df93b5bf4c fix: optional-requirements.txt to reduce vulnerabilities
The following vulnerabilities are fixed by pinning transitive dependencies:
- https://snyk.io/vuln/SNYK-PYTHON-NUMPY-2321964
- https://snyk.io/vuln/SNYK-PYTHON-NUMPY-2321966
- https://snyk.io/vuln/SNYK-PYTHON-NUMPY-2321970
- https://snyk.io/vuln/SNYK-PYTHON-PYARROW-6052811
- https://snyk.io/vuln/SNYK-PYTHON-SETUPTOOLS-3180412
- https://snyk.io/vuln/SNYK-PYTHON-SETUPTOOLS-7448482
- https://snyk.io/vuln/SNYK-PYTHON-SETUPTOOLS-9964606
- https://snyk.io/vuln/SNYK-PYTHON-URLLIB3-7267250
2025-07-05 10:32:11 +02:00
nicolargo e277908118 Commit issue following #3186 - glances.js not found 2025-07-05 10:32:11 +02:00
fr4nc0is ea12008e10 Update plugin containers display and order #3186 2025-07-05 10:32:11 +02:00
ia74 bcf3d42097 Change "Pinned thread" to "Pinned task" and "Upin" to "Unpin" 2025-07-05 10:32:11 +02:00
Ariel Otilibili 0ffb08dd2a glances: Refactor _build_amps_list
Used a list comprehension. Moreover None and empty list are considered
as false values in Python.

Part-of: #2801
Link: https://docs.python.org/3/library/stdtypes.html#truth-value-testing
Signed-off-by: Ariel Otilibili <otilibil@eurecom.fr>
2025-07-05 10:32:11 +02:00
Ariel Otilibili 75b7998185 glances: amps: remove iterator helpers
No more needed in Python 3.

Moreover in update(), the keys are not used: the call to items() is
replaced with values().

Related to #3181
2025-07-05 10:32:11 +02:00
nicolargo f45900b450 Add test for JSON export 2025-07-05 10:32:11 +02:00
nicolargo 96660cae16 Add Star history to Readme file 2025-07-05 10:32:11 +02:00
nicolargo 83a5847ff1 Add Star history to Readme file 2025-07-05 10:32:11 +02:00
renovate[bot] 51166fe1df chore(deps): update alpine docker tag to v3.22 2025-07-05 10:32:11 +02:00
Ariel Otilibili 1375573a46 glances: remove iterator helpers
No more needed in Python 3. Following commit 72e1511d ("globals: Fix a
race condition in namedtuple_to_dict"), the dynamic view on the keys is
as well transformed into a list.

Related to #3181
2025-07-05 10:32:11 +02:00
Ariel Otilibili 239d5f7db6 glances: Refactor
Instead of a loop, used a generator for the search.

Part-of: #2801
Signed-off-by: Ariel Otilibili <otilibil@eurecom.fr>
2025-07-05 10:32:11 +02:00
Ariel Otilibili 81150246e5 glances: remove iterator helpers
No more needed in Python 3.

Related to #3181
2025-07-05 10:32:11 +02:00
Ariel Otilibili 39ac435218 plugins: containers: Refactor update()
Commit 445d20dc ("plugins: containers: Refactor") changed update() so
that, stats are added if any of is_key_in_container_and_not_hidden()
or is_key_absent_in_container() is true.

This could be replaced by the negation of is_key_in_container_and_hidden()

Part-of: #2801
Suggested-by: Jasmin Blackshaw <105jassen@gmail.com>
Signed-off-by: Ariel Otilibili <otilibil@eurecom.fr>
2025-07-05 10:32:11 +02:00
Ariel Otilibili 016799cbfa outputs: glances_curses: Refactor
In catch_other_actions_maybe_return_to_browser(), replaced if-statements
by a dict. If no key is found, a null function is executed.

Part-of: #2801
Signed-off-by: Ariel Otilibili <otilibil@eurecom.fr>
2025-07-05 10:32:11 +02:00
nicolargo 719094edf7 Update Glances dev version 2025-07-05 10:32:11 +02:00
nicolargo c343351072 Update Glances dev version 2025-07-05 10:32:11 +02:00
nicolargo d79c74df25 Update Glances dev version 2025-07-05 10:32:11 +02:00
Ariel Otilibili 3488760ae5 globals: Fix a race condition in namedtuple_to_dict
namedtuple_to_dict() loops over a dynamic view of the dict of processes;
other threads might be editing the same dict.

For instance in webserver mode, when a race condition happens, the
following error shows up in the console:

>   File "C:\Users\ryabtsev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\glances\processes.py", line 628, in update_list
>     return list_of_namedtuple_to_list_of_dict(processlist)
>   File "C:\Users\ryabtsev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\glances\globals.py", line 495, in list_of_namedtuple_to_list_of_dict
>     return [namedtuple_to_dict(d) for d in data]
>             ^^^^^^^^^^^^^^^^^^^^^
>   File "/app/glances/globals.py", line 490, in namedtuple_to_dict
>     return {k: (v._asdict() if hasattr(v, '_asdict') else v) for k, v in data.items()}
>                                                                          ^^^^^^^^^^^^
> RuntimeError: dictionary changed size during iteration

Instead of a dict view, namedtuple_to_dict() will use a list of tuples.

Performances are unchanged: on average, for 100 runs, namedtuple_to_dict()
completes in 0.2ms

GH issue: #3097
Link: https://docs.python.org/3/library/stdtypes.html#dictionary-view-objects
Signed-off-by: Ariel Otilibili <otilibil@eurecom.fr>
2025-07-05 10:32:11 +02:00
nicolargo 7c0dee3a63 Add support for InfluxDB 3 Core #3182 2025-07-05 10:32:11 +02:00
Ariel Otilibili a5b2a97e6c podman: remove iterator helpers
No more needed in Python 3.

Related to #3181
2025-07-05 10:32:11 +02:00
Ariel Otilibili b57b26e1b5 docker: remove iterator helpers
No more needed in Python 3.

Related to #3181
2025-07-05 10:32:11 +02:00
nicolargo 31834a366f Related to iteritems, itervalues, and iterkeys are not more needed in Python 3 #3181 2025-07-05 10:32:11 +02:00
nicolargo aea1b67862 Related to iteritems, itervalues, and iterkeys are not more needed in Python 3 #3181 2025-07-05 10:32:11 +02:00
nicolargo e28bf6496f Add a new field in the process list to identifie Zombie process #3178 2025-07-05 10:32:11 +02:00
Ariel Otilibili a78e778b36 plugins: containers: Refactor
1. update()
Two branches share the same logic for updating stats. Moreover, intermediate
values where used in nested loops: for filtering keys, and for extending stats.

This could be done at once with chain.from_iterable().

Therefore four helpers are introduced:
- add_engine_into_container
- is_key_in_container_and_not_hidden
- is_key_absent_in_container
- get_containers_from_updated_watcher

A profiling shows the stats build time is the same after the refactor,

$ sudo make run-webserver 2>&1 | grep primitive
         31631 function calls (31566 primitive calls) in 0.028 seconds
         23537 function calls (23487 primitive calls) in 0.025 seconds
         23559 function calls (23509 primitive calls) in 0.014 seconds
         23549 function calls (23499 primitive calls) in 0.024 seconds
         23549 function calls (23499 primitive calls) in 0.026 seconds
         23559 function calls (23509 primitive calls) in 0.016 seconds
         23559 function calls (23509 primitive calls) in 0.022 seconds
         23544 function calls (23494 primitive calls) in 0.015 seconds
         23549 function calls (23499 primitive calls) in 0.023 seconds
         23544 function calls (23494 primitive calls) in 0.018 seconds

[snapshot of top three calls]
         31881 function calls (31816 primitive calls) in 0.029 seconds

   Ordered by: cumulative time
   List reduced from 536 to 3 due to restriction <3>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        3    0.000    0.000    0.029    0.010 __init__.py:250(<genexpr>)
        2    0.000    0.000    0.029    0.015 __init__.py:242(get_containers_from_updated_watcher)
        1    0.000    0.000    0.029    0.029 docker.py:248(update)

And before,

$ sudo make run-webserver 2>&1 | grep primitive
         31620 function calls (31555 primitive calls) in 0.021 seconds
         23526 function calls (23476 primitive calls) in 0.019 seconds
         23533 function calls (23483 primitive calls) in 0.024 seconds
         23538 function calls (23488 primitive calls) in 0.015 seconds
         23528 function calls (23478 primitive calls) in 0.023 seconds
         23528 function calls (23478 primitive calls) in 0.022 seconds
         23533 function calls (23483 primitive calls) in 0.016 seconds
         23538 function calls (23488 primitive calls) in 0.025 seconds
         23538 function calls (23488 primitive calls) in 0.029 seconds
         23538 function calls (23488 primitive calls) in 0.013 seconds

[snapshot of top three calls]
         31865 function calls (31800 primitive calls) in 0.024 seconds

   Ordered by: cumulative time
   List reduced from 531 to 3 due to restriction <3>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.024    0.024 docker.py:248(update)
       13    0.000    0.000    0.022    0.002 decorators.py:38(inner)
       13    0.000    0.000    0.022    0.002 client.py:244(_get)

2. msg_curse()
The conditions are directly used in any().

3. exit()
Minimum supported version is Python 3.9; loops use iterators by default.

itervalues() was introduced for compatility with Python 2. Commit 76ea71f2
("Remove Python 2 in docs and README files") removed Python 2 support.

Part-of: #2801
Link: https://docs.python.org/3/library/itertools.html#itertools.chain.from_iterable
Link: https://docs.python.org/3/library/profile.html#profile.Profile
Signed-off-by: Ariel Otilibili <otilibil@eurecom.fr>
2025-07-05 10:32:11 +02:00
Ariel Otilibili 91902f0ffa plugins: containers: Refactor build_container_data
All the if-statements do the same actions:
- check the key is not disabled
- and add the corresponding callback to the building steps.

There could be done with a list comprehension on a dict.

Part-of: #2801
Signed-off-by: Ariel Otilibili <otilibil@eurecom.fr>
2025-07-05 10:32:11 +02:00
Ariel Otilibili f747bdfa73 containers: Fix sorting
sort_keys() uses sort_by_these_keys() on the stats. So doing, one of the
retrieved values might be absent; and sort_keys() will fall back to the
default sorting method, which is the alphabetical order.

This is the case for dead or exited containers.

Instead of a key lookup, the get method of dict could be used.

GH issue: #3098
Signed-off-by: Ariel Otilibili <otilibil@eurecom.fr>
2025-07-05 10:32:11 +02:00
Ariel Otilibili e4cdc14cd0 containers: processes: Refactor
Refactored sort_docker_stats() and sort_stats().

Useful for an upcoming commit.

Part-of: #2801
Signed-off-by: Ariel Otilibili <otilibil@eurecom.fr>
2025-07-05 10:32:11 +02:00
nicolargo dc165930b4 Refactor code to limit the complexity of update_views method in plugins #3171 2025-07-05 10:32:11 +02:00
nicolargo 03f23a582d Code refactoring - Rename plugin class to <Plugin name>Plugin instead of PluginModel #3169 2025-07-05 10:32:11 +02:00
Ariel Otilibili 1e92365c5e plugins: connections: refactor, version 2
Extracted update_with_net_connections_method and
update_with_nf_conntrack_method from update.

Part-of: #2801
Link: https://scrutinizer-ci.com/g/nicolargo/glances/code-structure/develop/py-function/glances.plugins.connections.PluginModel.update
Signed-off-by: Ariel Otilibili <otilibil@eurecom.fr>
2025-07-05 10:32:11 +02:00
Nicolas Hennion a3e55145b8 Revert "plugins: connections: refactor" 2025-07-05 10:32:11 +02:00
Ariel Otilibili 72a1466e9f plugins: connections: refactor
Extracted update_with_net_connections_method and
update_with_nf_conntrack_method from update.

Part-of: #2801
Link: https://scrutinizer-ci.com/g/nicolargo/glances/code-structure/develop/py-function/glances.plugins.connections.PluginModel.update
Signed-off-by: Ariel Otilibili <otilibil@eurecom.fr>
2025-07-05 10:32:11 +02:00