diagnostico: add uptime
Signed-off-by: Rodrigo Martins <rodrigo@martinsevieira.adv.br>
This commit is contained in:
1 parent
6c048a0045
commit
1dea1f8c6f
2 files changed
+32
No files matched your search
@@ -1215,6 +1215,9 @@ Digite /help para ver todos os comandos disponíveis!
|
||||
msg += ` 📍 Slot/PON: ${onuResult.slot || '?'}/${onuResult.pon || '?'}\n`;
|
||||
}
|
||||
msg += ` 🔌 Estado: ${onuResult.online ? '🟢 Online' : '🔴 Offline'}\n`;
|
||||
if (onuResult.uptime) {
|
||||
msg += ` ⏱️ Uptime: ${onuResult.uptime}\n`;
|
||||
}
|
||||
msg += ` ${rxEmoji} Rx Power: *${rxLabel}*\n`;
|
||||
|
||||
if (onuResult.portaEthernet) {
|
||||
@@ -1423,6 +1426,7 @@ Digite /help para ver todos os comandos disponíveis!
|
||||
pon: resultado.pon,
|
||||
onuId: resultado.onuId,
|
||||
online: resultado.online,
|
||||
uptime: resultado.uptime || null,
|
||||
rxPower,
|
||||
txPower: resultado.txPower !== 'N/A' ? resultado.txPower : null,
|
||||
portaEthernet: portaEthernetStr
|
||||
|
||||
@@ -613,6 +613,7 @@ class FiberhomeManager {
|
||||
pon: 'N/A',
|
||||
onuId: 'N/A',
|
||||
online: false,
|
||||
uptime: null,
|
||||
rxPower: 'N/A',
|
||||
txPower: 'N/A',
|
||||
distance: 'N/A',
|
||||
@@ -681,6 +682,33 @@ class FiberhomeManager {
|
||||
} else if (/\b(DOWN|Power-Off|LOS)\b/i.test(dados)) {
|
||||
resultado.online = false;
|
||||
}
|
||||
|
||||
// Extrair LASTONTIME e calcular uptime
|
||||
// Formato: "YYYY-MM-DD HH:MM:SS" ou "YYYY-MM-DD HH-MM-SS" (UTC+8 / Beijing)
|
||||
const lastonMatch = dados.match(/LASTONTIME[\s\S]{0,80}?(\d{4}-\d{2}-\d{2}[\s]\d{2}[:\-]\d{2}[:\-]\d{2})/i);
|
||||
if (lastonMatch) {
|
||||
try {
|
||||
// Normalizar separadores de tempo para ":"
|
||||
const normalizado = lastonMatch[1].replace(/(\d{2})-(\d{2})-(\d{2})$/, '$1:$2:$3');
|
||||
// UNM2000 usa horário de Beijing (UTC+8) por padrão
|
||||
const dtOnline = new Date(normalizado + '+08:00');
|
||||
const diffMs = Date.now() - dtOnline.getTime();
|
||||
if (!isNaN(dtOnline.getTime()) && diffMs >= 0) {
|
||||
const totalMin = Math.floor(diffMs / 60000);
|
||||
const dias = Math.floor(totalMin / 1440);
|
||||
const horas = Math.floor((totalMin % 1440) / 60);
|
||||
const mins = totalMin % 60;
|
||||
resultado.uptime = dias > 0
|
||||
? `${dias}d ${String(horas).padStart(2,'0')}:${String(mins).padStart(2,'0')}`
|
||||
: `${String(horas).padStart(2,'0')}:${String(mins).padStart(2,'0')}`;
|
||||
console.log(`[TL1-DIAG] ✅ LASTONTIME="${lastonMatch[1]}" → uptime="${resultado.uptime}"`);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(`[TL1-DIAG] ⚠️ Falha ao calcular uptime: ${e.message}`);
|
||||
}
|
||||
} else {
|
||||
console.log('[TL1-DIAG] ⚠️ LASTONTIME não encontrado na resposta LST-ONUSTATE');
|
||||
}
|
||||
}
|
||||
|
||||
// Processar LST-OMDDM (potência ótica)
|
||||
|
||||
Reference in new issue
Block a user