1
0
mirror of https://github.com/rtbrick/bngblaster.git synced 2024-05-06 15:54:57 +00:00
rtbrick-bngblaster/docs/controller.html
2022-06-30 08:38:05 +00:00

285 lines
17 KiB
HTML

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Controller &mdash; BNG Blaster 0.7 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/tabs.css" type="text/css" />
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Troubleshooting" href="troubleshooting.html" />
<link rel="prev" title="API/CLI" href="api/index.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home"> BNG Blaster
<img src="_static/rtbrick_logo.png" class="logo" alt="Logo"/>
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="install.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="quickstart.html">Quickstart Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Interfaces</a></li>
<li class="toctree-l1"><a class="reference internal" href="access/index.html">Access Protocols</a></li>
<li class="toctree-l1"><a class="reference internal" href="routing/index.html">Routing Protocols</a></li>
<li class="toctree-l1"><a class="reference internal" href="streams.html">Traffic Streams</a></li>
<li class="toctree-l1"><a class="reference internal" href="reports.html">Reports</a></li>
<li class="toctree-l1"><a class="reference internal" href="configuration/index.html">Configuration</a></li>
<li class="toctree-l1"><a class="reference internal" href="api/index.html">API/CLI</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Controller</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#installation">Installation</a></li>
<li class="toctree-l2"><a class="reference internal" href="#api">API</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#create-test-instance">Create Test Instance</a></li>
<li class="toctree-l3"><a class="reference internal" href="#start-test">Start Test</a></li>
<li class="toctree-l3"><a class="reference internal" href="#status">Status</a></li>
<li class="toctree-l3"><a class="reference internal" href="#command">Command</a></li>
<li class="toctree-l3"><a class="reference internal" href="#stop-test">Stop Test</a></li>
<li class="toctree-l3"><a class="reference internal" href="#delete-test-instance">Delete Test Instance</a></li>
<li class="toctree-l3"><a class="reference internal" href="#metrics">Metrics</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="troubleshooting.html">Troubleshooting</a></li>
<li class="toctree-l1"><a class="reference internal" href="reference/index.html">Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">BNG Blaster</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home"></a> &raquo;</li>
<li>Controller</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/controller.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="controller">
<span id="id1"></span><h1>Controller<a class="headerlink" href="#controller" title="Permalink to this headline"></a></h1>
<p>The BNG Blaster controller provides a REST API to start and stop multiple test instances.
It exposes the BNG Blaster <a class="reference internal" href="api/index.html#api"><span class="std std-ref">JSON RPC API</span></a> as REST API and provides endpoints
to download logs and reports.</p>
<p><a class="reference external" href="https://github.com/rtbrick/bngblaster-controller">https://github.com/rtbrick/bngblaster-controller</a></p>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>The BNG Blaster controller should run on any modern linux distribution
but is primary tested on Ubuntu 18.04 LTS and Ubuntu 20.04 LTS.</p>
<p>Download and install debian package: <a class="reference external" href="https://github.com/rtbrick/bngblaster-controller/releases">https://github.com/rtbrick/bngblaster-controller/releases</a></p>
</section>
<section id="api">
<h2>API<a class="headerlink" href="#api" title="Permalink to this headline"></a></h2>
<p>OpenAPI: <a class="reference external" href="https://rtbrick.github.io/bngblaster-controller/">https://rtbrick.github.io/bngblaster-controller/</a></p>
<section id="create-test-instance">
<h3>Create Test Instance<a class="headerlink" href="#create-test-instance" title="Permalink to this headline"></a></h3>
<p><cite>PUT /api/v1/instances/&lt;instance-name&gt;</cite></p>
<p>This API endpoint creates a test instance if not already created. The body of this request
is stored as bngblaster configuration (<cite>config.json</cite>).</p>
<p>Each test instance creates a directory in <cite>/var/bngblaster/&lt;instance-name&gt;</cite>.
This directory contains the following files:</p>
<ul class="simple">
<li><p><cite>config.json</cite>: bngblaster configuration</p></li>
<li><p><cite>run.pid</cite>: bngblaster process ID (if running)</p></li>
<li><p><cite>run.json</cite>: bngblaster arguments</p></li>
<li><p><cite>run_report.json</cite>: bngblaster report (if enabled)</p></li>
<li><p><cite>run.pcap</cite>: bngblaster traffic capture (if enabled)</p></li>
<li><p><cite>run.sock</cite>: bngblaster control socket</p></li>
<li><p><cite>run.stderr</cite>: bngblaster standard error</p></li>
<li><p><cite>run.stdout</cite>: bngblaster standard output</p></li>
</ul>
</section>
<section id="start-test">
<h3>Start Test<a class="headerlink" href="#start-test" title="Permalink to this headline"></a></h3>
<p><cite>POST /api/v1/instances/&lt;instance-name&gt;/_start</cite></p>
<p>The start API endpoint will start the bngblaster with the argument options
defined in the body.</p>
<div class="highlight-json notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="nt">&quot;logging&quot;</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w"></span>
<span class="w"> </span><span class="nt">&quot;logging_flags&quot;</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"></span>
<span class="w"> </span><span class="s2">&quot;error&quot;</span><span class="p">,</span><span class="w"></span>
<span class="w"> </span><span class="s2">&quot;ip&quot;</span><span class="w"></span>
<span class="w"> </span><span class="p">]</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>
</div>
<p>All supported argument options are explained in the OpenAPI schema.</p>
</section>
<section id="status">
<h3>Status<a class="headerlink" href="#status" title="Permalink to this headline"></a></h3>
<p><cite>GET /api/v1/instances/&lt;instance-name&gt;</cite></p>
<p>The status API endpoint returns the status of the test.</p>
</section>
<section id="command">
<h3>Command<a class="headerlink" href="#command" title="Permalink to this headline"></a></h3>
<p><cite>POST /api/v1/instances/&lt;instance-name&gt;/_command</cite></p>
<p>The JSON body of this API call will be passed to the bngblaster instance
control socket (<cite>/var/bngbnlaster/&lt;instance-name&gt;/run.sock</cite>). The result will
be passed back to the client.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>curl --location --request POST &#39;http://&lt;IP&gt;&gt;:8001/api/v1/instances/&lt;instance-name&gt;/_command&#39; \
--header &#39;Content-Type: application/json&#39; \
--data-raw &#39;{
&quot;command&quot;: &quot;session-info&quot;,
&quot;arguments&quot;: {
&quot;session-id&quot;: 1
}
}&#39;
</pre></div>
</div>
<div class="highlight-json notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="nt">&quot;status&quot;</span><span class="p">:</span><span class="w"> </span><span class="s2">&quot;ok&quot;</span><span class="p">,</span><span class="w"></span>
<span class="w"> </span><span class="nt">&quot;code&quot;</span><span class="p">:</span><span class="w"> </span><span class="mi">200</span><span class="p">,</span><span class="w"></span>
<span class="w"> </span><span class="nt">&quot;session-info&quot;</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="nt">&quot;type&quot;</span><span class="p">:</span><span class="w"> </span><span class="s2">&quot;pppoe&quot;</span><span class="p">,</span><span class="w"></span>
<span class="w"> </span><span class="nt">&quot;session-id&quot;</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"></span>
<span class="w"> </span><span class="nt">&quot;session-state&quot;</span><span class="p">:</span><span class="w"> </span><span class="s2">&quot;Established&quot;</span><span class="p">,</span><span class="w"></span>
<span class="w"> </span><span class="nt">&quot;...&quot;</span><span class="p">:</span><span class="w"> </span><span class="s2">&quot;...&quot;</span><span class="w"></span>
<span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>
</div>
<p>The result code is passed as HTTP response status code.</p>
<div class="highlight-json notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="nt">&quot;status&quot;</span><span class="p">:</span><span class="w"> </span><span class="s2">&quot;warning&quot;</span><span class="p">,</span><span class="w"></span>
<span class="w"> </span><span class="nt">&quot;code&quot;</span><span class="p">:</span><span class="w"> </span><span class="mi">404</span><span class="p">,</span><span class="w"></span>
<span class="w"> </span><span class="nt">&quot;message&quot;</span><span class="p">:</span><span class="w"> </span><span class="s2">&quot;session not found&quot;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>
</div>
</section>
<section id="stop-test">
<h3>Stop Test<a class="headerlink" href="#stop-test" title="Permalink to this headline"></a></h3>
<p><cite>POST /api/v1/instances/&lt;instance-name&gt;/_stop</cite></p>
<p>The stop API endpoint will send the SIGINT signal to the corresponding BNG blaster instance (<cite>kill -INT &lt;pid&gt;</cite>).</p>
</section>
<section id="delete-test-instance">
<h3>Delete Test Instance<a class="headerlink" href="#delete-test-instance" title="Permalink to this headline"></a></h3>
<p><cite>DELETE /api/v1/instances/&lt;instance-name&gt;</cite></p>
<p>This API endpoint deletes the test instance directory. The corresponding
test run is forcefully terminated (<cite>kill -9 &lt;pid&gt;</cite>) if running.</p>
</section>
<section id="metrics">
<h3>Metrics<a class="headerlink" href="#metrics" title="Permalink to this headline"></a></h3>
<p><cite>GET /metrics</cite></p>
<p>This endpoint returns metrics for all instances in prometheus text format.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span># HELP instances_running The number of running instances
# TYPE instances_running gauge
instances_running{hostname=&quot;blaster&quot;} 0
# HELP instances_total The total number of instances
# TYPE instances_total gauge
instances_total{hostname=&quot;blaster&quot;} 4
</pre></div>
</div>
<p>The metric <cite>instances_total</cite> counts the number of test instance directories
present and <cite>instances_running</cite> shows how many of them are running.</p>
<p>Every metric is labelled with the hostname where the controller is running.</p>
<p>Per default there are no metrics per instance. This has to be explicitly
enabled during instance start (<cite>/api/v1/instances/&lt;instance-name&gt;/_start</cite>)
using the new <cite>metric_flags</cite> option.</p>
<div class="highlight-json notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="nt">&quot;logging&quot;</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w"></span>
<span class="w"> </span><span class="nt">&quot;logging_flags&quot;</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"></span>
<span class="w"> </span><span class="s2">&quot;error&quot;</span><span class="p">,</span><span class="w"></span>
<span class="w"> </span><span class="s2">&quot;ip&quot;</span><span class="w"></span>
<span class="w"> </span><span class="p">],</span><span class="w"></span>
<span class="w"> </span><span class="nt">&quot;metric_flags&quot;</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"></span>
<span class="w"> </span><span class="s2">&quot;session_counters&quot;</span><span class="p">,</span><span class="w"></span>
<span class="w"> </span><span class="s2">&quot;interfaces&quot;</span><span class="w"></span>
<span class="w"> </span><span class="p">]</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>
</div>
<p>Currently the following metrics are supported:</p>
<ul class="simple">
<li><p><cite>session_counters</cite> session statistics</p></li>
<li><p><cite>interfaces</cite> interface counters</p></li>
</ul>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span># HELP sessions The total number of sessions
# TYPE sessions counter
sessions{hostname=&quot;blaster&quot;,instance_name=&quot;test&quot;} 10
# HELP sessions_established The number of sessions in state established
# TYPE sessions_established gauge
sessions_established{hostname=&quot;blaster&quot;,instance_name=&quot;test&quot;} 10
...
</pre></div>
</div>
<p>Instance metrics are labelled with the instance name. All interface specific metrics
are also labelled with the corresponding interface name.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span># HELP interfaces_rx_bytes Interface RX bytes
# TYPE interfaces_rx_bytes counter
interfaces_rx_bytes{hostname=&quot;blaster&quot;,instance_name=&quot;test&quot;,interface_name=&quot;eth1&quot;,interface_type=&quot;access&quot;} 36270
...
</pre></div>
</div>
</section>
</section>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="api/index.html" class="btn btn-neutral float-left" title="API/CLI" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="troubleshooting.html" class="btn btn-neutral float-right" title="Troubleshooting" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2020-2022, RtBrick, Inc..</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>