{% extends "base_status.html" %}

{% block title %}Error{% endblock %}
{% block smallheader %}{% endblock %}
{% block largeheader %}Oh no, something went wrong ☹{% endblock %}

{% block nav1 %}{{ block.super }}{% endblock %}
{% load adagiostags %}

{% block content %}

    <div id="friendly_livestatus_message" class=hide>
        {% if not nagios_running %}
            We can't find a running nagios instance. Make sure nagios is running and adagios can connect to it.
            <ul>
                <li>
                    check that nagios is in fact running, if sudoers.d is correctly configured, you can start it <a href="{% url misc.views.nagios_service %}">here</a>
                </li>
                <li>
                    Please verify your <a href="{% url misc.views.settings %}">settings</a> and check all paths are valid.
                </li>

            </ul>
        {% endif %}
        {% if nagios_running and not num_problems %}
            Adagios cannot connect to livestatus. Don't worry, you can still use the other parts of Adagios,
            but to get the status part to work check the following:
            <ul>
                <li>Is <a href="http://mathias-kettner.de/checkmk_livestatus.html">mk-livestatus</a> installed ?</li>
                <li>Does <a href="{% url objectbrowser.views.edit_nagios_cfg %}">nagios.cfg</a> have a broker_module= line that loads mk-livestatus ?</li>
                <li>Are there any errors related to livestatus in  <a href="{% url status.views.status_log %}?search=livestatus">nagios logfiles</a> ?</li>
            </ul>

            Install instructions for rpm-based systems:
            <pre>
yum --enablerepo=ok-testing install mk-livestatus
pynag config --append "broker_module=/usr/lib64/mk-livestatus/livestatus.o /var/spool/nagios/cmd/livestatus"
service nagios reload
            </pre>
            Install instructions for debian-based systems:
            <pre>
apt-get install check-mk-livestatus
pynag config --append "broker_module=/usr/lib/check_mk/livestatus.o /var/lib/nagios3/rw/livestatus"
service nagios3 reload
            </pre>
        {% endif %}
        <hr>
    </div>


    {% if exception %}
        <div id="error_message" class="alert alert-danger">
            <b>{{ exception_type }}</b>: {{ exception }}
        </div>
    {% endif %}


    <button id="debug_button" class="btn" onclick="$('#traceback').toggle(); $('#debug_button').toggle();">show debug information</button>
    <div id="traceback" class="hide">
        {% if traceback %}
            <p>If you think this is a bug. Send the following information to the <a href="https://github.com/opinkerfi/adagios/issues">developers</a>:</p>
            <pre>{{ traceback }}</pre>
        {% endif %}
    </div>
{% endblock %}

{% block toolbar %} {% endblock %}

{% block footer %}
    {{ block.super }}
    <script>
        $(document).ready(function() {
            var error = $('#error_message').text();
            if ( error.search("livestatus") > 0) { $('#friendly_livestatus_message').show(); }
        });
    </script>
{% endblock %}
