<!DOCTYPE html>
{% load staticfiles %}
<html>
<head>
    <title></title>
    <link rel="icon" href="{% static 'favicon_skull.ico' %}" type="image/x-icon">
    <link href="{% static 'css/themes-tablesorter/blue/style.css' %}" rel="stylesheet" />

    <script src="https://yandex.st/jquery/2.0.3/jquery.min.js" type="text/javascript"></script>
    <script src="{% static 'js/jquery.metadata.js' %}" type="text/javascript"></script>
    <script type="text/javascript" src="{% static 'js/jquery.tablesorter.min.js'%}"></script>
</head>
<script type='text/javascript'>
    $(document).ready(
		function() {
            try{
            $('#data').tablesorter({cancelSelection: false
                                    //    ,debug: true
            });
        } catch(err){
            alert(err);
        }
        }
    );
    function showDebug(){
        document.getElementById('debug_info').removeAttribute('hidden');
    }
</script>
<body>
<div>{% if ctype == 'stable' %}
    <span style='color:#8dbdd8;font-family:Arial;font-weight: bold'>stable</span>
    <a href="{% url 'golovan' %}?ctype=prestable" style='padding-left:20px;font-family:Arial;color:#8dbdd8'>prestable</a>
{% else %}
    <a href="{% url 'golovan' %}?ctype=stable" style='font-family:Arial;color:#8dbdd8'>stable</a>
    <span style='color:#8dbdd8;font-family:Arial;font-weight: bold;padding-left:20px'>prestable</span>
{% endif %}
<a href='https://wiki.yandex-team.ru/users/raspopova/метрики' style='padding-left:20px;font-family:Arial;color:#5f7f6b' target='_blank'>wiki</a>
</div>
{% if errors|length > 0 %}Errors: {{ errors }}<br>{% endif %}
<table class='tablesorter' id='data'>
    <thead>
    <tr>
        <th>Service</th>
        <th title='medium rps, for last 7 days'>Search rps</th>
        <th title='search requests percent with some docs found, for last 7 days'>Nonzero search %</th>
        <th title='max search rps for 5 minutes, for last 4 days'>Max rps</th>
        <th title='min search rps for 5 minutes, for last 4 days'>Min rps</th>

        <th title='cpu consumption, sum by hosts, medium by time, for last 7 days'>Cpu, %</th>
        <th title='memory (aka mem_size_real), summ by hosts, medium by time, for last 7 days'>Memory, Gb</th>
        <th title='replicas x slots = total (may be wrong if slots number in replica differs)'>Rep x slots</th>
        <th title='medium docs count per replica, instant value'>Replica docs</th>
        <th title='total index size, sum by hosts, instant value'>Index size, Gb</th>
        <th title='medium index rps, for last 7 days'>Index rps</th>
        <th title='max index rps for 5 minutes, for last 4 days'>Max ind rps</th>
        <th title='min index rps for 5 minutes, for last 4 days'>Min ind rps</th>
    </tr>
    </thead>
    <tbody>
    {% for d in data %}
        <tr>
        <td {% if d.search_rps == 0.0 and d.index_rps == 0.0 %}style='color: #ff9999;font-weight:bold'{% endif %}>{{ d.service }}</td>
        <td {% if d.search_rps == 0.0 and d.index_rps == 0.0 %}style='color: #ff9999;font-weight:bold'{% endif %}>{{ d.search_rps }}</td>
        <td>{{ d.nonzero_rps }}</td>
        <td>{{ d.max_rps }}</td>
        <td>{{ d.min_rps }}</td>

        <td>{{ d.cpu }}</td>
        <td>{{ d.memory }}</td>
        <td>{{ d.replicas }}</td>
        <td>{{ d.replica_docs }}</td>
        <td>{{ d.doc_size }}</td>
        <td {% if d.search_rps == 0.0 and d.index_rps == 0.0 %}style='color: #ff9999;font-weight:bold'{% endif %}>{{ d.index_rps }}</td>
        <td>{{ d.max_rps_ind }}</td>
        <td>{{ d.min_rps_ind }}</td>
        </tr>
    {% endfor %}
    </tbody>

</table>
<a onclick='showDebug()'>show debug</a>
<div id='debug_info' hidden>{{ debug_info }}</div>
</body>
</html>