{% load i18n %}
{% if unavailable %}
    <h4>{% trans 'ERROR: uWSGI is not available!' %}</h4>
{% else %}


<div id="content-main" class="inline-related tabular">
    <div class="module">
    <h4>{% trans 'Status' %}</h4>
        <table>
            <thead>
                <tr>
                    <th>{% trans "Option" %}</th>
                    <th>{% trans "Value" %}</th>
                </tr>
            </thead>
            <tbody>
                {% for key, value in stats %}
                <tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}">
                    <td>{{ key }}</td>
                    <td>{{ value }}</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    <div class="module">
    <h4>{% trans 'Options' %}</h4>
        <table>
            <thead>
                <tr>
                    <th>{% trans "Option" %}</th>
                    <th>{% trans "Value" %}</th>
                </tr>
            </thead>
            <tbody>
                {% for key, value in options %}
                <tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}">
                    <td><a href="http://uwsgi-docs.readthedocs.org/en/latest/Options.html#{{ key }}">{{ key }}</a></td>
                    <td>{{ value }}</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>

    <div class="module balanced">
    <h4>{% trans 'Workers' %}</h4>
        <table>
            <thead>
                <tr>
                    <th>{% trans "id" %}</th>
                    <th>{% trans "pid" %}</th>
                    <th>{% trans "status" %}</th>
                    <th>{% trans "requests" %}</th>
                    <th>{% trans "exceptions" %}</th>
                    <th>{% trans "signals" %}</th>
                    <th>{% trans "running time(ms)" %}</th>
                    <th>{% trans "avg response time(ms)" %}</th>
                    <th>{% trans "load" %}</th>
                    <th>{% trans "last spawn" %}</th>
                    <th>{% trans "respawn count" %}</th>
                    <th>{% trans "address space (vsz)" %}</th>
                    <th>{% trans "resident memory (rss)" %}</th>
                </tr>
            </thead>
            <tbody>
            {% for w in workers %}
                <tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}">
                    <td>{{ w.id }}</td>
                    <td>{{ w.pid }}</td>
                    <td>{{ w.status }}</td>
                    <td>{{ w.requests }}</td>
                    <td>{{ w.exceptions }}</td>
                    <td>{{ w.signals }}</td>
                    <td>{{ w.running_time }}</td>
                    <td>{{ w.avg_rt }}</td>
                    <td>{{ w.load|floatformat:2 }} %</td>
                    <td>{{ w.last_spawn }}</td>
                    <td>{{ w.respawn_count }}</td>
                    <td>{{ w.vsz|filesizeformat }}</td>
                    <td>{{ w.rss|filesizeformat }}</td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
    <div class="module balanced">
        <h4>{% trans 'Applications' %}</h4>
        <table>
            <thead>
            <tr>
                <th>{% trans "#" %}</th>
                <th>{% trans "modifier1" %}</th>
                <th>{% trans "mountpoint" %}</th>
                <th>{% trans "interpreter" %}</th>
                <th>{% trans "callable" %}</th>
                <th>{% trans "chdir" %}</th>
                <th>{% trans "requests" %}</th>
                <th>{% trans "exceptions" %}</th>
            </tr>
            </thead>
            <tbody>
            {% for w in workers %}
                {% for app in w.apps %}
                    <tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}">
                        <td>{{ app.id }}</td>
                        <td>{{ app.modifier1 }}</td>
                        <td>{{ app.mountpoint }}</td>
                        <td>{{ app.interpreter }}</td>
                        <td>{{ app.callable }}</td>
                        <td>{{ app.chdir }}</td>
                        <td>{{ app.requests }}</td>
                        <td>{{ app.exceptions }}</td>
                    </tr>
                {% endfor %}
            {% endfor %}
            </tbody>
        </table>
    </div>
    <div class="module balanced">
    <h4>{% trans 'Spooler jobs' %}</h4>
        <table>

            <thead>
                <tr>
                    <th>job filename</th>
                    <th>environment</th>
                </tr>
            </thead>
            <tbody>
        {% for j in jobs %}
            <tr>
                <td align="left">{{ j.file }}</td>
                <td align="left">{{ j.env }}</td>
            </tr>
        {% endfor %}
            </tbody>
        </table>
    </div>

    {% if masterpid %}
    <div class="submit-row">
        <a href="{% url 'uwsgi_reload' %}">{% trans 'Gracefully reload uWSGI' %}</a>
        <a href="{% url 'uwsgi_cache_clear' %}">{% trans 'Clear uWSGI cache' %}</a>
    </div>
    {% endif %}

</div>


{% endif %}
