Skip to content

Commit

Permalink
Include a process monitor
Browse files Browse the repository at this point in the history
Update runbook
  • Loading branch information
dormant-user committed Aug 11, 2024
1 parent 9046ff0 commit e708e0c
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 44 deletions.
8 changes: 8 additions & 0 deletions doc_gen/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ Routers

.. automodule:: pyninja.routers

Monitors
========

Process
=======

.. automodule:: pyninja.process

Service
=======

Expand Down
8 changes: 8 additions & 0 deletions docs/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ Routers

.. automodule:: pyninja.routers

Monitors
========

Process
=======

.. automodule:: pyninja.process

Service
=======

Expand Down
15 changes: 13 additions & 2 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ <h2 id="F">F</h2>
<h2 id="G">G</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyninja.service.get_pid">get_pid() (in module pyninja.service)</a>
<li><a href="index.html#pyninja.process.get_performance">get_performance() (in module pyninja.process)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyninja.process.get_process_status">get_process_status() (in module pyninja.process)</a>
</li>
<li><a href="index.html#pyninja.service.get_service_status">get_service_status() (in module pyninja.service)</a>
</li>
</ul></td>
Expand All @@ -131,6 +133,8 @@ <h2 id="M">M</h2>
<li><a href="index.html#module-pyninja.exceptions">pyninja.exceptions</a>
</li>
<li><a href="index.html#module-pyninja.main">pyninja.main</a>
</li>
<li><a href="index.html#module-pyninja.process">pyninja.process</a>
</li>
<li><a href="index.html#module-pyninja.routers">pyninja.routers</a>
</li>
Expand All @@ -157,7 +161,7 @@ <h2 id="N">N</h2>
<h2 id="P">P</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyninja.squire.ServiceStatus.pid">pid (pyninja.squire.ServiceStatus attribute)</a>
<li><a href="index.html#pyninja.routers.process_status">process_status() (in module pyninja.routers)</a>
</li>
<li>
pyninja.auth
Expand All @@ -183,6 +187,13 @@ <h2 id="P">P</h2>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li>
pyninja.process

<ul>
<li><a href="index.html#module-pyninja.process">module</a>
</li>
</ul></li>
<li>
pyninja.routers

<ul>
Expand Down
56 changes: 45 additions & 11 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,23 @@ <h1>Welcome to PyNinja’s documentation!<a class="headerlink" href="#welcome-to
</section>
<section id="module-pyninja.routers">
<span id="routers"></span><h1>Routers<a class="headerlink" href="#module-pyninja.routers" title="Permalink to this heading"></a></h1>
<dl class="py function">
<dt class="sig sig-object py" id="pyninja.routers.process_status">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyninja.routers.</span></span><span class="sig-name descname"><span class="pre">process_status</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">payload</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#pyninja.squire.StatusPayload" title="pyninja.squire.StatusPayload"><span class="pre">StatusPayload</span></a></span></em><span class="sig-paren">)</span><a class="headerlink" href="#pyninja.routers.process_status" title="Permalink to this definition"></a></dt>
<dd><p>API function to monitor a process.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>payload</strong> (<em>StatusPayload</em>) – Payload received as request body.</p>
</dd>
<dt class="field-even">Raises<span class="colon">:</span></dt>
<dd class="field-even"><ul class="simple">
<li><p><a class="reference internal" href="#pyninja.exceptions.APIResponse" title="pyninja.exceptions.APIResponse"><strong>APIResponse</strong></a></p></li>
<li><p><strong>Raises the HTTPStatus object with a status code and detail as response.</strong></p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyninja.routers.service_status">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyninja.routers.</span></span><span class="sig-name descname"><span class="pre">service_status</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">payload</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#pyninja.squire.StatusPayload" title="pyninja.squire.StatusPayload"><span class="pre">StatusPayload</span></a></span></em><span class="sig-paren">)</span><a class="headerlink" href="#pyninja.routers.service_status" title="Permalink to this definition"></a></dt>
Expand All @@ -143,25 +160,45 @@ <h1>Welcome to PyNinja’s documentation!<a class="headerlink" href="#welcome-to
</dd></dl>

