You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
haproxy-wi/app/templates/hapservers.html

336 lines
12 KiB

{% extends "base.html" %}
{% block content %}
{% from 'include/input_macros.html' import input, checkbox, select, copy_to_clipboard %}
<script src="/inc/overview.js"></script>
{% if serv %}
<style>
@media (max-width: 1280px) {
.div-pannel {
height: 430px !important;
}
}
</style>
{% endif %}
<style>
.alert-danger {
width: 250px;
display: inline-block;
height: 15px;
padding-top: 0px;
padding-bottom: 8px;
margin-bottom: -20px !important;
}
.ui-checkboxradio-label {
padding-bottom: 5px !important;
padding-top: 5px !important;
}
</style>
<script>
var ip = []
var hostnamea = []
{% for s in servers %}
ip.push("{{s[2]}}")
var host = "{{s[2]}}"
host = host.replace(/\./g, '\\.');
hostnamea.push(host)
{% endfor %}
$( function() {
$( ".sortable" ).sortable({
revert: true,
placeholder: "ui-state-highlight"
});
$( ".sortable" ).disableSelection();
$( ".sortable" ).sortable({
stop: function(event, ui) {
var itemOrder = $('.sortable').sortable("toArray");
for (var i = 0; i < itemOrder.length; i++) {
var pos = i;
var id = itemOrder[i].split('-')[2]
change_pos(pos, id);
}
}
});
{% for s in services %}
{% if s.1 == '* is not installed' or s.1 == '' %}
{% if s.0 == 'checker_haproxy' %}
$(':regex(id, alert)').checkboxradio('disable');
{% elif s.0 == 'keep_alive' %}
$(':regex(id, active-)').checkboxradio('disable');
{% elif s.0 == 'metrics_haproxy' %}
$(':regex(id, metrics-)').checkboxradio('disable');
{% endif %}
{% endif %}
{% endfor %}
});
</script>
{% if serv %}
<div id="up-pannel">
{% else %}
<div id="up-pannel" class="sortable">
{% endif %}
{% if servers|length == 0 %}
{% include 'include/getstarted.html' %}
{% endif %}
{% for s in servers %}
{% if serv %}
<link href="/inc/chart.min.css" rel="stylesheet">
<script src="/inc/metrics.js"></script>
<script src="/inc/chart.min.js"></script>
<script>
var server_ip = '{{s.2}}'
function showMetrics() {
{% if service == 'haproxy' %}
{% for s in servers %}
getChartData(server_ip)
getHttpChartData(server_ip)
getWafChartData(server_ip)
{% endfor %}
{% endif %}
showOverviewServer('{{s.1}}', server_ip, '{{s.0}}', '{{service}}');
{% if service == 'nginx' %}
showNginxConnections(server_ip)
{% elif service == 'haproxy' %}
showBytes(server_ip)
{% endif %}
}
showMetrics();
$( function() {
$("#time-range").on('selectmenuchange', function () {
removeData()
let metrics = new Promise(
(resolve, reject) => {
{% for s in servers %}
getChartData(server_ip)
getHttpChartData(server_ip)
getWafChartData(server_ip)
{% endfor %}
});
metrics.then();
});
});
</script>
{% endif %}
{% if service == 'nginx' %}
{% set checker_desc = 'Checker monitors Nginx services. If Nginx service is down, Checker will alert via Telegram' %}
{% set is_auto_start_enabled = s.8.0.17 %}
{% set is_checker_enabled = s.8.0.19 %}
{% if s.5.0.1 == 'active' %}
{% set additional_status_class = 'div-server-head-up' %}
{% else %}
{% set additional_status_class = 'div-server-head-down' %}
{% endif %}
{% elif service == 'keepalived' %}
{% if s.5.0.1 == 'active' %}
{% set additional_status_class = 'div-server-head-up' %}
{% else %}
{% set additional_status_class = 'div-server-head-down' %}
{% endif %}
{% elif service == 'haproxy' %}
{% set checker_desc = 'Checker monitors HAProxy services and its backends. If some backend or HAProxy service is down, Checker will alert via Telegram' %}
{% set is_auto_start_enabled = s.8.0.12 %}
{% set is_checker_enabled = s.8.0.8 %}
{% if s.5 != False %}
{% set additional_status_class = 'div-server-head-up' %}
{% else %}
{% set additional_status_class = 'div-server-head-down' %}
{% endif %}
{% endif %}
<div id="div-server-{{s.0}}" class="div-server-hapwi {{additional_status_class}}" {% if not serv %}style="cursor: move;"{%endif%}>
<div class="server-name">
<input type="hidden" id="server-name-{{s.0}}" value="{{s.1}}" />
<input type="hidden" id="service" value="{{service}}" />
{% if service == 'nginx' or service == 'keepalived' %}
{% if s.5.0.1 == 'active' %}
<span class="serverUp server-status" title="Uptime: {{s.5.0.4}}"></span>
{% else %}
<span class="serverDown server-status" title="Downtime: : {{s.5.0.4}}"></span>
{% endif %}
{% else %}
{% if s.5 != False %}
<span class="serverUp server-status" title="{{s.5.0.2}}"></span>
{% else %}
<span class="serverDown server-status" title="HAProxy is down"></span>
{% endif %}
{% endif %}
{% if not serv %}
<a href="/app/hapservers.py?service={{service}}&serv={{s.2}}" title="More about {{s.1}}" style="color: #5d9ceb">{{s.1}}</a>
{% else %}
{{s.1}}
{% endif %}
{% if s.6|int() >= 1 and service != 'keepalived' %}
<span
{% if keep_alive|int() >= 1 %}
class="shield green" title="Auto start enabled">
{% else %}
class="shield red" title="Auto start enabled, but keep alive service does not work">
{% endif %}
</span>
{% endif %}
{% if s.8.0.20 == 1 %}
<span class="lock" title="This server is inaccessible for editing by everyone except the admin role"></span>
{% endif %}
{% if role <= 2 %}
<span class="server-action">
{% if service == 'nginx' %}
{% set action_service = 'nginx' %}
{% elif service == 'keepalived' %}
{% set action_service = 'keepalived' %}
{% else %}
{% set action_service = 'hap' %}
{% endif %}
<a id="start-{{ s.2 }}" class="start" title="Start {{service}} service">
<span class="service-start" onclick="confirmAjaxAction('start', '{{action_service}}', '{{s.2}}')"></span>
</a>
<a id="reload-{{ s.2 }}" class="reload" title="Reload {{service}} service">
<span class="service-reload" onclick="confirmAjaxAction('reload', '{{action_service}}', '{{s.2}}', '{{s.1}}')"></span>
</a>
<a id="restart-{{ s.2 }}" class="restart" title="Restart {{service}} service">
<span class="service-reload service-restart" onclick="confirmAjaxAction('restart', '{{action_service}}', '{{s.2}}')"></span>
</a>
<a id="stop-{{ s.2 }}" class="stop" title="Stop {{service}} service">
<span class="service-stop" onclick="confirmAjaxAction('stop', '{{action_service}}', '{{s.2}}')"></span>
</a>
</span>
{% endif %}
</div>
<div class="server-desc">
{{s.3}}
<br />
{% if service == 'nginx' or service == 'keepalived' %}
Version: {{s.5.0.0}} Process_num: {{s.5.0.3}}
<br />
{% if s.5.0.1 == 'active' %}
Uptime:
{% else %}
Downtime:
{% endif %}
{{s.5.0.2}}
{% else %}
{% if s.5.0 is defined %}
{{s.5.0.0}} {{s.5.0.1}}
<br />
{{s.5.0.2}}
{% else %}
Cannot get information about HAProxy
{% endif %}
{% endif %}
<span title="Date of last configuration edit">
Last edit:
<span id="edit_date_{{s.2}}"></span>
</span>
<br />
IP: {{ copy_to_clipboard(value=s.2, style='font-weight: bold') }}
{% if s.7.0.0 != None %}
Master for: <b>{{ s.7.0.1 }}</b>
{% endif %}
{% if s.9.0 == '1' %}
VRRP status: <b>
{% if s.9.1 == 'MASTER' or s.9.1 == 'BACKUP' or s.9.1 == 'INIT' or s.9.1 == 'FAULT' %}
{{s.9.1}}
{% else %}
<span title="Cannot get Keepalived Status" class="help_cursor">Error</span>
{% endif %}
</b>
{% endif %}
</div>
<div class="server-act-links" id="server-{{s.8.0.0|string()}}-{{service}}">
{% if role <= 2 and service != 'keepalived' %}
{% set id = 'alert-' + s.8.0.0|string() %}
{% if is_checker_enabled == 1 %}
{{ checkbox(id, title=checker_desc, value='1', desc='Checker', checked='checked') }}
{% else %}
{{ checkbox(id, title=checker_desc, value='1', desc='Checker') }}
{% endif %}
{% if service == 'haproxy' %}
{% set id = 'metrics-' + s.8.0.0|string() %}
{% if s.8.0.9 == 1 %}
{{ checkbox(id, title='Collecting metrics is enabled', value='1', desc='Metrics', checked='checked') }}
{% else %}
{{ checkbox(id, title='Enable collecting metrics', value='1', desc='Metrics') }}
{% endif %}
{% endif %}
{% set id = 'active-' + s.8.0.0|string() %}
{% if is_auto_start_enabled == 1 %}
{{ checkbox(id, title='Auto Start is enabled', value='1', desc='Auto Start', checked='checked') }}
{% else %}
{{ checkbox(id, title='Enable Auto Start', value='1', desc='Auto Start') }}
{% endif %}
{% endif %}
</div>
<div class="server-act-links">
{% if service != 'keepalived' %}
<a href="/app/config.py?service={{service}}&serv={{s.2}}&showConfig" class="ui-button ui-widget ui-corner-all" title="Open running config">Config</a>
{% else %}
<a href="/app/config.py?service={{service}}" class="ui-button ui-widget ui-corner-all" title="Edit running config">Config</a>
{% endif %}
<a href="/app/config.py?service={{service}}&serv={{s.2}}&showCompare" class="ui-button ui-widget ui-corner-all" title="Compare configs">Compare</a>
{% if service != 'nginx' and service != 'keepalived' %}
<a href="/app/config.py?serv={{s.2}}&showMap" class="ui-button ui-widget ui-corner-all" title="Show map">Map</a>
{% endif %}
{% if service != 'keepalived' %}
<a href="/app/viewsttats.py?service={{service}}&serv={{s.2}}" class="ui-button ui-widget ui-corner-all" title="View {{service}} statistics">Stat</a>
<a href="/app/logs.py?service={{service}}&serv={{s.2}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" class="ui-button ui-widget ui-corner-all" title="View {{service}} log">Log</a>
{% endif %}
{% if role <= 2 %}
<a href="/app/versions.py?service={{service}}&serv={{s.2}}&open=open" class="ui-button ui-widget ui-corner-all" title="View/Rollback to previous config">Versions</a>
{% endif %}
</div>
</div>
{% if serv %}
<div id="bin_bout"></div>
<div id="ajax-server-{{s.0}}" class="ajax-server"></div>
<div class="div-server div-backends">
<div class="server-name backends">
{% if service == 'haproxy' %}
Backends:
{% elif service == 'keepalived' %}
VRRP addresses:
{% else %}
Virtual hosts:
{% endif %}
</div>
<div style="margin-top: 10px;" id="top-{{s.2}}"></div>
</div>
{% endif %}
{% endfor %}
</div>
{% if serv and service == 'haproxy' %}
<div style="clear: both; width: 95%;">
<div style="padding-left: 25px;float: left;margin-top: -15px;">
<b>Time range:</b>
<select title="Choose time range" id="time-range">
<option value="30">30 minutes</option>
<option value="60">1 hour</option>
<option value="180">3 hours</option>
<option value="360">6 hours</option>
<option value="720">12 hours</option>
</select>
</div>
<div id="refresh" style="text-align: right;margin-right: 3%;" title="Refresh metrics" onclick="showMetrics()">
<span class="service-reload"></span>
</div>
</div>
{% for s in servers %}
<div id="server_metrics_div" class="chart-container" style="display: block; width: 91.3%; height: 300px;">
<canvas id="{{s.2}}" role="img"></canvas>
</div>
<div id="http_metrics_div" class="chart-container" style="display: block; width: 91.3%; height: 300px;">
<canvas id="http_{{s.2}}" role="img"></canvas>
</div>
<div id="waf_metrics_div" class="chart-container" style="display: block; width: 90%; height: 300px;">
<canvas id="s_{{s.2}}" role="img"></canvas>
</div>
{% endfor %}
{% endif %}
<div id="dialog-confirm" style="display: none;">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:3px 12px 20px 0;"></span>Are you sure?</p>
</div>
<script>
{% if serv %}
overviewHapserverBackends(ip, hostnamea, '{{service}}');
{% endif %}
showHapservers(ip, hostnamea, '{{service}}');
</script>
{% endblock %}