{% extends "template.html" %}

{% block title %}Index{% endblock %}
{% block head %}
{{ super() }}
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
{% endblock %}

{% block content %}

<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js?lang=yaml&skin=default"></script>
<a href="https://github.com/ImmobilienScout24/livestatus_service"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<div class="container">
  <div class="hero-unit">
    <h1>Livestatus-service</h1>
    <p class="lead">
      Livestatus-service exposes the functionality of a livestatus socket to the outside world over HTTP.
    </p>
  </div>
  <div class="row-fluid marketing">

    <div class="span6">
        <h2>Performing queries</h2>
        <h3>Basics</h3>
        <p>
          <code>GET /query?q=<em>QUERY</em></code>
        </p>
        <p>
          Will perform a query using <em>QUERY</em>.<br />
          Example : <a href="/query?q=GET%20hosts"><code>/query?q=GET%20hosts</code></a>
        </p>
        <p>
          If you need newlines, e.G. to add a filter, use <code>\n</code>.<br />
          <a href="/query?q=GET%20hosts\nColumns:%20host_name%20notifications_enabled\nFilter:%20host_name%20=%20devica01">Example : query notifications_enabled for host <em>devica01</em>.</a>
        </p>
        <p>
          See the <a href="http://mathias-kettner.de/checkmk_livestatus.html#H1:LQL%20-%20The%20Livestatus%20Query%20Language">LQL documentation</a> for more information.
        </p>
        <h3>
          Pretty query results
        </h3>
        <h4>
          Default output format
        </h4>
        <p>
          By default you will receive a list of dictionaries, where each dictionary represent a row.
          <a href="/query?q=GET%20hosts\nColumns:%20host_name%20notifications_enabled">Example : host_name and notifications_enabled</a><br/>
          The example yields
          <pre class="prettyprint lang-yaml">
            [{
                "notifications_enabled": "0",
                "host_name": "devica01"
            }, {
                "notifications_enabled": "1",
                "host_name": "tuvdbs05"
            }, {
                "notifications_enabled": "1",
                "host_name": "tuvdbs06"
            }, {
                "notifications_enabled": "1",
                "host_name": "tuvdbs50"
            }, {
                "notifications_enabled": "1",
                "host_name": "tuvmpc01"
            }, {
                "notifications_enabled": "1",
                "host_name": "tuvmpc02"
            }, {
                "notifications_enabled": "1",
                "host_name": "tuvrep01"
            }]
          </pre>
        </p>
        <h4>
          Custom output format
        </h4>
        <p>
          If you specify the <code>key</code> parameter, this column name will be used as a unique index for the rows and you will have a dictionary of dictionaries instead.<br/>
          <a href="/query?q=GET%20hosts\nColumns:%20host_name%20notifications_enabled&key=host_name">Example : host_name and notifications_enabled with host_name as key</a><br/>
          The example yields <br/>
          <pre class="prettyprint lang-yaml">
            {
                "devica01": {
                    "notifications_enabled": "0",
                    "host_name": "devica01"
                },
                "tuvrep01": {
                    "notifications_enabled": "1",
                    "host_name": "tuvrep01"
                },
                "tuvdbs06": {
                    "notifications_enabled": "1",
                    "host_name": "tuvdbs06"
                },
                "tuvdbs05": {
                    "notifications_enabled": "1",
                    "host_name": "tuvdbs05"
                },
                "tuvdbs50": {
                    "notifications_enabled": "1",
                    "host_name": "tuvdbs50"
                },
                "tuvmpc01": {
                    "notifications_enabled": "1",
                    "host_name": "tuvmpc01"
                },
                "tuvmpc02": {
                    "notifications_enabled": "1",
                    "host_name": "tuvmpc02"
                }
            }
          </pre>
        </p>
    </div>

    <div class="span6">
        <h2>Performing commands</h2>
        <h3>The command endpoint</h3>
        <p>
          <code>GET /cmd?q=<em>COMMAND</em></code>
        </p>
        <p>
          Will perform a command using <em>COMMAND</em>.<br />
          The <code>COMMAND [%s]</code> directive will be inserted for you.<br />
          Example : <a href="/cmd?q=ENABLE_HOST_NOTIFICATIONS;devica01"> <code>/cmd?q=ENABLE_HOST_NOTIFICATIONS;devica01</code></a>
        </p>
        <p>
          Refer to the <a href="http://docs.icinga.org/latest/en/extcommands2.html"> list of external commands</a> for more information.
        </p>
        <h3>Using another command handler</h3>
          You can specify the <code>handler</code> argument to use a custom handler.<br/>
          <a href="/cmd?q=ENABLE_HOST_NOTIFICATIONS;devica01&handler=icinga" >Example: enable host notifications using the icinga handler</a><br/>
        <h4>Currently implemented handlers</h4>
          <p>
            <table border="1">
              <tr>
                <th>Handler</th>
                <th>Effect</th>
              </tr>
              <tr>
                <td>livestatus (default)&nbsp;</td>
                <td>Uses the livestatus UNIX socket</td>
              </tr>
              <tr>
                <td>icinga</td>
                <td>Uses the configured icinga command file (commands only)</td>
              </tr>
            </table>
          </p>
    </div>

  </div>
</div>

{% endblock %}

{% block footer %}
<hr>
<div class="container">
  <div class="offset1 span5">
    {{ super() }}
  </div>
</div>

<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/js/bootstrap.min.js"></script>
{% endblock %}


