Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2be44d8b24 | |||
| 2d6dcd782f | |||
| a1a3a52dd8 | |||
| bcc2ad7f5c | |||
| d4f159ee7c | |||
| 61019418d3 | |||
| 1a53718cc5 | |||
| afaeb64636 |
@@ -182,7 +182,7 @@ def get_active_events(limit: int = 200, offset: int = 0) -> list:
|
|||||||
for r in rows:
|
for r in rows:
|
||||||
for k in ('first_seen', 'last_seen'):
|
for k in ('first_seen', 'last_seen'):
|
||||||
if r.get(k) and hasattr(r[k], 'isoformat'):
|
if r.get(k) and hasattr(r[k], 'isoformat'):
|
||||||
r[k] = r[k].isoformat()
|
r[k] = r[k].isoformat() + 'Z'
|
||||||
return rows
|
return rows
|
||||||
|
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ def get_recent_resolved(hours: int = 24, limit: int = 50) -> list:
|
|||||||
for r in rows:
|
for r in rows:
|
||||||
for k in ('first_seen', 'last_seen', 'resolved_at'):
|
for k in ('first_seen', 'last_seen', 'resolved_at'):
|
||||||
if r.get(k) and hasattr(r[k], 'isoformat'):
|
if r.get(k) and hasattr(r[k], 'isoformat'):
|
||||||
r[k] = r[k].isoformat()
|
r[k] = r[k].isoformat() + 'Z'
|
||||||
return rows
|
return rows
|
||||||
|
|
||||||
|
|
||||||
@@ -252,7 +252,7 @@ def get_active_suppressions() -> list:
|
|||||||
for r in rows:
|
for r in rows:
|
||||||
for k in ('created_at', 'expires_at'):
|
for k in ('created_at', 'expires_at'):
|
||||||
if r.get(k) and hasattr(r[k], 'isoformat'):
|
if r.get(k) and hasattr(r[k], 'isoformat'):
|
||||||
r[k] = r[k].isoformat()
|
r[k] = r[k].isoformat() + 'Z'
|
||||||
return rows
|
return rows
|
||||||
|
|
||||||
|
|
||||||
@@ -267,7 +267,7 @@ def get_suppression_history(limit: int = 50) -> list:
|
|||||||
for r in rows:
|
for r in rows:
|
||||||
for k in ('created_at', 'expires_at'):
|
for k in ('created_at', 'expires_at'):
|
||||||
if r.get(k) and hasattr(r[k], 'isoformat'):
|
if r.get(k) and hasattr(r[k], 'isoformat'):
|
||||||
r[k] = r[k].isoformat()
|
r[k] = r[k].isoformat() + 'Z'
|
||||||
return rows
|
return rows
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -78,7 +78,7 @@ class DiagnosticsRunner:
|
|||||||
f'ssh -o StrictHostKeyChecking=accept-new -o ConnectTimeout=5 '
|
f'ssh -o StrictHostKeyChecking=accept-new -o ConnectTimeout=5 '
|
||||||
f'-o BatchMode=yes -o LogLevel=ERROR '
|
f'-o BatchMode=yes -o LogLevel=ERROR '
|
||||||
f'-o ServerAliveInterval=10 -o ServerAliveCountMax=2 '
|
f'-o ServerAliveInterval=10 -o ServerAliveCountMax=2 '
|
||||||
f'root@{ip_q} \'{remote_cmd}\''
|
f'root@{ip_q} {shlex.quote(remote_cmd)}'
|
||||||
)
|
)
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|||||||
+9
-6
@@ -215,7 +215,10 @@ class TicketClient:
|
|||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
data = resp.json()
|
data = resp.json()
|
||||||
if data.get('success'):
|
if data.get('success'):
|
||||||
tid = data['ticket_id']
|
tid = data.get('ticket_id')
|
||||||
|
if not tid:
|
||||||
|
logger.warning(f'Ticket API success but no ticket_id in response: {data}')
|
||||||
|
return None
|
||||||
logger.info(f'Created ticket #{tid}: {title}')
|
logger.info(f'Created ticket #{tid}: {title}')
|
||||||
return tid
|
return tid
|
||||||
if data.get('existing_ticket_id'):
|
if data.get('existing_ticket_id'):
|
||||||
@@ -377,7 +380,7 @@ class LinkStatsCollector:
|
|||||||
f'ssh -o StrictHostKeyChecking=accept-new -o ConnectTimeout=5 '
|
f'ssh -o StrictHostKeyChecking=accept-new -o ConnectTimeout=5 '
|
||||||
f'-o BatchMode=yes -o LogLevel=ERROR '
|
f'-o BatchMode=yes -o LogLevel=ERROR '
|
||||||
f'-o ServerAliveInterval=10 -o ServerAliveCountMax=2 '
|
f'-o ServerAliveInterval=10 -o ServerAliveCountMax=2 '
|
||||||
f'root@{ip} "{shell_cmd}"'
|
f'root@{ip} {shlex.quote(shell_cmd)}'
|
||||||
)
|
)
|
||||||
output = self.pulse.run_command(ssh_cmd)
|
output = self.pulse.run_command(ssh_cmd)
|
||||||
if output is None:
|
if output is None:
|
||||||
@@ -786,7 +789,7 @@ class NetworkMonitor:
|
|||||||
f'Please inspect the cable/SFP/switch port for {host}/{iface}.'
|
f'Please inspect the cable/SFP/switch port for {host}/{iface}.'
|
||||||
)
|
)
|
||||||
tid = self.tickets.create(title, desc, priority='2')
|
tid = self.tickets.create(title, desc, priority='2')
|
||||||
if tid and is_new:
|
if tid:
|
||||||
db.set_ticket_id(event_id, tid)
|
db.set_ticket_id(event_id, tid)
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
@@ -828,7 +831,7 @@ class NetworkMonitor:
|
|||||||
f'Please check power and cable connectivity.'
|
f'Please check power and cable connectivity.'
|
||||||
)
|
)
|
||||||
tid = self.tickets.create(title, desc, priority='2')
|
tid = self.tickets.create(title, desc, priority='2')
|
||||||
if tid and is_new:
|
if tid:
|
||||||
db.set_ticket_id(event_id, tid)
|
db.set_ticket_id(event_id, tid)
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
@@ -870,7 +873,7 @@ class NetworkMonitor:
|
|||||||
f'Please check the host power, management interface, and network connectivity.'
|
f'Please check the host power, management interface, and network connectivity.'
|
||||||
)
|
)
|
||||||
tid = self.tickets.create(title, desc, priority='2')
|
tid = self.tickets.create(title, desc, priority='2')
|
||||||
if tid and is_new:
|
if tid:
|
||||||
db.set_ticket_id(event_id, tid)
|
db.set_ticket_id(event_id, tid)
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
@@ -918,7 +921,7 @@ class NetworkMonitor:
|
|||||||
return {
|
return {
|
||||||
'hosts': hosts,
|
'hosts': hosts,
|
||||||
'unifi': display_unifi,
|
'unifi': display_unifi,
|
||||||
'updated': datetime.utcnow().isoformat(),
|
'updated': datetime.utcnow().isoformat() + 'Z',
|
||||||
}
|
}
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|||||||
+1
-1
@@ -220,7 +220,7 @@ function updateEventsTable(events, totalActive) {
|
|||||||
? GANDALF_CONFIG.ticket_web_url : 'http://t.lotusguild.org/ticket/';
|
? GANDALF_CONFIG.ticket_web_url : 'http://t.lotusguild.org/ticket/';
|
||||||
const ticket = e.ticket_id
|
const ticket = e.ticket_id
|
||||||
? `<a href="${lt.escHtml(ticketBase)}${lt.escHtml(String(e.ticket_id))}" target="_blank"
|
? `<a href="${lt.escHtml(ticketBase)}${lt.escHtml(String(e.ticket_id))}" target="_blank"
|
||||||
class="ticket-link">#${e.ticket_id}</a>`
|
class="ticket-link">#${lt.escHtml(String(e.ticket_id))}</a>`
|
||||||
: '–';
|
: '–';
|
||||||
const supBadge = e.is_suppressed
|
const supBadge = e.is_suppressed
|
||||||
? `<span class="lt-badge badge-suppressed" title="Alert suppressed">🔕 sup</span>`
|
? `<span class="lt-badge badge-suppressed" title="Alert suppressed">🔕 sup</span>`
|
||||||
|
|||||||
@@ -218,6 +218,7 @@ let _apiData = null;
|
|||||||
function selectPort(el) {
|
function selectPort(el) {
|
||||||
const swName = el.dataset.switch;
|
const swName = el.dataset.switch;
|
||||||
const idx = parseInt(el.dataset.portIdx, 10);
|
const idx = parseInt(el.dataset.portIdx, 10);
|
||||||
|
if (_diagPollTimer) { clearInterval(_diagPollTimer); _diagPollTimer = null; }
|
||||||
document.querySelectorAll('.switch-port-block.selected')
|
document.querySelectorAll('.switch-port-block.selected')
|
||||||
.forEach(e => e.classList.remove('selected'));
|
.forEach(e => e.classList.remove('selected'));
|
||||||
el.classList.add('selected');
|
el.classList.add('selected');
|
||||||
|
|||||||
+12
-8
@@ -372,14 +372,16 @@ function togglePanel(panel) {
|
|||||||
if (title) title.setAttribute('aria-expanded', isCollapsed ? 'false' : 'true');
|
if (title) title.setAttribute('aria-expanded', isCollapsed ? 'false' : 'true');
|
||||||
const id = panel.id;
|
const id = panel.id;
|
||||||
if (id) {
|
if (id) {
|
||||||
const collapsed = JSON.parse(sessionStorage.getItem('linksCollapsed') || '{}');
|
let collapsed = {};
|
||||||
|
try { collapsed = JSON.parse(sessionStorage.getItem('linksCollapsed') || '{}'); } catch(_) {}
|
||||||
collapsed[id] = panel.classList.contains('collapsed');
|
collapsed[id] = panel.classList.contains('collapsed');
|
||||||
sessionStorage.setItem('linksCollapsed', JSON.stringify(collapsed));
|
try { sessionStorage.setItem('linksCollapsed', JSON.stringify(collapsed)); } catch(_) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function restoreCollapseState() {
|
function restoreCollapseState() {
|
||||||
const collapsed = JSON.parse(sessionStorage.getItem('linksCollapsed') || '{}');
|
let collapsed = {};
|
||||||
|
try { collapsed = JSON.parse(sessionStorage.getItem('linksCollapsed') || '{}'); } catch(_) {}
|
||||||
for (const [id, isCollapsed] of Object.entries(collapsed)) {
|
for (const [id, isCollapsed] of Object.entries(collapsed)) {
|
||||||
const panel = document.getElementById(id);
|
const panel = document.getElementById(id);
|
||||||
if (!panel) continue;
|
if (!panel) continue;
|
||||||
@@ -507,9 +509,11 @@ function collapseAll() {
|
|||||||
if (btn) btn.textContent = '[+]';
|
if (btn) btn.textContent = '[+]';
|
||||||
if (title) title.setAttribute('aria-expanded', 'false');
|
if (title) title.setAttribute('aria-expanded', 'false');
|
||||||
});
|
});
|
||||||
sessionStorage.setItem('linksCollapsed', JSON.stringify(
|
try {
|
||||||
Object.fromEntries([...document.querySelectorAll('.link-host-panel')].map(p => [p.id, true]))
|
sessionStorage.setItem('linksCollapsed', JSON.stringify(
|
||||||
));
|
Object.fromEntries([...document.querySelectorAll('.link-host-panel')].map(p => [p.id, true]))
|
||||||
|
));
|
||||||
|
} catch(_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function expandAll() {
|
function expandAll() {
|
||||||
@@ -520,7 +524,7 @@ function expandAll() {
|
|||||||
if (btn) btn.textContent = '[–]';
|
if (btn) btn.textContent = '[–]';
|
||||||
if (title) title.setAttribute('aria-expanded', 'true');
|
if (title) title.setAttribute('aria-expanded', 'true');
|
||||||
});
|
});
|
||||||
sessionStorage.setItem('linksCollapsed', '{}');
|
try { sessionStorage.setItem('linksCollapsed', '{}'); } catch(_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Stale data warning ────────────────────────────────────────────
|
// ── Stale data warning ────────────────────────────────────────────
|
||||||
@@ -548,7 +552,7 @@ function checkLinksStale(updatedStr) {
|
|||||||
async function loadLinks() {
|
async function loadLinks() {
|
||||||
try {
|
try {
|
||||||
const data = await lt.api.get('/api/links');
|
const data = await lt.api.get('/api/links');
|
||||||
if (!data.hosts && !data.unifi_switches) {
|
if ((!data.hosts || !Object.keys(data.hosts).length) && (!data.unifi_switches || !Object.keys(data.unifi_switches).length)) {
|
||||||
document.getElementById('links-container').innerHTML =
|
document.getElementById('links-container').innerHTML =
|
||||||
'<div class="link-no-data">No link data yet — monitor has not completed a full cycle.</div>';
|
'<div class="link-no-data">No link data yet — monitor has not completed a full cycle.</div>';
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
<label class="lt-label" for="s-reason">Reason <span class="required">*</span></label>
|
<label class="lt-label" for="s-reason">Reason <span class="required">*</span></label>
|
||||||
<input type="text" class="lt-input" id="s-reason" name="reason"
|
<input type="text" class="lt-input" id="s-reason" name="reason"
|
||||||
placeholder="e.g. Planned switch maintenance, replacing SFP on large1/enp43s0"
|
placeholder="e.g. Planned switch maintenance, replacing SFP on large1/enp43s0"
|
||||||
required>
|
required aria-required="true">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user