Source
/*
** Zabbix
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
jQuery(function($) {
'use strict';
/**
* Object that sends ajax request for server status and show/hide warning messages.
*
* @type {Object}
*/
var ServerChecker = {
$elem: null,
elem_offset_top: 0,
delay: 10000, // 10 seconds
warning: false,
/**
* Function to start check server status via RPC call.
*
* @param {object} $elem General element.
* @param {integer} timeout Check rate.
*/
start: function($elem, timeout) {
if (!$elem.length) {
return false;
}
this.prepareNext(timeout);
this.$elem = $elem;
this.updateWidth();
this.$elem.on('mouseenter', this.hideMessage.bind(this));
$(window).on('resize', this.updateWidth.bind(this));
},
prepareNext: function(delay) {
setTimeout(this.check.bind(this), delay || this.delay);
},
/**
* Sends ajax request to get Zabbix server availability and message to show if server is not available.
*/
check: function() {
new RPC.Call({
'method': 'zabbix.status',