{% extends "template.html" %}

{% block title %}Index{% endblock %}
{% block head %}
{{ super() }}
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="http://codeorigin.jquery.com/jquery-2.0.3.min.js"></script>
{% endblock %}

{% block content %}
<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="navbar">
        <div class="container">

          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">Livestatus-service</a>
          <div class="nav-collapse collapse">
            <ul class="nav navbar-nav">
              <li><a target=_new href="http://github.com/ImmobilienScout24/livestatus_service/issues/new">Submit an issue</a></li>
              <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Useful links<b class="caret"></b></a>
                <ul class="dropdown-menu">
                  <li><a target=_new href="http://github.com/ImmobilienScout24/livestatus_service">About</a></li>
                  <li><a target=_new href="http://mathias-kettner.de/checkmk_livestatus.html">MK livestatus</a></li>
                  <li><a target=_new href="http://docs.icinga.org/latest/en/extcommands2.html">External commands in icinga</a></li>
                </ul>
              </li>
            </ul>
          </div><!--/.nav-collapse -->
        </div>
</div>

  <div class="jumbotron">
    <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="col-lg-6">
        <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 />
        </p>
        <h4>Example</h4>
          <a href="/query?q=GET%20hosts"><code>/query?q=GET%20hosts</code></a>
          <p>If you need newlines, e.G. to add a filter, use <code>\n</code>.</p>
   </div>
   <div class="col-lg-6">
        <h2>Performing commands</h2>
        <h3>Basics</h3>
  </div>
        <div class="col-lg-3">
        <h4> GET </h4>
        <p>
          <code>GET /cmd?q=<em>COMMAND</em></code>
        </p>
        </div>
        <div class="col-lg-3">
        <h4> POST </h4>
        <p>
          <code>POST /cmd {q: <em>COMMAND</em>}</code>
        </p>
        </div>
    <div class="col-lg-6">
        <p>
          Will perform a command using <em>COMMAND</em>.<br />
          The <code>COMMAND [%s]</code> directive will be inserted for you.<br />
        </p>
        <h4>Example</h4>
    </div>
    <div class="col-lg-6">
    </div>
      <div class="col-lg-3">
          <h5> GET </h5>
          <a href="/cmd?q=ENABLE_HOST_NOTIFICATIONS;devica01"> <code style="display:block">/cmd?q=ENABLE_<br/>HOST_NOTIFICATIONS;devica01</code></a><br/>
      </div>
      <div class="col-lg-3">
          <h5> POST </h5>
          <form action="/cmd" method="post" class="form-signin">
          <input type="text" class="input-block-level" name="q" value="ENABLE_HOST_NOTIFICATIONS;devica01">
                  <button class="btn" type="submit">Run</button>

          </form>
      </div>
  </div>

  <div class="row-fluid-marketing">
    <div class="col-lg-6">
              <a class="btn btn-primary btn-large" href="http://mathias-kettner.de/checkmk_livestatus.html#H1:LQL%20-%20The%20Livestatus%20Query%20Language">Refer to the LQL documentation</a>
    </div>
    <div class="col-lg-6">
         <a class="btn btn-primary btn-large" href="http://docs.icinga.org/latest/en/extcommands2.html">Refer to the list of external commands</a>
    </div>
  </div>

  <div class="row-fluid marketing">
    <div class="col-lg-6">
        <h3>
          Advanced queries
        </h3>
        <h4>
          Default output format
        </h4>
        <p>
          By default you will receive a list of dictionaries, where each dictionary represent a row.
        </p>
        <h4>Example</h4>
        <p>
          <a href="/query?q=GET%20hosts\nColumns:%20host_name%20notifications_enabled">Query host_name and notifications_enabled</a><br/>
          This yields
          <pre>
            [{
                "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>
          Key-grouped 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/>
        </p>
        <h4>Example</h4>
        <p>
          <a href="/query?q=GET%20hosts\nColumns:%20host_name%20notifications_enabled&key=host_name">Query host_name and notifications_enabled with host_name as key</a><br/>
          This yields <br/>
          <pre>
            {
                "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="col-lg-6">
        <h3>Advanced commands</h3>
        <h4>Using another command handler</h4>
        <p>
          You can specify the <code>handler</code> argument to use a custom handler.<br/>
        </p>
        <h4>Example</h4>
        <p>
          <a href="/cmd?q=ENABLE_HOST_NOTIFICATIONS;devica01&handler=icinga" >Enable host notifications using the icinga handler</a><br/>
        </p>
        <h4>Available 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 id="footer">
<div class="container">
          <p class="text-muted credit">
            {{ super() }}
          </p>
</div>
</div>


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


