poa-netstats-warehouse/doc/POABackend.Receivers.System...

337 lines
12 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.18.4">
<title>POABackend.Receivers.System.Stats poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-f62ce50de1.js"></script>
</head>
<body data-type="modules">
<script>try { if(localStorage.getItem('night-mode')) document.body.className += ' night-mode'; } catch (e) { }</script>
<div class="main">
<button class="sidebar-button sidebar-toggle">
<span class="icon-menu" aria-hidden="true"></span>
<span class="sr-only">Toggle Sidebar</span>
</button>
<button class="sidebar-button night-mode-toggle">
<span class="icon-theme" aria-hidden="true"></span>
<span class="sr-only">Toggle Theme</span>
</button>
<section class="sidebar">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
</h1>
<h2 class="sidebar-projectVersion">
v0.1.0
</h2>
</div>
</a>
<form class="sidebar-search" action="search.html">
<button type="submit" class="search-button">
<span class="icon-search" aria-hidden="true"></span>
</button>
<input name="q" type="text" id="search-list" class="search-input" placeholder="Search" aria-label="Search" autocomplete="off" />
</form>
<ul class="sidebar-listNav">
<li><a id="extras-list" href="#full-list">Pages</a></li>
<li><a id="modules-list" href="#full-list">Modules</a></li>
</ul>
<div class="gradient"></div>
<ul id="full-list" class="sidebar-fullList"></ul>
</section>
<section class="content">
<div class="content-outer">
<div id="content" class="content-inner">
<h1>
<small class="visible-xs">poa_backend v0.1.0</small>
POABackend.Receivers.System.Stats
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/receivers/system/stats.ex#L1" title="View Source" class="view-source" rel="help">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</h1>
<section id="moduledoc">
<p>This is a Receiver Plugin which is in charge of storing the System Metrics received from the Agents in a Postgres
database. If we want to use it we have to declare it in the Config file, inside the <code class="inline">:receivers</code> section, ie:</p>
<pre><code class="elixir">{:store_system_stats, POABackend.Receivers.System.Stats, []}</code></pre>
<p>This Plugin uses Postgres as a backend, specifically the <code class="inline">system_stats</code> table. Make sure that table exists before using
this Plugin.</p>
<p>We also need to subscribe this plugin to <code class="inline">:system_metrics</code> metrics in the config file. For that we have to add this line
to the list in the <code class="inline">:subscriptions</code> section:</p>
<pre><code class="elixir">{:store_system_stats, [:system_metrics]}</code></pre>
</section>
<section id="summary" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#summary">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this section</span>
</a>
Summary
</h1>
<div class="summary-functions summary">
<h2>
<a href="#functions">Functions</a>
</h2>
<div class="summary-row">
<div class="summary-signature">
<a href="#handle_inactive/2">handle_inactive(agent_id, state)</a>
</div>
<div class="summary-synopsis"><p>This function is called when a Custom Handler detects a client is inactive</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#handle_message/2">handle_message(message, state)</a>
</div>
<div class="summary-synopsis"><p>In this callback is called when the Receiver process receives an erlang message</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#init_receiver/1">init_receiver(args)</a>
</div>
<div class="summary-synopsis"><p>A callback executed when the Receiver Plugin starts.
The argument is retrieved from the configuration file when the Receiver is defined
It must return <code class="inline">{:ok, state}</code>, that <code class="inline">state</code> will be keept as in <a href="https://hexdocs.pm/elixir/GenServer.html"><code class="inline">GenServer</code></a> and can be
retrieved in the <a href="#metrics_received/3"><code class="inline">metrics_received/3</code></a> function</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#metrics_received/3">metrics_received(arg1, from, state)</a>
</div>
<div class="summary-synopsis"><p>This callback will be called every time a message to the subscribed metric type arrives. It must
return the tuple <code class="inline">{:ok, state}</code></p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#terminate/1">terminate(state)</a>
</div>
<div class="summary-synopsis"><p>This callback is called just before the Process goes down. This is a good place for closing connections</p>
</div>
</div>
</div>
</section>
<section id="functions" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#functions">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this section</span>
</a>
Functions
</h1>
<div class="detail" id="handle_inactive/2">
<div class="detail-header">
<a href="#handle_inactive/2" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">handle_inactive(agent_id, state)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/receivers/system/stats.ex#L39" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p> This function is called when a Custom Handler detects a client is inactive.</p>
<p> The Custom Handler must to call explicity to <a href="POABackend.CustomHandler.html#publish_inactive/1"><code class="inline">POABackend.CustomHandler.publish_inactive/1</code></a> and it will publish the
<code class="inline">inactive</code> message to all the metrics in the system (defined in the config file).</p>
<p>Callback implementation for <a href="POABackend.Receiver.html#c:handle_inactive/2"><code class="inline">POABackend.Receiver.handle_inactive/2</code></a>.</p>
</section>
</div>
<div class="detail" id="handle_message/2">
<div class="detail-header">
<a href="#handle_message/2" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">handle_message(message, state)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/receivers/system/stats.ex#L35" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p> In this callback is called when the Receiver process receives an erlang message.</p>
<p> It must return <code class="inline">{:ok, state}</code>.</p>
<p>Callback implementation for <a href="POABackend.Receiver.html#c:handle_message/2"><code class="inline">POABackend.Receiver.handle_message/2</code></a>.</p>
</section>
</div>
<div class="detail" id="init_receiver/1">
<div class="detail-header">
<a href="#init_receiver/1" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">init_receiver(args)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/receivers/system/stats.ex#L23" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p> A callback executed when the Receiver Plugin starts.
The argument is retrieved from the configuration file when the Receiver is defined
It must return <code class="inline">{:ok, state}</code>, that <code class="inline">state</code> will be keept as in <a href="https://hexdocs.pm/elixir/GenServer.html"><code class="inline">GenServer</code></a> and can be
retrieved in the <a href="#metrics_received/3"><code class="inline">metrics_received/3</code></a> function.</p>
<p>Callback implementation for <a href="POABackend.Receiver.html#c:init_receiver/1"><code class="inline">POABackend.Receiver.init_receiver/1</code></a>.</p>
</section>
</div>
<div class="detail" id="metrics_received/3">
<div class="detail-header">
<a href="#metrics_received/3" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">metrics_received(arg1, from, state)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/receivers/system/stats.ex#L31" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p> This callback will be called every time a message to the subscribed metric type arrives. It must
return the tuple <code class="inline">{:ok, state}</code></p>
<p>Callback implementation for <a href="POABackend.Receiver.html#c:metrics_received/3"><code class="inline">POABackend.Receiver.metrics_received/3</code></a>.</p>
</section>
</div>
<div class="detail" id="terminate/1">
<div class="detail-header">
<a href="#terminate/1" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">terminate(state)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/receivers/system/stats.ex#L43" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p> This callback is called just before the Process goes down. This is a good place for closing connections.</p>
<p>Callback implementation for <a href="POABackend.Receiver.html#c:terminate/1"><code class="inline">POABackend.Receiver.terminate/1</code></a>.</p>
</section>
</div>
</section>
<footer class="footer">
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by
<a href="https://twitter.com/dignifiedquire" target="_blank" title="@dignifiedquire">Friedel Ziegelmayer</a>.
</span>
</p>
</footer>
</div>
</div>
</section>
</div>
<script src="dist/app-9bd040e5e5.js"></script>
</body>
</html>