Metadata-Version: 2.4
Name: PyNinja
Version: 4.2.0
Summary: Lightweight OS-agnostic service monitoring API
Author-email: Vignesh Rao <svignesh1793@gmail.com>
License: MIT License
        
        Copyright (c) 2024 TheVickypedia
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/thevickypedia/PyNinja
Project-URL: Docs, https://thevickypedia.github.io/PyNinja
Project-URL: Source, https://github.com/thevickypedia/PyNinja
Project-URL: Bug Tracker, https://github.com/thevickypedia/PyNinja/issues
Project-URL: Release Notes, https://github.com/thevickypedia/PyNinja/blob/main/release_notes.rst
Keywords: service-monitor,PyNinja
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Development Status :: 5 - Production/Stable
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Topic :: System :: Monitoring
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click==8.1.*
Requires-Dist: docker==7.1.*
Requires-Dist: fastapi==0.112.*
Requires-Dist: gmail-connector==1.0.*
Requires-Dist: Jinja2==3.1.*
Requires-Dist: psutil==6.0.*
Requires-Dist: PyArchitecture==0.3.*
Requires-Dist: pydantic==2.*
Requires-Dist: pydantic-settings==2.*
Requires-Dist: python-multipart>=0.0.19
Requires-Dist: PyUdisk==2.0.*
Requires-Dist: PyYaml==6.0.*
Requires-Dist: requests==2.*
Requires-Dist: uvicorn[standard]==0.32.*
Provides-Extra: dev
Requires-Dist: sphinx==5.1.1; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Requires-Dist: recommonmark; extra == "dev"
Requires-Dist: gitverse; extra == "dev"
Requires-Dist: aiohttp==3.12.*; extra == "dev"
Requires-Dist: python-dotenv==1.1.*; extra == "dev"
Requires-Dist: tqdm==4.67.*; extra == "dev"
Requires-Dist: requests==2.*; extra == "dev"
Dynamic: license-file

# PyNinja
Lightweight OS-agnostic service monitoring API

![Python][label-pyversion]

**Platform Supported**

![Platform][label-platform]

**Deployments**

[![pages][label-actions-pages]][gha_pages]
[![pypi][label-actions-pypi]][gha_pypi]
[![markdown][label-actions-markdown]][gha_md_valid]

[![Pypi][label-pypi]][pypi]
[![Pypi-format][label-pypi-format]][pypi-files]
[![Pypi-status][label-pypi-status]][pypi]

## Kick off

**Recommendations**

- Install `python` [3.11] or above
- Use a dedicated [virtual environment]

**Install PyNinja**
```shell
python -m pip install pyninja
```

**Initiate - IDE**
```python
import pyninja


if __name__ == '__main__':
    pyninja.start()
```

**Initiate - CLI**
```shell
pyninja start
```

> Use `pyninja --help` for usage instructions.

## Environment Variables

<details>
<summary><strong>Sourcing environment variables from an env file</strong></summary>

> _By default, `PyNinja` will look for a `.env` file in the current working directory._
</details>

**Basic API**
- **APIKEY** - API Key for authentication.
- **SWAGGER_UI_PARAMETERS** - Dictionary of parameters to be included in the Swagger UI.
- **NINJA_HOST** - Hostname for the API server.
- **NINJA_PORT** - Port number for the API server.

**Functional improvements**
- **RATE_LIMIT** - List of dictionaries with `max_requests` and `seconds` to apply as rate limit.
- **LOG_CONFIG** - Logging configuration file path.

**Remote execution and FileIO**
- **REMOTE_EXECUTION** - Boolean flag to enable remote execution.
- **API_SECRET** - Secret access key for running commands on server remotely.
- **DATABASE** - FilePath to store the auth database that handles the authentication errors.

⚠️ **Warning: Enabling remote execution carries significant security risks.**
To enhance security, it's strongly recommended to use multifactor authentication (MFA) via your Gmail account.
If you don't have a Gmail account and instead rely on an **API_SECRET**,
please proceed with **caution** and ensure that the **API_SECRET** is set to a strong and secure value.

**Multifactor Authentication (MFA)**
- **GMAIL_USER** - Gmail username for MFA.
- **GMAIL_PASS** - Gmail password for MFA.
- **RECIPIENT** - Recipient email address for MFA.
- **MFA_TIMEOUT** - Timeout duration for MFA in seconds.

