MediaWiki:Common.css
Nota: Após publicar, você pode ter que limpar o "cache" do seu navegador para ver as alterações.
- Firefox / Safari: Pressione Shift enquanto clica Recarregar, ou pressione Ctrl-F5 ou Ctrl-R (⌘-R no Mac)
- Google Chrome: Pressione Ctrl-Shift-R (⌘-Shift-R no Mac)
- Edge: Pressione Ctrl enquanto clica Recarregar, ou pressione Ctrl-F5.
- Opera: Pressione Ctrl-F5.
function atualizarStatus(host, elementId) {
fetch('/noc/status.php?host=' + host)
.then(function(response) {
return response.json();
})
.then(function(data) {
var el = document.getElementById(elementId);
if (!el) return;
var html = '';
if (data.status === "online") {
html = "🟢 Operacional<br>" +
"<small>Uptime: " + formatUptime(data.uptime) + "</small><br>" +
"<small>Último check: " + (data.lastcheck ? data.lastcheck : '-') + "</small>";
el.classList.remove("blink");
} else if (data.status === "offline") {
html = "🔴 Offline<br>" +
"<small>Último check: " + (data.lastcheck ? data.lastcheck : '-') + "</small>";
el.classList.add("blink");
} else {
html = "🟡 Indefinido";
}
el.innerHTML = html;
})
.catch(function() {
var el = document.getElementById(elementId);
if (el) {
el.innerHTML = "🟡 Erro";
}
});
}
function formatUptime(seconds) {
if (!seconds || seconds <= 0) return '-';
var days = Math.floor(seconds / 86400);
var hours = Math.floor((seconds % 86400) / 3600);
var minutes = Math.floor((seconds % 3600) / 60);
return days + "d " + hours + "h " + minutes + "m";
}
function atualizarTodos() {
atualizarStatus("web01", "web01-status");
atualizarStatus("web02", "web02-status");
atualizarStatus("web03", "web03-status");
atualizarStatus("web04", "web04-status");
atualizarStatus("ns1", "ns1-status");
atualizarStatus("ns2", "ns2-status");
}
document.addEventListener("DOMContentLoaded", function () {
atualizarTodos();
setInterval(atualizarTodos, 30000);
});