{% extends "layout.html" %}

{% block body %}
    <form method="POST">
        <table>
            <tr>
                <th>Hostname</th>
                <th>IP</th>
                <th>Port</th>
                <th>Uptime</th>
                <th>PID</th>
                <th>Version</th>
                <th>Workers</th>
                <th>Load</th>
                <th>Actions</th>
            </tr>
            {% for addr, master in sockets|dictsort(by='value') %}
            <tr>
                <td>{{ master.stats.hostname }}</td>
                <td>{{ addr[0] }}</td>
                <td>{{ addr[1] }}</td>
                <td>{{ human_time(master.stats.uptime) }}</td>
                <td>
                    <a href="{{ url_for('workers', ppid=master.stats.pid) }}">
                        {{ master.stats.pid }}
                    </a>
                </td>
                <td>{{ master.stats.version }}</td>
                <td>{{ master.stats.workers }}</td>
                <td>
                    {% for l in master.stats.load -%}
                        {{ l|round(2) }}
                    {% endfor %}
                </td>
                <td>
                    {{ action_button(addr, 'warm_shutdown', 'Warm Shutdown') }}
                    {{ action_button(addr, 'cold_shutdown', 'Cold Shutdown') }}
                    {{ action_button(addr, 'abort', 'Abort') }}
                </td>
            </tr>
            {% endfor %}
            <tr>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td>
                    {{ action_button_all('master', 'warm_shutdown', 'Warm Shutdown All') }}
                    {{ action_button_all('master', 'cold_shutdown', 'Cold Shutdown All') }}
                    {{ action_button_all('master', 'abort', 'Abort All') }}
                </td>
            </tr>
        </table>
        Count: {{ sockets|count }}
    </form>
{% endblock %}