**Monitoring UI**
- **MONITOR_USERNAME** - Username to authenticate the monitoring page.
- **MONITOR_PASSWORD** - Password to authenticate the monitoring page.
- **MONITOR_SESSION** - Session timeout for the monitoring page.
- **DISK_REPORT** - Boolean flag to enable disk report feature using [PyUdisk].
- **MAX_CONNECTIONS** - Maximum number of monitoring sessions allowed in parallel.
- **NO_AUTH** - Boolean flag to disable authentication for monitoring page.
- **PROCESSES** - List of process names to include in the monitor page.
- **SERVICES** - List of service names to include in the monitor page.
- **SERVICE_LIB** - Library path to retrieve service info.
- **SMART_LIB** - Library path for S.M.A.R.T metrics using [PyUdisk].
- **GPU_LIB** - Library path to retrieve GPU names using [PyArchitecture].
- **DISK_LIB** - Library path to retrieve disk info using [PyArchitecture].
- **PROCESSOR_LIB** - Library path to retrieve processor name using [PyArchitecture].

**macOS Specific Binaries**
- **OSASCRIPT** - Path to the `osascript` binary for macOS. Defaults to `/usr/bin/osascript`
- **MDLS** - Path to the `mdls` binary for macOS. Defaults to `/usr/bin/mdls`
- **OPEN** - Path to the `open` binary for macOS. Defaults to `/usr/bin/open`

> Certain environment variables like `SERVICES` and `PROCESSS` are case-sensitive

> Refer [samples] directory for examples.

## Coding Standards
Docstring format: [`Google`][google-docs] <br>
Styling conventions: [`PEP 8`][pep8] and [`isort`][isort]

## [Release Notes][release-notes]
**Requirement**
```shell
python -m pip install gitverse
```

**Usage**
```shell
gitverse-release reverse -f release_notes.rst -t 'Release Notes'
```

## Linting
`pre-commit` will ensure linting, run pytest, generate runbook & release notes, and validate hyperlinks in ALL
markdown files (including Wiki pages)

**Requirement**
```shell
python -m pip install sphinx==5.1.1 pre-commit recommonmark
```

**Usage**
```shell
pre-commit run --all-files
```

## Pypi Package
[![pypi-module][label-pypi-package]][pypi-repo]

[https://pypi.org/project/PyNinja/][pypi]

## Runbook
[![made-with-sphinx-doc][label-sphinx-doc]][sphinx]

[https://thevickypedia.github.io/PyNinja/][runbook]

## License & copyright

&copy; Vignesh Rao

Licensed under the [MIT License][license]

[//]: # (Labels)

[label-actions-markdown]: https://github.com/thevickypedia/PyNinja/actions/workflows/markdown.yaml/badge.svg
[label-pypi-package]: https://img.shields.io/badge/Pypi%20Package-pyninja-blue?style=for-the-badge&logo=Python
[label-sphinx-doc]: https://img.shields.io/badge/Made%20with-Sphinx-blue?style=for-the-badge&logo=Sphinx
[label-pyversion]: https://img.shields.io/badge/python-3.11%20%7C%203.12-blue
[label-platform]: https://img.shields.io/badge/Platform-Linux|macOS|Windows-1f425f.svg
[label-actions-pages]: https://github.com/thevickypedia/PyNinja/actions/workflows/pages/pages-build-deployment/badge.svg
[label-actions-pypi]: https://github.com/thevickypedia/PyNinja/actions/workflows/python-publish.yaml/badge.svg
[label-pypi]: https://img.shields.io/pypi/v/PyNinja
[label-pypi-format]: https://img.shields.io/pypi/format/PyNinja
[label-pypi-status]: https://img.shields.io/pypi/status/PyNinja

[3.11]: https://docs.python.org/3/whatsnew/3.11.html
[virtual environment]: https://docs.python.org/3/tutorial/venv.html
[release-notes]: https://github.com/thevickypedia/PyNinja/blob/main/release_notes.rst
[gha_pages]: https://github.com/thevickypedia/PyNinja/actions/workflows/pages/pages-build-deployment
[gha_pypi]: https://github.com/thevickypedia/PyNinja/actions/workflows/python-publish.yaml
[gha_md_valid]: https://github.com/thevickypedia/PyNinja/actions/workflows/markdown.yaml
[google-docs]: https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings
[pep8]: https://www.python.org/dev/peps/pep-0008/
[isort]: https://pycqa.github.io/isort/
[sphinx]: https://www.sphinx-doc.org/en/master/man/sphinx-autogen.html
[pypi]: https://pypi.org/project/PyNinja
[pypi-files]: https://pypi.org/project/PyNinja/#files
[pypi-repo]: https://packaging.python.org/tutorials/packaging-projects/
[license]: https://github.com/thevickypedia/PyNinja/blob/main/LICENSE
[runbook]: https://thevickypedia.github.io/PyNinja/
[samples]: https://github.com/thevickypedia/PyNinja/tree/main/samples
[PyUdisk]: https://github.com/thevickypedia/PyUdisk
[PyArchitecture]: https://github.com/thevickypedia/PyArchitecture
