Skip to content

Commit

Permalink
Set CPU and refresh intervals dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
dormant-user committed Sep 4, 2024
1 parent 1bcc935 commit 9d8849d
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 22 deletions.
31 changes: 26 additions & 5 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ <h3>Navigation</h3>
<h1 id="index">Index</h1>

<div class="genindex-jumpbox">
<a href="#A"><strong>A</strong></a>
<a href="#_"><strong>_</strong></a>
| <a href="#A"><strong>A</strong></a>
| <a href="#C"><strong>C</strong></a>
| <a href="#D"><strong>D</strong></a>
| <a href="#E"><strong>E</strong></a>
Expand All @@ -61,6 +62,14 @@ <h1 id="index">Index</h1>
| <a href="#W"><strong>W</strong></a>

</div>
<h2 id="_">_</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyninja.models.WSSettings._abc_impl">_abc_impl (pyninja.models.WSSettings attribute)</a>
</li>
</ul></td>
</tr></table>

<h2 id="A">A</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
Expand All @@ -83,10 +92,12 @@ <h2 id="C">C</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyninja.models.Payload.command">command (pyninja.models.Payload attribute)</a>
</li>
<li><a href="index.html#pyninja.models.complexity_checker">complexity_checker() (in module pyninja.models)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyninja.models.complexity_checker">complexity_checker() (in module pyninja.models)</a>
<li><a href="index.html#pyninja.models.WSSettings.cpu_interval">cpu_interval (pyninja.models.WSSettings attribute)</a>
</li>
<li><a href="index.html#pyninja.models.Database.create_table">create_table() (pyninja.models.Database method)</a>
</li>
Expand Down Expand Up @@ -237,6 +248,12 @@ <h2 id="M">M</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyninja.models.RateLimit.max_requests">max_requests (pyninja.models.RateLimit attribute)</a>
</li>
<li><a href="index.html#pyninja.models.WSSettings.model_computed_fields">model_computed_fields (pyninja.models.WSSettings attribute)</a>
</li>
<li><a href="index.html#pyninja.models.WSSettings.model_config">model_config (pyninja.models.WSSettings attribute)</a>
</li>
<li><a href="index.html#pyninja.models.WSSettings.model_fields">model_fields (pyninja.models.WSSettings attribute)</a>
</li>
<li>
module
Expand Down Expand Up @@ -390,10 +407,12 @@ <h2 id="R">R</h2>
</li>
<li><a href="index.html#pyninja.rate_limit.RateLimiter">RateLimiter (class in pyninja.rate_limit)</a>
</li>
<li><a href="index.html#pyninja.models.EnvConfig.remote_execution">remote_execution (pyninja.models.EnvConfig attribute)</a>
<li><a href="index.html#pyninja.models.WSSettings.refresh_interval">refresh_interval (pyninja.models.WSSettings attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyninja.models.EnvConfig.remote_execution">remote_execution (pyninja.models.EnvConfig attribute)</a>
</li>
<li><a href="index.html#pyninja.database.remove_record">remove_record() (in module pyninja.database)</a>
</li>
<li><a href="index.html#pyninja.models.Session.rps">rps (pyninja.models.Session attribute)</a>
Expand Down Expand Up @@ -462,11 +481,13 @@ <h2 id="W">W</h2>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyninja.routers.websocket_endpoint">websocket_endpoint() (in module pyninja.routers)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyninja.models.ServiceManager.windows">windows (pyninja.models.ServiceManager attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyninja.models.EnvConfig.workers">workers (pyninja.models.EnvConfig attribute)</a>
</li>
<li><a href="index.html#pyninja.models.WSSettings">WSSettings (class in pyninja.models)</a>
</li>
</ul></td>
</tr></table>
Expand Down
57 changes: 52 additions & 5 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,50 @@ <h1>Models<a class="headerlink" href="#models" title="Permalink to this heading"
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="pyninja.models.WSSettings">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyninja.models.</span></span><span class="sig-name descname"><span class="pre">WSSettings</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cpu_interval</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">3</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">refresh_interval</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">5</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#pyninja.models.WSSettings" title="Permalink to this definition"></a></dt>
<dd><p>Default settings for websocket configuration.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">WSSettings</span>
</pre></div>
</div>
<dl class="py attribute">
<dt class="sig sig-object py" id="pyninja.models.WSSettings.cpu_interval">
<span class="sig-name descname"><span class="pre">cpu_interval</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">int</span></em><a class="headerlink" href="#pyninja.models.WSSettings.cpu_interval" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="pyninja.models.WSSettings.refresh_interval">
<span class="sig-name descname"><span class="pre">refresh_interval</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">int</span></em><a class="headerlink" href="#pyninja.models.WSSettings.refresh_interval" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="pyninja.models.WSSettings._abc_impl">
<span class="sig-name descname"><span class="pre">_abc_impl</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">&lt;_abc._abc_data</span> <span class="pre">object&gt;</span></em><a class="headerlink" href="#pyninja.models.WSSettings._abc_impl" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="pyninja.models.WSSettings.model_computed_fields">
<span class="sig-name descname"><span class="pre">model_computed_fields</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">ClassVar</span><span class="p"><span class="pre">[</span></span><span class="pre">dict</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">ComputedFieldInfo</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></em><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">{}</span></em><a class="headerlink" href="#pyninja.models.WSSettings.model_computed_fields" title="Permalink to this definition"></a></dt>
<dd><p>A dictionary of computed field names and their corresponding <cite>ComputedFieldInfo</cite> objects.</p>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="pyninja.models.WSSettings.model_config">
<span class="sig-name descname"><span class="pre">model_config</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">ClassVar</span><span class="p"><span class="pre">[</span></span><span class="pre">ConfigDict</span><span class="p"><span class="pre">]</span></span></em><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">{}</span></em><a class="headerlink" href="#pyninja.models.WSSettings.model_config" title="Permalink to this definition"></a></dt>
<dd><p>Configuration for the model, should be a dictionary conforming to [<cite>ConfigDict</cite>][pydantic.config.ConfigDict].</p>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="pyninja.models.WSSettings.model_fields">
<span class="sig-name descname"><span class="pre">model_fields</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">ClassVar</span><span class="p"><span class="pre">[</span></span><span class="pre">dict</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">FieldInfo</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></em><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">{'cpu_interval':</span> <span class="pre">FieldInfo(annotation=int,</span> <span class="pre">required=False,</span> <span class="pre">default=3,</span> <span class="pre">metadata=[Gt(gt=0)]),</span> <span class="pre">'refresh_interval':</span> <span class="pre">FieldInfo(annotation=int,</span> <span class="pre">required=False,</span> <span class="pre">default=5,</span> <span class="pre">metadata=[Gt(gt=0)])}</span></em><a class="headerlink" href="#pyninja.models.WSSettings.model_fields" title="Permalink to this definition"></a></dt>
<dd><p>Metadata about the fields defined on the model,
mapping of field names to [<cite>FieldInfo</cite>][pydantic.fields.FieldInfo].</p>
<p>This replaces <cite>Model.__fields__</cite> from Pydantic V1.</p>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyninja.models.get_service_manager">
<span class="sig-prename descclassname"><span class="pre">pyninja.models.</span></span><span class="sig-name descname"><span class="pre">get_service_manager</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="#pyninja.models.ServiceManager" title="pyninja.models.ServiceManager"><span class="pre">ServiceManager</span></a></span></span><a class="headerlink" href="#pyninja.models.get_service_manager" title="Permalink to this definition"></a></dt>
Expand Down Expand Up @@ -1038,14 +1082,17 @@ <h1>Models<a class="headerlink" href="#models" title="Permalink to this heading"

<dl class="py function">
<dt class="sig sig-object py" id="pyninja.squire.system_resources">
<span class="sig-prename descclassname"><span class="pre">pyninja.squire.</span></span><span class="sig-name descname"><span class="pre">system_resources</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Dict</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">dict</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#pyninja.squire.system_resources" title="Permalink to this definition"></a></dt>
<span class="sig-prename descclassname"><span class="pre">pyninja.squire.</span></span><span class="sig-name descname"><span class="pre">system_resources</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cpu_interval</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Dict</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">dict</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#pyninja.squire.system_resources" title="Permalink to this definition"></a></dt>
<dd><p>Get system resources like CPU, virtual memory and swap memory information.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns<span class="colon">:</span></dt>
<dd class="field-odd"><p>Returns a nested dictionary.</p>
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>cpu_interval</strong> – Interval in seconds is used to compare CPU times elapsed before and after.</p>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
<dd class="field-even"><p>Dict[str, dict]</p>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>Returns a nested dictionary.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>Dict[str, dict]</p>
</dd>
</dl>
</dd></dl>
Expand Down
Binary file modified docs/objects.inv
Binary file not shown.
Loading

0 comments on commit 9d8849d

Please sign in to comment.