{% extends "base_misc.html" %}

{% block title %}Nagios Service{% endblock %}
{% block smallheader %}{% endblock %}
{% block largeheader %}Nagios Service is <b> {{ friendly_status }}</b>{% endblock %}
{% block nav1 %}Nagios Service{% endblock %}

{% block adagios_hausinn %}{{ block.super }}{% endblock %}

{% block content %}


    {% if form %}
        <form action="#" method="post" class="form-horizontal">{% csrf_token %}
            {% if status == 0 %}
                <button class="btn btn-success" type="submit" name="reload">Reload</button>
                <button class="btn " type="submit" name="stop">Stop</button>
                <button class="btn " type="submit" name="restart">Restart</button>
            {% endif %}
            {% if status == 1 %}
                <button class="btn btn-success" type="submit" name="start">Start</button>
            {% endif %}
            {% if status > 1 %}
                <button class="btn btn-success" type="submit" name="start">Start</button>
                <button class="btn " type="submit" name="stop">Stop</button>
                <button class="btn " type="submit" name="restart">Restart</button>
                <button class="btn" type="submit" name="reload">Reload</button>
            {% endif %}
            <button class="btn " type="submit" name="status">Status</button>
             <button class="btn " type="submit" name="verify">Verify</button>
        </form>
    {% else %}
        No form found
    {%  endif %}



    {% if command %}
        <div >
            Executing <b>nagios {{ command }}</b>
            {% if stderr %}
                <h4>Errors</h4>
                <pre>{{ stderr }}</pre>
            {% endif %}

            {% if stdout %}
                <pre>{{ stdout }}</pre>
            {% endif %}
        </div>

        {% if not stdout and not stderr %}
            <div class="alert alert-danger">
                <p>
                    Something does not smell right. We ran {{ command }} and got no output.
                    Usually when this happens there is a problem with sudoers configuration.
                </p>
                <p>
                    Inspect webserver apache log and check if there are any sudo errors.
                    Your <a>/etc/sudoers.d/adagios</a> should have something like this:
                </p>
            <pre>
                Defaults:{{ local_user }}    !requiretty
                {{ local_user }} ALL = (root) NOPASSWD: /etc/init.d/nagios3
            </pre>
            </div>
        {% endif %}

    {% endif %}

    <hr>
    <div>Nagios Service is <b>{{ friendly_status }}</b>.</div>

{% endblock %}


{% block toolbar %}
{% endblock %}


{% block header %} {{ block.super }} {% endblock %}

{% block sidebar %}
    <h5>Diagnostics</h5>
        <div>Nagios Service is {{ friendly_status }}.</div>

{% endblock %}

{% block footer %} {{ block.super }} {% endblock %}