</section>
<section id="module-pyninja.service">
<span id="service"></span><h1>Service<a class="headerlink" href="#module-pyninja.service" title="Permalink to this heading"></a></h1>
<section id="monitors">
<h1>Monitors<a class="headerlink" href="#monitors" title="Permalink to this heading"></a></h1>
</section>
<section id="module-pyninja.process">
<span id="process"></span><h1>Process<a class="headerlink" href="#module-pyninja.process" title="Permalink to this heading"></a></h1>
<dl class="py function">
<dt class="sig sig-object py" id="pyninja.service.get_pid">
<span class="sig-prename descclassname"><span class="pre">pyninja.service.</span></span><span class="sig-name descname"><span class="pre">get_pid</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">service_name</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</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">int</span></span></span><a class="headerlink" href="#pyninja.service.get_pid" title="Permalink to this definition"></a></dt>
<dt class="sig sig-object py" id="pyninja.process.get_process_status">
<span class="sig-prename descclassname"><span class="pre">pyninja.process.</span></span><span class="sig-name descname"><span class="pre">get_process_status</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">process_name</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</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">Generator</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">int</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#pyninja.process.get_process_status" title="Permalink to this definition"></a></dt>
<dd><p>Get process ID for a particular service.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>service_name</strong> (<em>str</em>) – Name of the service.</p>
</dd>
<dt class="field-even">Yields<span class="colon">:</span></dt>
<dd class="field-even"><p><em>Generator[Dict[str, int]]</em> – Yields the process metrics as a dictionary of key-value pairs.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyninja.process.get_performance">
<span class="sig-prename descclassname"><span class="pre">pyninja.process.</span></span><span class="sig-name descname"><span class="pre">get_performance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">process_name</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">process</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Process</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">int</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#pyninja.process.get_performance" title="Permalink to this definition"></a></dt>
<dd><p>Checks performance by monitoring CPU utilization, number of threads and open files.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>process</strong> – Process object.</p>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>Process ID running the service.</p>
<dd class="field-even"><p>Returns the process metrics as key-value pairs.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>int</p>
<dd class="field-odd"><p>Dict[str, int]</p>
</dd>
</dl>
</dd></dl>

</section>
<section id="module-pyninja.service">
<span id="service"></span><h1>Service<a class="headerlink" href="#module-pyninja.service" title="Permalink to this heading"></a></h1>
<dl class="py function">
<dt class="sig sig-object py" id="pyninja.service.get_service_status">
<span class="sig-prename descclassname"><span class="pre">pyninja.service.</span></span><span class="sig-name descname"><span class="pre">get_service_status</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">service_name</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em><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.squire.ServiceStatus" title="pyninja.squire.ServiceStatus"><span class="pre">ServiceStatus</span></a></span></span><a class="headerlink" href="#pyninja.service.get_service_status" title="Permalink to this definition"></a></dt>
Expand Down Expand Up @@ -204,11 +241,6 @@ <h1>Squire<a class="headerlink" href="#squire" title="Permalink to this heading"
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">ServiceStatus</span>
</pre></div>
</div>
<dl class="py attribute">
<dt class="sig sig-object py" id="pyninja.squire.ServiceStatus.pid">
<span class="sig-name descname"><span class="pre">pid</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.squire.ServiceStatus.pid" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="pyninja.squire.ServiceStatus.status_code">
<span class="sig-name descname"><span class="pre">status_code</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.squire.ServiceStatus.status_code" title="Permalink to this definition"></a></dt>
Expand Down Expand Up @@ -328,6 +360,8 @@ <h3><a href="#">Table of Contents</a></h3>
<li><a class="reference internal" href="#module-pyninja.auth">Authenticator</a></li>
<li><a class="reference internal" href="#module-pyninja.exceptions">Exceptions</a></li>
<li><a class="reference internal" href="#module-pyninja.routers">Routers</a></li>
<li><a class="reference internal" href="#monitors">Monitors</a></li>
<li><a class="reference internal" href="#module-pyninja.process">Process</a></li>
<li><a class="reference internal" href="#module-pyninja.service">Service</a></li>
<li><a class="reference internal" href="#squire">Squire</a></li>
<li><a class="reference internal" href="#indices-and-tables">Indices and tables</a></li>
Expand Down
Binary file modified docs/objects.inv
Binary file not shown.
5 changes: 5 additions & 0 deletions docs/py-modindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ <h1>Python Module Index</h1>
<td>&#160;&#160;&#160;
<a href="index.html#module-pyninja.main"><code class="xref">pyninja.main</code></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&#160;&#160;&#160;
<a href="index.html#module-pyninja.process"><code class="xref">pyninja.process</code></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&#160;&#160;&#160;
Expand Down
Loading

0 comments on commit e708e0c

Please sign in to comment.