blob: ae65cf6b206c16432b3607cb7477ddba24c71387 [file] [log] [blame]
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Traffic Ops &mdash; Traffic Control 2.2-dev documentation </title>
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/theme_overrides.css" type="text/css" />
<link rel="index" title="Index"
href="../genindex.html"/>
<link rel="search" title="Search" href="../search.html"/>
<link rel="top" title="Traffic Control 2.2-dev documentation" href="../index.html"/>
<link rel="up" title="Developer’s Guide" href="index.html"/>
<link rel="next" title="Traffic Portal" href="traffic_portal.html"/>
<link rel="prev" title="Building Traffic Control" href="building.html"/>
<script src="_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-nav-search">
<a href="/" class="icon icon-home"> Traffic Control
<img src="../_static/tc_logo_c_only.png" class="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="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../basics/index.html">CDN Basics</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../basics/content_delivery_networks.html">Content Delivery Networks</a></li>
<li class="toctree-l2"><a class="reference internal" href="../basics/http_11.html">HTTP 1.1</a></li>
<li class="toctree-l2"><a class="reference internal" href="../basics/caching_proxies.html">Caching Proxies</a></li>
<li class="toctree-l2"><a class="reference internal" href="../basics/cache_revalidation.html">Cache Control Headers and Revalidation</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">Traffic Control Overview</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../overview/introduction.html">Introduction</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/traffic_ops.html">Traffic Ops</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/traffic_portal.html">Traffic Portal</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/traffic_router.html">Traffic Router</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/traffic_monitor.html">Traffic Monitor</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/traffic_stats.html">Traffic Stats</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/traffic_vault.html">Traffic Vault</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../admin/index.html">Administrator’s Guide</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_ops/installation.html">Traffic Ops - Installing</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_ops/default_profiles.html">Traffic Ops - Default Profiles</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_ops/migration_from_10_to_20.html">Traffic Ops - Migrating from 1.x to 2.x</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_ops/migration_from_20_to_22.html">Traffic Ops - Migrating from 2.0 to 2.2</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_ops/configuration.html">Traffic Ops - Configuring</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_ops/using.html">Traffic Ops - Using</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_ops/extensions.html">Managing Traffic Ops Extensions</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_portal/installation.html">Traffic Portal Administration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_portal/usingtrafficportal.html">Traffic Portal - Using</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_monitor.html">Traffic Monitor Administration (Legacy)</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_monitor_golang.html">Traffic Monitor Administration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_router.html">Traffic Router Administration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_stats.html">Traffic Stats Administration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_server.html">Traffic Server Administration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_vault.html">Traffic Vault Administration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/quick_howto/index.html">Quick How To Guides</a></li>
</ul>
</li>
</ul>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Developer’s Guide</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="building.html">Building Traffic Control</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Traffic Ops</a></li>
<li class="toctree-l2"><a class="reference internal" href="traffic_portal.html">Traffic Portal</a></li>
<li class="toctree-l2"><a class="reference internal" href="traffic_router.html">Traffic Router</a></li>
<li class="toctree-l2"><a class="reference internal" href="traffic_monitor.html">Traffic Monitor Golang</a></li>
<li class="toctree-l2"><a class="reference internal" href="traffic_stats.html">Traffic Stats</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../api/index.html">APIs</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../api/traffic_ops_api.html">API Overview</a></li>
<li class="toctree-l2"><a class="reference internal" href="../api/routes.html">API Routes</a></li>
<li class="toctree-l2"><a class="reference internal" href="../api/v11/index.html">API 1.1 Reference</a></li>
<li class="toctree-l2"><a class="reference internal" href="../api/v12/index.html">API 1.2 Reference</a></li>
<li class="toctree-l2"><a class="reference internal" href="../api/v13/index.html">API 1.3 Reference</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../faq/index.html">FAQ</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../faq/general.html">General</a></li>
<li class="toctree-l2"><a class="reference internal" href="../faq/development.html">Development</a></li>
<li class="toctree-l2"><a class="reference internal" href="../faq/administration.html">Running a Traffic Control CDN</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../glossary.html">Glossary</a></li>
</ul>
</div>
&nbsp;
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">Traffic Control</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html">Traffic Control 2.2-dev</a> &raquo;</li>
<li><a href="index.html">Developer’s Guide</a> &raquo;</li>
<li>Traffic Ops</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/development/traffic_ops.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="traffic_portal.html" class="btn btn-neutral float-right" title="Traffic Portal">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="building.html" class="btn btn-neutral" title="Building Traffic Control"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<div role="main" class="document">
<div class="section" id="traffic-ops">
<h1>Traffic Ops<a class="headerlink" href="#traffic-ops" title="Permalink to this headline"></a></h1>
<div class="section" id="introduction">
<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline"></a></h2>
<p>Traffic Ops uses a Postgres database to store the configuration information, and the <a class="reference external" href="http://mojolicio.us/">Mojolicious framework</a> to generate the user interface and REST APIs.</p>
</div>
<div class="section" id="software-requirements">
<h2>Software Requirements<a class="headerlink" href="#software-requirements" title="Permalink to this headline"></a></h2>
<p>To work on Traffic Ops you need a *nix (MacOS and Linux are most commonly used) environment that has the following installed:</p>
<ul class="simple">
<li><a class="reference external" href="http://search.cpan.org/~miyagawa/Carton-v1.0.12/lib/Carton.pm">Carton 1.0.12</a><ul>
<li>cpan JSON</li>
<li>cpan JSON::PP</li>
</ul>
</li>
<li><a class="reference external" href="http://golang.org/doc/install">Go 1.8.3</a></li>
<li>Perl 5.10.1</li>
<li>Git</li>
<li>Postgres 9.6.6</li>
<li><a class="reference external" href="https://bitbucket.org/liamstask/goose/">Goose</a></li>
</ul>
<p>Addionally, the installation of the following RPMs (or equivalent) is required:</p>
<ul class="simple">
<li>All RPMs listed in <a class="reference internal" href="../admin/traffic_ops/migration_from_10_to_20.html#rl-ps"><span class="std std-ref">Traffic Ops - Migrating from 1.x to 2.x</span></a></li>
</ul>
</div>
<div class="section" id="traffic-ops-project-tree-overview">
<h2>Traffic Ops Project Tree Overview<a class="headerlink" href="#traffic-ops-project-tree-overview" title="Permalink to this headline"></a></h2>
<p><strong>/opt/traffic_ops/app</strong></p>
<ul class="simple">
<li>bin/ - Directory for scripts, cronjobs, etc</li>
<li>conf/<ul>
<li>/development - Development (local) specific config files.</li>
<li>/misc - Miscellaneous config files.</li>
<li>/production - Production specific config files.</li>
<li>/test - Test (unit test) specific config files.</li>
</ul>
</li>
<li>db/ - Database related area.<ul>
<li>/migrations - Database Migration files.</li>
</ul>
</li>
<li>lib/<ul>
<li>/API - Mojo Controllers for the /API area of the application.</li>
<li>/Common - Common Code between both the API and UI areas.</li>
<li>/Extensions</li>
<li>Fixtures/ - Test Case fixture data for the ‘to_test’ database.
* /Integration - Integration Tests.</li>
<li>/MojoPlugins - Mojolicious Plugins for Common Controller Code.</li>
<li>Schema/ - Database Schema area.
* /Result - DBIx ORM related files.</li>
<li>/Test - Common Test.</li>
<li>/UI - Mojo Controllers for the Traffic Ops UI itself.</li>
<li>Utils/
* /Helper - Common utilities for the Traffic Ops application.</li>
</ul>
</li>
<li>log/ - Log directory where the development and test files are written by the app.</li>
<li>public/</li>
</ul>
<blockquote>
<div><ul class="simple">
<li>css/ - Stylesheets.</li>
<li>images/ - Images.</li>
<li>js/ - Javascripts</li>
</ul>
</div></blockquote>
<ul class="simple">
<li>script/ - Mojo Bootstrap scripts.</li>
<li>t/ - Unit Tests for the UI.</li>
</ul>
<blockquote>
<div><ul class="simple">
<li>api/ - Unit Tests for the API.</li>
</ul>
</div></blockquote>
<ul class="simple">
<li>t_integration/ - High level tests for Integration level testing.</li>
<li>templates/ - Mojo Embedded Perl (.ep) files for the UI.</li>
</ul>
</div>
<div class="section" id="perl-formatting-conventions">
<h2>Perl Formatting Conventions<a class="headerlink" href="#perl-formatting-conventions" title="Permalink to this headline"></a></h2>
<p>Perl tidy is for use in code formatting. See the following config file for formatting conventions.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>edit a file called $HOME/.perltidyrc
-l=156
-et=4
-t
-ci=4
-st
-se
-vt=0
-cti=0
-pt=1
-bt=1
-sbt=1
-bbt=1
-nsfs
-nolq
-otr
-aws
-wls=&quot;= + - / * .&quot;
-wrs=\&quot;= + - / * .\&quot;
-wbb=&quot;% + - * / x != == &gt;= &lt;= =~ &lt; &gt; | &amp; **= += *= &amp;= &lt;&lt;= &amp;&amp;= -= /= |= + &gt;&gt;= ||= .= %= ^= x=&quot;
</pre></div>
</div>
</div>
<div class="section" id="database-management">
<h2>Database Management<a class="headerlink" href="#database-management" title="Permalink to this headline"></a></h2>
<p>The admin.pl script is for use in managing the Traffic Ops database tables. Below is an example of its usage.</p>
<p><code class="docutils literal notranslate"><span class="pre">$</span> <span class="pre">db/admin.pl</span></code></p>
<p>Usage: db/admin.pl [–env (development|test|production)] [arguments]</p>
<p>Example: <code class="docutils literal notranslate"><span class="pre">db/admin.pl</span> <span class="pre">--env=test</span> <span class="pre">reset</span></code></p>
<p>Purpose: This script is used to manage the database. The environments are defined in the dbconf.yml, as well as the database names.</p>
<ul class="simple">
<li>To use the <code class="docutils literal notranslate"><span class="pre">admin.pl</span></code> script, you may need to add <code class="docutils literal notranslate"><span class="pre">traffic_ops/lib</span></code> and <code class="docutils literal notranslate"><span class="pre">traffic_ops/local/lib/perl5</span></code> to your <a class="reference external" href="http://modperlbook.org/html/3-9-2-2-Using-the-PERL5LIB-environment-variable.html">PERL5LIB</a> environment variable.</li>
</ul>
<table border="1" class="docutils">
<colgroup>
<col width="14%" />
<col width="86%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Arguments</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>create</td>
<td>Execute db ‘create’ the database for the current environment.</td>
</tr>
<tr class="row-odd"><td>down</td>
<td>Roll back a single migration from the current version.</td>
</tr>
<tr class="row-even"><td>drop</td>
<td>Execute db ‘drop’ on the database for the current environment.</td>
</tr>
<tr class="row-odd"><td>redo</td>
<td>Roll back the most recently applied migration, then run it again.</td>
</tr>
<tr class="row-even"><td>reset</td>
<td>Execute db drop, create, load_schema, migrate on the database for
the current environment.</td>
</tr>
<tr class="row-odd"><td>seed</td>
<td>Execute SQL from db/seeds.sql for loading static data.</td>
</tr>
<tr class="row-even"><td>setup</td>
<td>Execute db drop, create, load_schema, migrate, seed on the
database for the current environment.</td>
</tr>
<tr class="row-odd"><td>status</td>
<td>Print the status of all migrations.</td>
</tr>
<tr class="row-even"><td>upgrade</td>
<td>Execute migrate then seed on the database for the current
environment.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="installing-the-developer-environment">
<h2>Installing The Developer Environment<a class="headerlink" href="#installing-the-developer-environment" title="Permalink to this headline"></a></h2>
<p>To install the Traffic Ops Developer environment:</p>
<ol class="arabic simple">
<li>Clone the traffic_control repository from <a class="reference external" href="https://github.com/apache/incubator-trafficcontrol">github.com</a>.</li>
<li>Install the local dependencies using Carton (cpanfile).</li>
</ol>
<blockquote>
<div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cd traffic_ops/app
$ carton
</pre></div>
</div>
</div></blockquote>
<ol class="arabic" start="3">
<li><p class="first">Set up a role (user) in Postgres</p>
<p>See Postgres instructions on initdb <a class="reference external" href="https://wiki.postgresql.org/wiki/First_steps">https://wiki.postgresql.org/wiki/First_steps</a></p>
</li>
<li><p class="first">Enter <code class="docutils literal notranslate"><span class="pre">db/admin.pl</span> <span class="pre">--env=&lt;enviroment</span> <span class="pre">name&gt;</span> <span class="pre">setup</span></code> to set up the traffic_ops database(s).</p>
<ul class="simple">
<li>Unit test database: <code class="docutils literal notranslate"><span class="pre">$</span> <span class="pre">db/admin.pl</span> <span class="pre">--env=test</span> <span class="pre">setup</span></code></li>
<li>Development database: <code class="docutils literal notranslate"><span class="pre">$</span> <span class="pre">db/admin.pl</span> <span class="pre">--env=development</span> <span class="pre">setup</span></code></li>
<li>Integration database: <code class="docutils literal notranslate"><span class="pre">$</span> <span class="pre">db/admin.pl</span> <span class="pre">--env=integration</span> <span class="pre">setup</span></code></li>
</ul>
<div class="line-block">
<div class="line"><br /></div>
</div>
<p>Running the the admin.pl script in setup mode should look like this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>master $ db/admin.pl --env=development setup
Using database.conf: conf/development/database.conf
Using database.conf: conf/development/database.conf
Using database.conf: conf/development/database.conf
Using database.conf: conf/development/database.conf
Using database.conf: conf/development/database.conf
Using database.conf: conf/development/database.conf
Executing &#39;drop database to_development&#39;
Executing &#39;create database to_development&#39;
Creating database tables...
Warning: Using a password on the command line interface can be insecure.
Migrating database...
goose: migrating db environment &#39;development&#39;, current version: 0, target: 20150210100000
OK 20141222103718_extension.sql
OK 20150108100000_add_job_deliveryservice.sql
OK 20150205100000_cg_location.sql
OK 20150209100000_cran_to_asn.sql
OK 20150210100000_ds_keyinfo.sql
Seeding database...
Warning: Using a password on the command line interface can be insecure.
</pre></div>
</div>
</li>
<li><p class="first">(Optional) To load temporary data into the tables: <code class="docutils literal notranslate"><span class="pre">$</span> <span class="pre">perl</span> <span class="pre">bin/db/setup_kabletown.pl</span></code></p>
</li>
<li><p class="first">Run the postinstall script: <code class="docutils literal notranslate"><span class="pre">traffic_ops/install/bin/postinstall</span></code></p>
</li>
<li><p class="first">To start Traffic Ops, enter <code class="docutils literal notranslate"><span class="pre">$</span> <span class="pre">bin/start.pl</span></code></p>
<p>The local Traffic Ops instance uses an open source framework called morbo, starting following the start command execution.</p>
<p>Start up success includes the following:</p>
</li>
</ol>
<blockquote>
<div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">2015</span><span class="o">-</span><span class="mi">02</span><span class="o">-</span><span class="mi">24</span> <span class="mi">10</span><span class="p">:</span><span class="mi">44</span><span class="p">:</span><span class="mi">34</span><span class="p">,</span><span class="mi">991</span><span class="p">]</span> <span class="p">[</span><span class="n">INFO</span><span class="p">]</span> <span class="n">Listening</span> <span class="n">at</span> <span class="s2">&quot;http://*:3000&quot;</span><span class="o">.</span>
<span class="n">Server</span> <span class="n">available</span> <span class="n">at</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span><span class="p">:</span><span class="mf">3000.</span>
</pre></div>
</div>
</div></blockquote>
<ol class="arabic simple" start="8">
<li>Using a browser, navigate to the given address: <code class="docutils literal notranslate"><span class="pre">http://127.0.0.1:3000</span></code></li>
<li>For the initial log in:</li>
</ol>
<blockquote>
<div><ul class="simple">
<li>User name: admin</li>
<li>Password: password</li>
</ul>
</div></blockquote>
<ol class="arabic simple" start="10">
<li>Change the log in information.</li>
</ol>
</div>
<div class="section" id="test-cases">
<h2>Test Cases<a class="headerlink" href="#test-cases" title="Permalink to this headline"></a></h2>
<p>Use prove to execute test cases. Execute after a carton install:</p>
<ul class="simple">
<li>To run the Unit Tests: <code class="docutils literal notranslate"><span class="pre">$</span> <span class="pre">local/bin/prove</span> <span class="pre">-qrp</span>&#160; <span class="pre">t/</span></code></li>
<li>To run the Integration Tests: <code class="docutils literal notranslate"><span class="pre">$</span> <span class="pre">local/bin/prove</span> <span class="pre">-qrp</span> <span class="pre">t_integration/</span></code></li>
</ul>
<div class="section" id="the-kabletown-cdn-example">
<h3>The KableTown CDN example<a class="headerlink" href="#the-kabletown-cdn-example" title="Permalink to this headline"></a></h3>
<p>The integration tests will load an example CDN with most of the features of Traffic Control being used. This is mostly for testing purposes, but can also be used as an example of how to configure certain features. To load the KableTown CDN example and access it:</p>
<ol class="arabic simple">
<li>Run the integration tests</li>
<li>Start morbo against the integration database: <code class="docutils literal notranslate"><span class="pre">export</span> <span class="pre">MOJO_MODE=integration;</span> <span class="pre">./bin/start.pl</span></code></li>
<li>Using a browser, navigate to the given address: <code class="docutils literal notranslate"><span class="pre">http://127.0.0.1:3000</span></code></li>
<li>For the initial log in:</li>
</ol>
<blockquote>
<div><ul class="simple">
<li>User name: admin</li>
<li>Password: password</li>
</ul>
</div></blockquote>
</div>
</div>
<div class="section" id="extensions">
<h2>Extensions<a class="headerlink" href="#extensions" title="Permalink to this headline"></a></h2>
<p>Traffic Ops Extensions are a way to enhance the basic functionality of Traffic Ops in a custom manner. There are three types of extensions:</p>
<ol class="arabic simple">
<li>Check Extensions</li>
</ol>
<blockquote>
<div>These allow you to add custom checks to the “Health-&gt;Server Checks” view.</div></blockquote>
<ol class="arabic simple" start="2">
<li>Configuration Extensions</li>
</ol>
<blockquote>
<div>These allow you to add custom configuration file generators.</div></blockquote>
<ol class="arabic simple" start="3">
<li>Data source Extensions</li>
</ol>
<blockquote>
<div>These allow you to add statistic sources for the graph views and APIs.</div></blockquote>
<p>Extensions are managed using the $TO_HOME/bin/extensions command line script. For more information see <a class="reference internal" href="../admin/traffic_ops/extensions.html#admin-to-ext-script"><span class="std std-ref">Managing Traffic Ops Extensions</span></a>.</p>
<div class="section" id="check-extensions">
<h3>Check Extensions<a class="headerlink" href="#check-extensions" title="Permalink to this headline"></a></h3>
<p>In other words, check extensions are scripts that, after registering with Traffic Ops, have a column reserved in the “Health-&gt;Server Checks” view and that usually run periodically out of cron.</p>
<p>It is the responsibility of the check extension script to iterate over the servers it wants to check and post the results.</p>
<p>An example script might proceed by logging into the Traffic Ops server using the HTTPS base_url provided on the command line. The script is hardcoded with an auth token that is also provisioned in the Traffic Ops User database. This token allows the script to obtain a cookie used in later communications with the Traffic Ops API. The script then obtains a list of all caches to be polled by accessing Traffic Ops’ <code class="docutils literal notranslate"><span class="pre">/api/1.1/servers.json</span></code> REST target. This list is walked, running a command to gather the stats from that cache. For some extensions, an HTTP GET request might be made to the ATS astats plugin, while for others the cache might be pinged, or a command run over SSH. The results are then compiled into a numeric or boolean result and the script POSTs tha result back to the Traffic Ops <code class="docutils literal notranslate"><span class="pre">/api/1.1/servercheck/</span></code> target.</p>
<p>A check extension can have a column of <img alt="checkmark" src="../_images/good1.png" />‘s and <img alt="X" src="../_images/bad1.png" />‘s (CHECK_EXTENSION_BOOL) or a column that shows a number (CHECK_EXTENSION_NUM).A simple example of a check extension of type CHECK_EXTENSION_NUM that will show 99.33 for all servers of type EDGE is shown below:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Script</span> <span class="n">here</span><span class="o">.</span>
</pre></div>
</div>
<p>Check Extension scripts are located in the $TO_HOME/bin/checks directory.</p>
<p>Currently, the following Check Extensions are available and installed by default:</p>
<dl class="docutils">
<dt><strong>Cache Disk Usage Check - CDU</strong></dt>
<dd>This check shows how much of the available total cache disk is in use. A “warm” cache should show 100.00.</dd>
<dt><strong>Cache Hit Ratio Check - CHR</strong></dt>
<dd>The cache hit ratio for the cache in the last 15 minutes (the interval is determined by the cron entry).</dd>
<dt><strong>DiffServe CodePoint Check - DSCP</strong></dt>
<dd>Checks if the returning traffic from the cache has the correct DSCP value as assigned in the delivery service. (Some routers will overwrite DSCP)</dd>
<dt><strong>Maximum Transmission Check - MTU</strong></dt>
<dd>Checks if the Traffic Ops host (if that is the one running the check) can send and receive 8192 size packets to the <code class="docutils literal notranslate"><span class="pre">ip_address</span></code> of the server in the server table.</dd>
<dt><strong>Operational Readiness Check - ORT</strong></dt>
<dd>See <a class="reference internal" href="../admin/traffic_server.html#reference-traffic-ops-ort"><span class="std std-ref">Configuring Traffic Server</span></a> for more information on the ort script. The ORT column shows how many changes the traffic_ops_ort.pl script would apply if it was run. The number in this column should be 0.</dd>
<dt><strong>Ping Check - 10G, ILO, 10G6, FQDN</strong></dt>
<dd><p class="first">The bin/checks/ToPingCheck.pl is to check basic IP connectivity, and in the default setup it checks IP connectivity to the following:</p>
<dl class="last docutils">
<dt>10G</dt>
<dd>Is the <code class="docutils literal notranslate"><span class="pre">ip_address</span></code> (the main IPv4 address) from the server table pingable?</dd>
<dt>ILO</dt>
<dd>Is the <code class="docutils literal notranslate"><span class="pre">ilo_ip_address</span></code> (the lights-out-mangement IPv4 address) from the server table pingable?</dd>
<dt>10G6</dt>
<dd>Is the <code class="docutils literal notranslate"><span class="pre">ip6_address</span></code> (the main IPv6 address) from the server table pingable?</dd>
<dt>FQDN</dt>
<dd>Is the Fully Qualified Domain name (the concatenation of <code class="docutils literal notranslate"><span class="pre">host_name</span></code> and <code class="docutils literal notranslate"><span class="pre">.</span></code> and <code class="docutils literal notranslate"><span class="pre">domain_name</span></code> from the server table) pingable?</dd>
</dl>
</dd>
<dt><strong>Traffic Router Check - RTR</strong></dt>
<dd>Checks the state of each cache as perceived by all Traffic Monitors (via Traffic Router). This extension asks each Traffic Router for the state of the cache. A check failure is indicated if one or more monitors report an error for a cache. A cache is only marked as good if all reports are positive. (This is a pessimistic approach, opposite of how TM marks a cache as up, “the optimistic approach”)</dd>
</dl>
</div>
<div class="section" id="configuration-extensions">
<h3>Configuration Extensions<a class="headerlink" href="#configuration-extensions" title="Permalink to this headline"></a></h3>
<p>NOTE: Config Extensions are Beta at this time.</p>
</div>
<div class="section" id="data-source-extensions">
<h3>Data Source Extensions<a class="headerlink" href="#data-source-extensions" title="Permalink to this headline"></a></h3>
<p>Traffic Ops has the ability to load custom code at runtime that allow any CDN user to build custom APIs for any requirement that Traffic Ops does not fulfill. There are two classes of Data Source Extensions, private and public. Private extensions are Traffic Ops extensions that are not publicly available, and should be kept in the /opt/traffic_ops_extensions/private/lib. Public extensions are Traffic Ops extensions that are Open Source in nature and free to enhance or contribute back to the Traffic Ops Open Source project and should be kept in /opt/traffic_ops/app/lib/Extensions.</p>
</div>
<div class="section" id="extensions-at-runtime">
<h3>Extensions at Runtime<a class="headerlink" href="#extensions-at-runtime" title="Permalink to this headline"></a></h3>
<p>The search path for extensions depends on the configuration of the PERL5LIB, which is preconfigured in the Traffic Ops start scripts. The following directory structure is where Traffic Ops will look for Extensions in this order.</p>
</div>
<div class="section" id="extension-directories">
<h3>Extension Directories<a class="headerlink" href="#extension-directories" title="Permalink to this headline"></a></h3>
<p>PERL5LIB Example Configuration:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">export</span> <span class="n">PERL5LIB</span><span class="o">=/</span><span class="n">opt</span><span class="o">/</span><span class="n">traffic_ops_extensions</span><span class="o">/</span><span class="n">private</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">Extensions</span><span class="p">:</span><span class="o">/</span><span class="n">opt</span><span class="o">/</span><span class="n">traffic_ops</span><span class="o">/</span><span class="n">app</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">Extensions</span><span class="o">/</span><span class="n">TrafficStats</span>
</pre></div>
</div>
</div>
<div class="section" id="perl-package-naming-convention">
<h3>Perl Package Naming Convention<a class="headerlink" href="#perl-package-naming-convention" title="Permalink to this headline"></a></h3>
<p>To prevent Extension namespace collisions within Traffic Ops all Extensions should follow the package naming convention below:</p>
<p>Extensions::&lt;ExtensionName&gt;</p>
<p>Data Source Extension Perl package name example
Extensions::TrafficStats
Extensions::YourCustomExtension</p>
</div>
<div class="section" id="trafficopsroutes-pm">
<h3>TrafficOpsRoutes.pm<a class="headerlink" href="#trafficopsroutes-pm" title="Permalink to this headline"></a></h3>
<p>Traffic Ops accesses each extension through the addition of a URL route as a custom hook. These routes will be defined in a file called TrafficOpsRoutes.pm that should live in the top directory of your Extension. The routes that are defined should follow the Mojolicious route conventions.</p>
</div>
<div class="section" id="development-configuration">
<h3>Development Configuration<a class="headerlink" href="#development-configuration" title="Permalink to this headline"></a></h3>
<p>To incorporate any custom Extensions during development set your PERL5LIB with any number of directories with the understanding that the PERL5LIB search order will come into play, so keep in mind that top-down is how your code will be located. Once Perl locates your custom route or Perl package/class it ‘pins’ on that class or Mojo Route and doesn’t look any further, which allows for the developer to <em>override</em> Traffic Ops functionality.</p>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="traffic_portal.html" class="btn btn-neutral float-right" title="Traffic Portal">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="building.html" class="btn btn-neutral" title="Building Traffic Control"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions">
<span class="rst-current-version" data-toggle="rst-current-version">
<span class="fa fa-book">Apache Traffic Control (Incubating)</span>
v:
<span class="fa fa-caret-down"></span>
</span>
<div class="rst-other-versions">
<dl>
<dt>Versions</dt>
<dd><a href="/docs/master/">latest</a></dd>
<dd><a href="/docs/2.0/">2.0</a></dd>
<dd><a href="/docs/1.8.1/">1.8</a></dd>
<dd><a href="/docs/1.7.0/">1.7</a></dd>
</dl>
<hr/>
Free document hosting provided by <a href="http://www.readthedocs.org">Read the Docs</a>.
</div>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'2.2-dev',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>