Metadata-Version: 2.4
Name: opsiconfd
Version: 4.3.33.9
Summary: opsi configuration service
Author-email: uib GmbH <info@uib.de>
Maintainer-email: uib GmbH <info@uib.de>
License-Expression: AGPL-3.0-only
Project-URL: Homepage, https://www.opsi.org
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: acme>=3.0
Requires-Dist: aiofiles>=24.1
Requires-Dist: aiohttp>=3.7
Requires-Dist: aiologger>=0.7
Requires-Dist: aiozeroconf>=0.1
Requires-Dist: annotated-types>=0.7
Requires-Dist: click>=8.1
Requires-Dist: configargparse>=1.4
Requires-Dist: configupdater>=3.1
Requires-Dist: distro>=1.5
Requires-Dist: fastapi>=0.115
Requires-Dist: greenlet>=3.0
Requires-Dist: hiredis>=3.1
Requires-Dist: httpx>=0.28
Requires-Dist: itsdangerous>=2.0
Requires-Dist: mysqlclient<2.2,>=2.0
Requires-Dist: netifaces>=0.11
Requires-Dist: objgraph>=3.5
Requires-Dist: py3dns>=4.0
Requires-Dist: pydantic>=2.4
Requires-Dist: pydantic-core>=2.18
Requires-Dist: pympler>=1.0
Requires-Dist: pymysql>=1.1
Requires-Dist: pyotp>=2.8
Requires-Dist: python-magic>=0.4
Requires-Dist: python-multipart>=0.0
Requires-Dist: python-opsi<4.4,>=4.3.6
Requires-Dist: python-opsi-common<4.4,>=4.3.29
Requires-Dist: python-opsi-system<4.4,>=4.3.2.1
Requires-Dist: python3-saml==1.16.0
Requires-Dist: qrcode>=8.0
Requires-Dist: redis<5.3,>=5.0
Requires-Dist: rich>=13.0
Requires-Dist: six>=1.16
Requires-Dist: starlette>=0.46
Requires-Dist: uvicorn>=0.34
Requires-Dist: uvloop>=0.21
Requires-Dist: websockets>=15.0
Requires-Dist: werkzeug>=3.0
Requires-Dist: wsgidav>=4.3
Requires-Dist: wsproto>=1.2
Requires-Dist: xmlsec
Requires-Dist: lxml
Requires-Dist: yappi>=1.4; platform_machine == "x86_64"

![pipeline](https://gitlab.uib.gmbh/uib/opsiconfd/badges/devel/pipeline.svg)
![coverage](https://gitlab.uib.gmbh/uib/opsiconfd/badges/devel/coverage.svg)
# Configuration

The configuration is based on [ConfigArgParse](https://pypi.org/project/ConfigArgParse/).
Configuration can be done by command line, config file, environment variable, and defaults.
If a value is specified in more than one way, the folowing order of precedence is applied:
command line argument > environment variable > config file value > default value

## Internal and external urls
In the communication between services (redis, grafana, opsiconfd, ...) the internal urls are used.
These can be different from the external urls of the services, for example when services are connected via a docker internal network or behind a proxy / load-balancer.

## workers and executor workers
JSON-RPC requests will be executed in a asyncio executor pool, because the opsi backend is not async currently.
Therefore, the maximum of concurrent JSON-RPC requests is limited by the number of workers and the size of the executor pool.
**max concurrent JSON-RPC-requests = workers * executor-workers**
If this limit is exceeded, new JSON-RPC requests will have to wait for a free worker.
Thus, long runinng JSON-RPC requests could block other requests.

# Development in Dev Container
* Install Remote-Containers: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers
* Set OPSILICSRV_TOKEN in docker/opsiconfd-dev/.env if available
* Open project in container:
	* \<F1\> -> Remote-Containers: Reopen in Container
	* or remote button in bottom left corner -> Reopen in Container
* In the container \<F5\> starts opsiconfd in debug mode (opsiconfd default)
* You can use the default debug settings or you can set the number of worker and the log level by selecting opsiconfd in the debug/run tab.

## Run Tests
* Select "Run Tests" on the Status Bar, use the Test Explorer or run `uv run pytest --cov-append --cov opsiconfd --cov-report term --cov-report xml -vv tests` in a terminal


# Performance
## Redis
* Based on the Redis official benchmark, you can improve performance by upto 50% using unix sockets (versus TCP ports) on Redis.
* Check slow queries `SLOWLOG GET`
* Check queries `MONITOR`

## Memory usage / profiling
### py-spy
To analyze high CPU usage of opsiconfd processes py-spy can be very helpful.
```shell
py-spy top --full-filenames --pid <pid-of-opsiconfd-worker-or-manager>
```

### valgrind
```
PYTHONMALLOC=malloc sudo -E valgrind --tool=memcheck --trace-children=yes --dsymutil=yes --leak-check=full --show-leak-kinds=all --log-file=/tmp/valgrind-out uv run opsiconfd --workers=1 --log-level-stderr=5
```
* PYTHONMALLOC=debug
* PYTHONMALLOC=malloc_debug
