Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Include todo for future release
Remove redundant conditions for disk_report
  • Loading branch information
dormant-user committed Dec 1, 2024
1 parent 36615e9 commit 86650a0
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 14 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Lightweight OS-agnostic service monitoring API
python -m pip install pyninja
```

> For Linux machines, use `pip install pyninja[extra]` to include functionalities from [PyUdisk] (S.M.A.R.T metrics)
**Initiate - IDE**
```python
import pyninja
Expand Down Expand Up @@ -59,6 +61,7 @@ pyninja start
- **REMOTE_EXECUTION** - Boolean flag to enable remote execution.
- **API_SECRET** - Secret access key for running commands on server remotely.
- **DISK_REPORT** - Boolean flag to enable disk report feature using [PyUdisk].
- **UDISK_LIB** - Udisk library for Linux machines to use [PyUdisk].
- **MONITOR_USERNAME** - Username to authenticate the monitoring page.
- **MONITOR_PASSWORD** - Password to authenticate the monitoring page.
- **MONITOR_SESSION** - Session timeout for the monitoring page.
Expand Down
4 changes: 4 additions & 0 deletions docs/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ <h2>Kick off<a class="headerlink" href="#kick-off" title="Permalink to this head
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>python<span class="w"> </span>-m<span class="w"> </span>pip<span class="w"> </span>install<span class="w"> </span>pyninja
</pre></div>
</div>
<blockquote>
<div><p>For Linux machines, use <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">pyninja[extra]</span></code> to include functionalities from <a class="reference external" href="https://github.com/thevickypedia/PyUdisk">PyUdisk</a> (S.M.A.R.T metrics)</p>
</div></blockquote>
<p><strong>Initiate - IDE</strong></p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">pyninja</span>

Expand Down Expand Up @@ -96,6 +99,7 @@ <h2>Environment Variables<a class="headerlink" href="#environment-variables" tit
<li><p><strong>REMOTE_EXECUTION</strong> - Boolean flag to enable remote execution.</p></li>
<li><p><strong>API_SECRET</strong> - Secret access key for running commands on server remotely.</p></li>
<li><p><strong>DISK_REPORT</strong> - Boolean flag to enable disk report feature using <a class="reference external" href="https://github.com/thevickypedia/PyUdisk">PyUdisk</a>.</p></li>
<li><p><strong>UDISK_LIB</strong> - Udisk library for Linux machines to use <a class="reference external" href="https://github.com/thevickypedia/PyUdisk">PyUdisk</a>.</p></li>
<li><p><strong>MONITOR_USERNAME</strong> - Username to authenticate the monitoring page.</p></li>
<li><p><strong>MONITOR_PASSWORD</strong> - Password to authenticate the monitoring page.</p></li>
<li><p><strong>MONITOR_SESSION</strong> - Session timeout for the monitoring page.</p></li>
Expand Down
3 changes: 3 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Lightweight OS-agnostic service monitoring API
python -m pip install pyninja
```

> For Linux machines, use `pip install pyninja[extra]` to include functionalities from [PyUdisk] (S.M.A.R.T metrics)
**Initiate - IDE**
```python
import pyninja
Expand Down Expand Up @@ -59,6 +61,7 @@ pyninja start
- **REMOTE_EXECUTION** - Boolean flag to enable remote execution.
- **API_SECRET** - Secret access key for running commands on server remotely.
- **DISK_REPORT** - Boolean flag to enable disk report feature using [PyUdisk].
- **UDISK_LIB** - Udisk library for Linux machines to use [PyUdisk].
- **MONITOR_USERNAME** - Username to authenticate the monitoring page.
- **MONITOR_PASSWORD** - Password to authenticate the monitoring page.
- **MONITOR_SESSION** - Session timeout for the monitoring page.
Expand Down
3 changes: 3 additions & 0 deletions docs/_sources/README.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Lightweight OS-agnostic service monitoring API
python -m pip install pyninja
```

> For Linux machines, use `pip install pyninja[extra]` to include functionalities from [PyUdisk] (S.M.A.R.T metrics)

**Initiate - IDE**
```python
import pyninja
Expand Down Expand Up @@ -59,6 +61,7 @@ pyninja start
- **REMOTE_EXECUTION** - Boolean flag to enable remote execution.
- **API_SECRET** - Secret access key for running commands on server remotely.
- **DISK_REPORT** - Boolean flag to enable disk report feature using [PyUdisk].
- **UDISK_LIB** - Udisk library for Linux machines to use [PyUdisk].
- **MONITOR_USERNAME** - Username to authenticate the monitoring page.
- **MONITOR_PASSWORD** - Password to authenticate the monitoring page.
- **MONITOR_SESSION** - Session timeout for the monitoring page.
Expand Down
2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pyninja/modules/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class EnvConfig(BaseSettings):
"""

# todo: make apikey optional but validate if either apikey or (monitor username and password) is available
apikey: str
ninja_host: str = socket.gethostbyname("localhost") or "0.0.0.0"
ninja_port: PositiveInt = 8000
Expand Down
20 changes: 7 additions & 13 deletions pyninja/monitor/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ async def monitor_endpoint(
return await monitor.config.clear_session(
request, await monitor.authenticator.session_error(request, error)
)
# If disk_report was not enabled on the server, the Content-Type header or Cookie for render is not honored
if not models.env.disk_report:
render = enums.Cookies.monitor.value
if not render:
Expand All @@ -147,19 +148,12 @@ async def monitor_endpoint(
name=enums.Templates.main.value, context=ctx
)
elif render == enums.Cookies.drive.value:
if models.env.disk_report:
LOGGER.info("Rendering disk report!")
try:
return await monitor.drive.report(request)
except Exception as error:
LOGGER.error(error)
return await monitor.drive.invalidate(
"Failed to generate disk report"
)
else:
return await monitor.drive.invalidate(
"Disk reporting feature is not enabled in the server!"
)
LOGGER.info("Rendering disk report!")
try:
return await monitor.drive.report(request)
except Exception as error:
LOGGER.error(error)
return await monitor.drive.invalidate("Failed to generate disk report")
return monitor.config.templates.TemplateResponse(
name=enums.Templates.index.value,
context={
Expand Down

0 comments on commit 86650a0

Please sign in to comment.