forked from escrevebastante/myrha
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyrha-mac.sh
More file actions
906 lines (810 loc) · 38.7 KB
/
myrha-mac.sh
File metadata and controls
906 lines (810 loc) · 38.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
#!/bin/bash
# --- MYRHA (Mirantis Supportdump Dashboard) ---
# Version: 2.1.0-MAC
# Description: Analysis and Visualization of Mirantis support dumps for macOS.
VERSION="2.1.0-MAC"
DATE=$(date +"%Y-%m-%d %H:%M:%S")
# Check if yq and openssl are installed
if ! command -v yq &> /dev/null; then
echo "Error: yq is not installed. Please install it (e.g., brew install yq)."
exit 1
fi
if ! command -v openssl &> /dev/null; then
echo "Error: openssl is not installed."
exit 1
fi
# Usage info
show_usage() {
echo "Usage: $0 [support-dump-directory]"
echo "Example: $0 ./support-dump-2024-01-01"
exit 1
}
if [[ $# -eq 0 ]]; then
BASE_DIR="."
else
BASE_DIR="$1"
fi
if [[ ! -d "$BASE_DIR" ]]; then
echo "Error: Directory $BASE_DIR not found."
show_usage
fi
LOGPATH="$BASE_DIR/myrha"
mkdir -p "$LOGPATH"
HTML_REPORT="$LOGPATH/dashboard.html"
# Ensure the report starts clean
rm -f "$HTML_REPORT"
# --- INTERNAL HELPERS ---
check_overlaps() {
# Requires a list of CIDRs and Ranges in stdin
# Returns warnings if overlaps are found
python3 -c '
import ipaddress
import sys
def get_ips(entry):
if "/" in entry:
return list(ipaddress.ip_network(entry.strip(), strict=False))
elif "-" in entry:
start, end = entry.split("-")
start_ip = ipaddress.ip_address(start.strip())
end_ip = ipaddress.ip_address(end.strip())
return [ipaddress.ip_address(start_ip + i) for i in range(int(end_ip) - int(start_ip) + 1)]
else:
return [ipaddress.ip_address(entry.strip())]
data = sys.stdin.read().split(",")
all_ranges = []
for item in data:
if not item.strip(): continue
try:
all_ranges.append(get_ips(item))
except:
continue
overlaps = []
for i in range(len(all_ranges)):
for j in range(i + 1, len(all_ranges)):
set_i = set(all_ranges[i])
set_j = set(all_ranges[j])
intersect = set_i.intersection(set_j)
if intersect:
overlaps.append(f"OVERLAP: {list(intersect)[0]}... in blocks {data[i]} and {data[j]}")
if overlaps:
print("🛑 ALERT: IP RANGE OVERLAPS DETECTED!")
for o in overlaps[:10]: print(f" - {o}")
' 2>/dev/null
}
audit_k8s_secret() {
local f="$1"
local DATA_EXPR='(.Object.data // .data // .Object.stringData // .stringData)'
local KEYS=$(yq eval "$DATA_EXPR | keys | .[]" "$f" 2>/dev/null)
for KEY in $KEYS; do
local VAL=$(yq eval "$DATA_EXPR.\"$KEY\"" "$f" 2>/dev/null)
[[ -z "$VAL" ]] && continue
# Try decoding
local DECODED=$(echo "$VAL" | base64 -d 2>/dev/null)
local TARGET=""
if [[ -n "$DECODED" ]]; then
TARGET="$DECODED"
else
TARGET="$VAL"
fi
if [[ "$TARGET" == *"BEGIN CERTIFICATE"* ]]; then
echo "### Key: $KEY (Certificate)"
echo "$TARGET" | openssl x509 -noout -text 2>/dev/null | grep -E "Subject:|Issuer:|Not After|DNS:" | sed 's/^/ /'
# Check expiry
local END_DATE=$(echo "$TARGET" | openssl x509 -noout -enddate 2>/dev/null | cut -d= -f2)
if [[ -n "$END_DATE" ]]; then
local END_SEC=$(date -j -f "%b %e %H:%M:%S %Y %Z" "$END_DATE" +%s 2>/dev/null)
local NOW_SEC=$(date +%s)
local DIFF=$((END_SEC - NOW_SEC))
if [ $DIFF -lt 0 ]; then
echo " 🔴 EXPIRED! ($END_DATE)"
elif [ $DIFF -lt 2592000 ]; then
echo " 🟠 WARNING: Expires in $((DIFF / 86400)) days ($END_DATE)"
fi
fi
elif [[ "$TARGET" == *"BEGIN PRIVATE KEY"* ]]; then
echo "### Key: $KEY (Private Key Detected)"
fi
done
}
# 1. SCAN AND MAP DUMP STRUCTURE
echo "Scanning support dump structure..."
find "$BASE_DIR" -type f \( -name "*.yaml" -o -name "*.log" -o -name "*.json" \) > "$LOGPATH/files"
# Identify Management (MCC) and Managed (MOS) clusters
MCC_DIR=$(find "$BASE_DIR" -maxdepth 1 -type d -name "kaas-mgmt" | head -n 1)
[[ -z "$MCC_DIR" ]] && MCC_DIR=$(find "$BASE_DIR" -type d -name "kaas-mgmt" | head -n 1)
[[ -z "$MCC_DIR" ]] && MCC_DIR=$(grep "kaas-mgmt" "$LOGPATH/files" | head -n 1 | cut -d'/' -f1-2)
[[ -z "$MCC_DIR" ]] && MCC_DIR="."
MOS_DIR=$(find "$BASE_DIR" -maxdepth 1 -type d -name "mos" | head -n 1)
if [[ -z "$MOS_DIR" ]]; then
if [[ -n "$MCC_DIR" ]]; then
MOS_DIR=$(find "$BASE_DIR" -type d -name "mos" | grep -v "$MCC_DIR" | head -n 1)
else
MOS_DIR=$(find "$BASE_DIR" -type d -name "mos" | head -n 1)
fi
fi
[[ -z "$MOS_DIR" ]] && MOS_DIR=$(grep -vE "kaas-mgmt|mgmt" "$LOGPATH/files" | grep "cluster/core/nodes" | head -n 1 | cut -d'/' -f1-2)
MOSNAME=""
if [[ -n "$MOS_DIR" && "$MOS_DIR" != "$MCC_DIR" ]]; then
MOSNAME=$(basename "$MOS_DIR")
fi
# Namespaces
MCCNAMESPACE="kaas"
MOSNAMESPACE="openstack"
echo "Detected Management Cluster: ${MCCNAME:-Unknown} (Path: $MCC_DIR)"
echo "Detected Managed Cluster: ${MOSNAME:-None} (Path: $MOS_DIR)"
# --- DASHBOARD HTML HEADER ---
cat <<EOF >"$HTML_REPORT"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Myrha - Mirantis Supportdump Dashboard</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&family=Fira+Code:wght@400;500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css">
<style>
:root {
--bg: #0f172a;
--sidebar-bg: #1e293b;
--card-bg: #1e293b;
--text: #e2e8f0;
--accent: #38bdf8;
--accent-hover: #7dd3fc;
--border: #334155;
--success: #22c55e;
--warning: #f59e0b;
--danger: #ef4444;
--code-bg: #000000;
}
* { box-sizing: border-box; }
body {
margin: 0;
font-family: 'Inter', sans-serif;
background-color: var(--bg);
color: var(--text);
display: flex;
height: 100vh;
overflow: hidden;
}
/* Sidebar Styles */
.sidebar {
width: 320px;
background-color: var(--sidebar-bg);
border-right: 1px solid var(--border);
display: flex;
flex-direction: column;
transition: all 0.3s ease;
flex-shrink: 0;
}
.sidebar.collapsed { width: 0; overflow: hidden; border-right: none; }
.sidebar-header { padding: 20px; border-bottom: 1px solid var(--border); }
.sidebar-header h2 { margin: 0; font-size: 1.2rem; color: var(--accent); }
.search-box { padding: 15px; border-bottom: 1px solid var(--border); }
.search-box input {
width: 100%; padding: 10px; border-radius: 6px; border: 1px solid var(--border);
background: var(--bg); color: white; outline: none;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px; }
.sidebar-nav ul { list-style: none; padding: 0; margin: 0; }
.sidebar-nav li { margin-bottom: 4px; }
.sidebar-nav a {
display: block; padding: 10px 15px; border-radius: 6px;
color: var(--text); text-decoration: none; font-size: 0.9rem;
transition: background 0.2s;
}
.sidebar-nav a:hover { background: var(--border); }
.sidebar-nav a.active { background: var(--accent); color: var(--bg); font-weight: 600; }
.category-header {
padding: 15px 15px 5px; font-size: 0.75rem; font-weight: 700;
text-transform: uppercase; color: #64748b; letter-spacing: 0.05em;
}
/* Main Content Styles */
.main-content { flex: 1; overflow-y: auto; padding: 30px; position: relative; scroll-behavior: smooth; }
.header { margin-bottom: 30px; }
.header h1 { margin: 0; font-weight: 300; font-size: 2rem; }
.header p { color: #94a3b8; margin: 5px 0 0; }
.card {
background: var(--card-bg); border-radius: 12px; border: 1px solid var(--border);
margin-bottom: 25px; display: none; flex-direction: column;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.card.active { display: flex; }
.card-header-actions { display: flex; align-items: center; gap: 10px; }
.card h2 {
padding: 20px; margin: 0; font-size: 1.1rem; border-bottom: 1px solid var(--border);
display: flex; justify-content: space-between; align-items: center;
}
.card .raw-code {
margin: 0; padding: 20px !important; background: var(--code-bg) !important;
font-family: 'Fira Code', monospace; font-size: 0.85rem; line-height: 1.6;
max-height: 600px; overflow: auto; border-radius: 0 0 12px 12px;
}
.card .raw-code.fullscreen {
position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
z-index: 9999; max-height: none; border-radius: 0;
}
/* Analysis Files Styles */
.analyzed-files-wrapper {
padding: 10px 20px; background: rgba(0,0,0,0.2); border-bottom: 1px solid var(--border);
display: flex; justify-content: space-between; align-items: center;
}
.analyzed-files-container {
font-size: 0.8rem; color: #94a3b8; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 1;
}
.analyzed-files-container.expanded { white-space: normal; }
.more-files-btn {
background: none; border: 1px solid var(--accent); color: var(--accent);
font-size: 0.7rem; cursor: pointer; border-radius: 4px; padding: 2px 6px; margin-left: 10px;
}
.btn-tool {
padding: 6px 12px; border-radius: 6px; font-size: 0.75rem; cursor: pointer;
background: var(--bg); border: 1px solid var(--border); color: var(--text);
transition: all 0.2s;
}
.btn-tool:hover { border-color: var(--accent); color: var(--accent); }
.btn-close { color: var(--danger); }
.btn-close:hover { background: var(--danger); color: white; border-color: var(--danger); }
.toggle-sidebar-btn {
position: fixed; bottom: 20px; left: 20px; z-index: 1000;
width: 40px; height: 40px; border-radius: 50%; background: var(--accent);
color: var(--bg); border: none; cursor: pointer; font-size: 1.2rem;
box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
/* Search highlights */
.search-match { background-color: rgba(245, 158, 11, 0.4); border-bottom: 2px solid var(--warning); }
.search-match.current { background-color: var(--warning); color: black; }
.card-search {
background: var(--bg); border: 1px solid var(--border); color: white;
padding: 4px 8px; border-radius: 4px; font-size: 0.8rem; width: 150px;
}
.search-nav-container { display: flex; align-items: center; gap: 5px; }
.search-count { font-size: 0.7rem; color: #94a3b8; min-width: 40px; }
.placeholder-msg {
display: flex; flex-direction: column; align-items: center; justify-content: center;
height: 60%; color: #475569;
}
.placeholder-msg h2 { font-weight: 300; font-size: 2.5rem; margin-bottom: 10px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }
@media print {
.sidebar, .toggle-sidebar-btn, .card-header-actions, .analyzed-files-wrapper { display: none !important; }
.card { display: block !important; break-inside: avoid; border: 1px solid #ccc; }
.main-content { overflow: visible; padding: 0; }
}
</style>
<script>
function toggleCard(link, id) {
const card = document.getElementById(id);
if (card.classList.contains('active')) {
card.classList.remove('active');
link.classList.remove('active');
} else {
card.classList.add('active');
link.classList.add('active');
// Scroll to card
card.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
updatePlaceholder();
}
function closeCard(id) {
document.getElementById(id).classList.remove('active');
const links = document.querySelectorAll('.sidebar-nav a');
links.forEach(l => {
if (l.getAttribute('onclick').includes("'" + id + "'")) l.classList.remove('active');
});
updatePlaceholder();
}
function updatePlaceholder() {
const activeCards = document.querySelectorAll('.card.active');
document.getElementById('placeholder').style.display = activeCards.length === 0 ? 'flex' : 'none';
}
function toggleSidebar() {
const sidebar = document.querySelector('.sidebar');
const btn = document.querySelector('.toggle-sidebar-btn');
sidebar.classList.toggle('collapsed');
btn.innerHTML = sidebar.classList.contains('collapsed') ? '▶' : '◀';
}
function filterNav(val) {
const links = document.querySelectorAll('.sidebar-nav li');
links.forEach(li => {
const text = li.textContent.toLowerCase();
li.style.display = text.includes(val.toLowerCase()) ? 'block' : 'none';
});
}
function copyToClipboard(btn, id) {
const code = document.querySelector('#' + id + ' .raw-code').innerText;
navigator.clipboard.writeText(code).then(() => {
const oldText = btn.innerText;
btn.innerText = 'Copied!';
btn.style.borderColor = 'var(--success)';
btn.style.color = 'var(--success)';
setTimeout(() => {
btn.innerText = oldText;
btn.style.borderColor = '';
btn.style.color = '';
}, 2000);
});
}
function toggleFullScreen(btn, id) {
const code = document.querySelector('#' + id + ' .raw-code');
code.classList.toggle('fullscreen');
btn.innerText = code.classList.contains('fullscreen') ? 'Exit Full Screen' : 'Full Screen';
if (code.classList.contains('fullscreen')) {
document.body.style.overflow = 'hidden';
} else {
document.body.style.overflow = '';
}
}
function toggleBlockWrap(btn, id) {
const code = document.querySelector('#' + id + ' .raw-code');
const isWrapped = code.style.whiteSpace === 'pre-wrap';
code.style.whiteSpace = isWrapped ? 'pre' : 'pre-wrap';
btn.innerText = isWrapped ? 'Wrap: OFF' : 'Wrap: ON';
}
function scrollToLimit(id, limit) {
const code = document.querySelector('#' + id + ' .raw-code');
if (limit === 'top') code.scrollTop = 0;
else code.scrollTop = code.scrollHeight;
}
function toggleAnalyzedFiles(btn) {
const container = btn.previousElementSibling;
container.classList.toggle('expanded');
btn.innerText = container.classList.contains('expanded') ? 'less...' : 'more...';
}
// Search logic inside cards
let searchIndices = {};
function performSearch(cardId, query) {
const card = document.getElementById(cardId);
const codeBlock = card.querySelector('code');
const countSpan = card.querySelector('.search-count');
if (!query || query.length < 2) {
codeBlock.innerHTML = codeBlock.textContent.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
countSpan.innerText = '0/0';
searchIndices[cardId] = { current: -1, total: 0 };
return;
}
const content = codeBlock.textContent;
const regex = new RegExp(query.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), 'gi');
let matches = [];
let match;
while ((match = regex.exec(content)) !== null) {
matches.push(match.index);
}
if (matches.length === 0) {
countSpan.innerText = '0/0';
searchIndices[cardId] = { current: -1, total: 0 };
return;
}
// Highlighting (expensive but works for reasonably sized blocks)
let highlighted = content
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(regex, (m) => `<span class="search-match">${m}</span>`);
codeBlock.innerHTML = highlighted;
searchIndices[cardId] = { current: 0, total: matches.length };
countSpan.innerText = `1/${matches.length}`;
highlightMatch(cardId, 0);
}
function highlightMatch(cardId, index) {
const card = document.getElementById(cardId);
const matches = card.querySelectorAll('.search-match');
matches.forEach(m => m.classList.remove('current'));
if (matches[index]) {
matches[index].classList.add('current');
matches[index].scrollIntoView({ behavior: 'smooth', block: 'center' });
}
}
function navigateSearch(cardId, direction) {
const state = searchIndices[cardId];
if (!state || state.total === 0) return;
if (direction === 'next') {
state.current = (state.current + 1) % state.total;
} else {
state.current = (state.current - 1 + state.total) % state.total;
}
const countSpan = document.getElementById(cardId).querySelector('.search-count');
countSpan.innerText = `${state.current + 1}/${state.total}`;
highlightMatch(cardId, state.current);
}
</script>
</head>
<body>
<nav class="sidebar">
<div class="sidebar-header">
<h2>MYRHA Dashboard</h2>
<small style="color: #64748b">Supportdump Analysis v$VERSION</small>
</div>
<div class="search-box">
<input type="text" placeholder="Filter sections..." onkeyup="filterNav(this.value)">
</div>
<nav class="sidebar-nav">
<ul id="sidebarList">
<li class="category-header">Executive</li>
<li data-category="all"><a href="javascript:void(0)" onclick="toggleCard(this, 'EXECUTIVE-SUMMARY-&-CRITICAL-FINDINGS')">EXECUTIVE SUMMARY</a></li>
EOF
# --- CORE ANALYSIS LOGIC ---
# Identify Versions for sidebar/header
MCC_VER_STR=""
MCC_DOC_URL="#"
MCC_JIRA_URL="#"
if [[ -n "$MCCNAME" ]]; then
MCC_YAML=$(find "$MCC_DIR" -path "*/cluster.k8s.io/clusters/$MCCNAME.yaml" | head -n 1)
[[ -z "$MCC_YAML" ]] && MCC_YAML=$(find "$MCC_DIR" -path "*/clusters/*.yaml" | head -n 1)
if [[ -f "$MCC_YAML" ]]; then
# Extract version (e.g., release: kaas-2.26.1)
K_RAW=$(grep -m1 "release: kaas-" "$MCC_YAML" | sed -e 's/.*kaas-//' -e 's/[[:space:]]//g' -e 's/-/./g')
IFS='.' read -r -a M <<<"$K_RAW"
MCC_BUG_VER="${M[0]}.${M[1]}.${M[2]}"
MCC_VER_STR=" (KaaS: $MCC_BUG_VER)"
MCC_DOC_URL="https://docs.mirantis.com/container-cloud/latest/release-notes/releases/${M[0]}-${M[1]}-${M[2]}.html"
# MCC Jira Filters
MCC_JIRA_URL="https://mirantis.jira.com/issues/?jql=affectedversion%20%3D%20%22KaaS%20$MCC_BUG_VER%22"
[[ "$MCC_BUG_VER" == "2.31.0" ]] && MCC_JIRA_URL="https://mirantis.jira.com/issues?jql=affectedversion%20%3D%20%22KaaS%202.31%20%2F%20MOSK%2026.1%22"
[[ "$MCC_BUG_VER" == "2.31.1" ]] && MCC_JIRA_URL="https://mirantis.jira.com/issues?jql=affectedversion%20%3D%20%22KaaS%202.31.1%20%2F%20MOSK%2025.2.6%20(Patch%20release6)%22"
[[ "$MCC_BUG_VER" == "2.31.2" ]] && MCC_JIRA_URL="https://mirantis.jira.com/issues?jql=affectedversion%20%3D%20%22KaaS%202.31.2%20%2F%20MOSK%2025.2.7%20(Patch%20release7)%22"
[[ "$MCC_BUG_VER" == "2.31.3" ]] && MCC_JIRA_URL="https://mirantis.jira.com/issues?jql=affectedversion%20%3D%20%22KaaS%202.31.3%20%2F%20MOSK%2025.2.8%20(Patch%20release8)%22"
[[ "$MCC_BUG_VER" == "2.31.4" ]] && MCC_JIRA_URL="https://mirantis.jira.com/issues?jql=affectedversion%20%3D%20%22KaaS%202.31.4%20%2F%20MOSK%2025.2.9%20(Patch%20release9)%22"
[[ "$MCC_BUG_VER" == "2.31.5" ]] && MCC_JIRA_URL="https://mirantis.jira.com/issues?jql=affectedversion%20%3D%20%22KaaS%202.31.5%20%2F%20MOSK%2026.1.1%22"
[[ "$MCC_BUG_VER" == "2.32.0" ]] && MCC_JIRA_URL="https://mirantis.jira.com/issues?jql=affectedversion%20%3D%20%22KaaS%202.32%20%2F%20MOSK%2026.2%22"
fi
fi
MOS_VER_STR=""
MOS_DOC_URL="#"
MOS_JIRA_URL="#"
if [[ -n "$MOSNAME" ]]; then
MOS_STATUS_FILE=$(find "$MOS_DIR" -path "*/lcm.mirantis.com/openstackdeploymentstatus/*.yaml" 2>/dev/null | head -n 1)
if [[ -f "$MOS_STATUS_FILE" ]]; then
REL_RAW=$(grep -m1 " release: " "$MOS_STATUS_FILE" | sed -e 's/.*release: //' -e 's/[[:space:]]//g' -e 's/+/./g' -e 's/\.$//')
IFS='.' read -r -a V <<<"$REL_RAW"
MOS_BUG_VER="${V[3]}.${V[4]}${V[5]:+.${V[5]}}"
MOS_VER_STR=" (MOSK: $MOS_BUG_VER)"
if (($(echo "${V[3]}.${V[4]} >= 24.2" | bc -l 2>/dev/null || echo 0))); then
MOS_DOC_URL="https://docs.mirantis.com/mosk/latest/release-notes/${V[3]}.${V[4]}-series/${V[3]}.${V[4]}.${V[5]}.html"
else
MOS_DOC_URL="https://docs.mirantis.com/mosk/24.1-and-earlier/release-notes/release-notes-mosk-old/${V[3]}.${V[4]}-series/${V[3]}.${V[4]}.${V[5]}.html"
fi
# MOS Jira Filters
MOS_JIRA_URL="https://mirantis.jira.com/issues/?jql=affectedversion%20%3D%20%22MOSK%20$MOS_BUG_VER%22"
[[ "$MOS_BUG_VER" == "25.2.9" ]] && MOS_JIRA_URL="https://mirantis.jira.com/issues?jql=affectedversion%20%3D%20%22KaaS%202.31.4%20%2F%20MOSK%2025.2.9%20(Patch%20release9)%22"
[[ "$MOS_BUG_VER" == "26.1."* ]] && MOS_JIRA_URL="https://mirantis.jira.com/issues?jql=affectedversion%20%3D%20%22KaaS%202.31%20%2F%20MOSK%2026.1%22"
[[ "$MOS_BUG_VER" == "26.1.1" ]] && MOS_JIRA_URL="https://mirantis.jira.com/issues?jql=affectedversion%20%3D%20%22KaaS%202.31.5%20%2F%20MOSK%2026.1.1%22"
[[ "$MOS_BUG_VER" == "26.2."* ]] && MOS_JIRA_URL="https://mirantis.jira.com/issues?jql=affectedversion%20%3D%20%22KaaS%202.32%20%2F%20MOSK%2026.2%22"
fi
fi
MCC_LINKS_HTML="<div style='margin-bottom: 5px;'><strong>MCC $MCC_BUG_VER:</strong> <a href='$MCC_DOC_URL' target='_blank'>RN</a> | <a href='$MCC_JIRA_URL' target='_blank'>Bugs</a></div>"
MOS_LINKS_HTML="${MOSNAME:+<div><strong>MOS $MOS_BUG_VER:</strong> <a href='$MOS_DOC_URL' target='_blank'>RN</a> | <a href='$MOS_JIRA_URL' target='_blank'>Bugs</a></div>}"
# --- COMPONENT SCANNING ---
# MOS Cluster
if [[ -n "$MOSNAME" ]]; then
OUT="$LOGPATH/mos_cluster.yaml"
echo "Gathering MOS cluster details..."
echo "################# [MOS CLUSTER DETAILS] #################" >"$OUT"
echo "" >>"$OUT"
MOS_CLUSTER_FILE=$(find "$MCC_DIR" -path "*/cluster.k8s.io/clusters/*.yaml" | grep -v "/default/" | head -n 1)
if [[ -f "$MOS_CLUSTER_FILE" ]]; then
echo "## MOS Cluster Status (Cluster API):" >>"$OUT"
echo "# [FILE]: $MOS_CLUSTER_FILE" >>"$OUT"
grep -E "release: | - message" "$MOS_CLUSTER_FILE" >>"$OUT"
sed -n '/ stacklight:/,/ kind:/p' "$MOS_CLUSTER_FILE" >>"$OUT"
#yq eval '.Object.status.providerStatus | {"ready": .ready, "ceph": .ceph, "warnings": .warnings, "notReadyObjects": .notReadyObjects}' "$MOS_CLUSTER_FILE" 2>/dev/null >>"$OUT"
echo "" >>"$OUT"
fi
MOS_OSD=$(find "$MOS_DIR" -path "*/lcm.mirantis.com/openstackdeployments/*.yaml" | head -n 1)
if [[ -f "$MOS_OSD" ]]; then
echo "# [FILE]: $MOS_OSD" >>"$OUT"
echo "## OpenStackDeployment Status:" >>"$OUT"
yq eval '.Object.status // .status' "$MOS_OSD" 2>/dev/null >>"$OUT"
STUCK_MSG=$(yq eval '.Object.status.lcmOperationStuckMessage // .status.lcmOperationStuckMessage' "$MOS_OSD" 2>/dev/null)
if [[ -n "$STUCK_MSG" && "$STUCK_MSG" != "null" ]]; then
echo " lcmOperationStuckMessage: $STUCK_MSG" >>"$OUT"
fi
fi
echo -e "\n## OpenStackDeploymentStatus Details:" >>"$OUT"
find "$MOS_DIR" -path "*/lcm.mirantis.com/openstackdeploymentstatus/*.yaml" 2>/dev/null | while read -r f; do
echo "### File: $f" >>"$OUT"
yq eval '.Object.status // .status' "$f" 2>/dev/null >>"$OUT"
done
echo -e "\n## Node Conditions:" >>"$OUT"
grep "/core/nodes" "$LOGPATH/files" | grep "$MOS_DIR" | while read -r nf; do
N_NAME=$(basename "$nf" .yaml)
READY=$(yq eval '.Object.status.conditions[] | select(.type=="Ready") | .status' "$nf" 2>/dev/null)
printf "Node: %-50s | Ready: %s\n" "$N_NAME" "${READY:-Unknown}" >>"$OUT"
done
fi
# MOS Events
if [[ -n "$MOSNAME" ]]; then
OUT="$LOGPATH/mos_events.yaml"
echo "Gathering MOS events..."
echo "################# [MOS EVENTS (WARNING+ERRORS)] #################" >"$OUT"
printf '# ' >>"$OUT"
ls "$MOS_DIR/objects/events.log" 2>/dev/null >>"$OUT"
grep -E "Warning|Error" "$MOS_DIR/objects/events.log" 2>/dev/null | sort >>"$OUT"
fi
# MCC Cluster
if [[ -n "$MCCNAME" ]]; then
OUT="$LOGPATH/mcc_cluster.yaml"
echo "Gathering MCC cluster details..."
echo "################# [MCC CLUSTER DETAILS] #################" >"$OUT"
if [[ -f "$MCC_YAML" ]]; then
echo "# [FILE]: $MCC_YAML" >>"$OUT"
yq eval '.Object.status // .status' "$MCC_YAML" 2>/dev/null >>"$OUT"
fi
LCM_MCC=$(find "$MCC_DIR" -path "*/lcm.mirantis.com/lcmclusters/*.yaml" | head -n 1)
if [[ -f "$LCM_MCC" ]]; then
echo -e "\n# [FILE]: $LCM_MCC" >>"$OUT"
yq eval '.Object.status // .status' "$LCM_MCC" 2>/dev/null >>"$OUT"
STUCK_MSG=$(yq eval '.Object.status.lcmOperationStuckMessage // .status.lcmOperationStuckMessage' "$LCM_MCC" 2>/dev/null)
[[ -n "$STUCK_MSG" && "$STUCK_MSG" != "null" ]] && echo " lcmOperationStuckMessage: $STUCK_MSG" >>"$OUT"
fi
echo -e "\n## LCM Controller Logs (Errors/Warnings):" >>"$OUT"
find "$MCC_DIR" -path "*/kaas/core/pods/lcm-lcm-controller-*/controller.log" | sort | while read -r log; do
echo "### Pod: /${log#./}" >>"$OUT"
grep -Ei "error|fail|warning|warn" "$log" | tail -n 10 >>"$OUT"
done
echo -e "\n## Audit: Known Issues Checks:" >>"$OUT"
echo "### [FIELD-8106] Keepalived Flapping Check:" >>"$OUT"
find "$MCC_DIR" -path "*/kaas/core/pods/mcc-keepalived-*/keepalived.log" 2>/dev/null | while read -r log; do
if grep -q "forcing new election" "$log"; then
echo "🛑 ALERT: 'forcing new election' found in /${log#./}" >>"$OUT"
grep "forcing new election" "$log" | tail -n 5 >>"$OUT"
fi
done
echo "### [Bug 58728] Auditd Managed Field Check:" >>"$OUT"
find "$MCC_DIR" -path "*/clusters/*.yaml" 2>/dev/null | while read -r f; do
if grep -q "auditd:" "$f" && grep -A 5 "auditd:" "$f" | grep -q "managed: false"; then
echo "⚠️ INFO: 'managed: false' found for auditd in $(basename "$f") (Expected for 2.31.0+)" >>"$OUT"
fi
done
echo "### [Bug 56677] Bare Metal Deletion Failure Check:" >>"$OUT"
find "$MCC_DIR" -path "*/kaas/core/pods/lcm-lcm-controller-*/controller.log" 2>/dev/null | while read -r log; do
if grep -q "Cleanup cannot be performed without target_storage spec" "$log"; then
echo "🛑 ALERT: Bug 56677 (BM Deletion failure) found in /${log#./}" >>"$OUT"
fi
done
fi
# MCC Events
if [[ -n "$MCCNAME" ]]; then
OUT="$LOGPATH/mcc_events.yaml"
echo "Gathering MCC events..."
echo "################# [MCC EVENTS (WARNING+ERRORS)] #################" >"$OUT"
printf '# ' >>"$OUT"
ls "$MCC_DIR/objects/events.log" 2>/dev/null >>"$OUT"
grep -E "Warning|Error" "$MCC_DIR/objects/events.log" 2>/dev/null | sort >>"$OUT"
fi
# Stacklight (Patroni)
if [[ -d "$MCC_DIR/objects/namespaced/stacklight" ]]; then
OUT="$LOGPATH/mcc_stacklight.yaml"
echo "Gathering MCC Stacklight details..."
echo "################# [MCC STACKLIGHT & PATRONI DETAILS] #################" >"$OUT"
echo "## Patroni Cluster Status:" >>"$OUT"
find "$MCC_DIR" -path "*/stacklight/core/pods/patroni-*.yaml" 2>/dev/null | sort | while read -r pf; do
P_STATUS=$(yq eval '.Object.metadata.annotations.status // .metadata.annotations.status' "$pf" 2>/dev/null)
if [[ -n "$P_STATUS" && "$P_STATUS" != "null" ]]; then
ROLE=$(echo "$P_STATUS" | grep -oE '"role":"[^"]+"' | cut -d'"' -f4)
STATE=$(echo "$P_STATUS" | grep -oE '"state":"[^"]+"' | cut -d'"' -f4)
printf "Pod: %-25s | Role: %-10s | State: %s\n" "$(basename "$pf" .yaml)" "$ROLE" "$STATE" >>"$OUT"
fi
done
fi
# Credentials
if [[ -n "$MCCNAME" ]]; then
OUT="$LOGPATH/mcc_credentials.yaml"
echo "Scanning MCC Secrets for Credentials..."
echo "################# [MCC CREDENTIALS (DECRYPTED)] #################" >"$OUT"
# Include Cluster Object
MCC_CLUSTER_OBJ="$MCC_DIR/objects/namespaced/default/cluster.k8s.io/clusters/kaas-mgmt.yaml"
if [[ -f "$MCC_CLUSTER_OBJ" ]]; then
CREDS=$(yq eval '.Object.spec.providerSpec.value.credentials // .spec.providerSpec.value.credentials' "$MCC_CLUSTER_OBJ" 2>/dev/null)
if [[ -n "$CREDS" && "$CREDS" != '""' ]]; then
echo "----------------------------------------------------" >> "$OUT"
echo "## MCC Cluster Object (Cluster API): $MCC_CLUSTER_OBJ" >> "$OUT"
DECODED=$(echo "$CREDS" | base64 -d 2>/dev/null)
if [[ -n "$DECODED" ]]; then
echo "$DECODED" | while read -r line; do
if [[ "$line" =~ user|pass ]]; then
echo "🔑 $line" >> "$OUT"
fi
done
else
echo "🔑 credentials : $CREDS" >> "$OUT"
fi
fi
fi
find "$MCC_DIR" -path "*/core/secrets/*.yaml" -type f | while read -r f; do
DATA_EXPR='(.Object.data // .data // .Object.stringData // .stringData)'
KEYS=$(yq eval "$DATA_EXPR | keys | .[]" "$f" 2>/dev/null)
FILE_BUF=""
for KEY in $KEYS; do
if [[ "$KEY" =~ user|pass|login|account|creds|secret|token|key ]]; then
VAL=$(yq eval "$DATA_EXPR.\"$KEY\"" "$f" 2>/dev/null)
DECODED=$(echo "$VAL" | base64 -d 2>/dev/null)
if [[ -n "$DECODED" && ! "$DECODED" =~ [^[:print:][:space:]] ]]; then
FILE_BUF+=$(printf "🔑 %-30s : %s\n" "$KEY" "$DECODED")
fi
fi
done
if [[ -n "$FILE_BUF" ]]; then
echo "----------------------------------------------------" >>"$OUT"
echo "## File: $f" >>"$OUT"
echo -e "$FILE_BUF" >>"$OUT"
fi
done
fi
if [[ -n "$MOSNAME" ]]; then
OUT="$LOGPATH/mos_credentials.yaml"
echo "Scanning MOS Secrets for Credentials..."
echo "################# [MOS CREDENTIALS (DECRYPTED)] #################" >"$OUT"
# Include Cluster Object
MOS_CLUSTER_OBJ="$MCC_DIR/objects/namespaced/$MOSNAMESPACE/cluster.k8s.io/clusters/$MOSNAME.yaml"
if [[ -f "$MOS_CLUSTER_OBJ" ]]; then
CREDS=$(yq eval '.Object.spec.providerSpec.value.credentials // .spec.providerSpec.value.credentials' "$MOS_CLUSTER_OBJ" 2>/dev/null)
if [[ -n "$CREDS" && "$CREDS" != '""' ]]; then
echo "----------------------------------------------------" >> "$OUT"
echo "## MOS Cluster Object (Cluster API): $MOS_CLUSTER_OBJ" >> "$OUT"
DECODED=$(echo "$CREDS" | base64 -d 2>/dev/null)
if [[ -n "$DECODED" ]]; then
echo "$DECODED" | while read -r line; do
if [[ "$line" =~ user|pass ]]; then
echo "🔑 $line" >> "$OUT"
fi
done
else
echo "🔑 credentials : $CREDS" >> "$OUT"
fi
fi
fi
find "$MOS_DIR" -path "*/core/secrets/*.yaml" -type f | while read -r f; do
DATA_EXPR='(.Object.data // .data // .Object.stringData // .stringData)'
KEYS=$(yq eval "$DATA_EXPR | keys | .[]" "$f" 2>/dev/null)
FILE_BUF=""
for KEY in $KEYS; do
if [[ "$KEY" =~ user|pass|login|account|creds|secret|token|key ]]; then
VAL=$(yq eval "$DATA_EXPR.\"$KEY\"" "$f" 2>/dev/null)
DECODED=$(echo "$VAL" | base64 -d 2>/dev/null)
if [[ -n "$DECODED" && ! "$DECODED" =~ [^[:print:][:space:]] ]]; then
FILE_BUF+=$(printf "🔑 %-30s : %s\n" "$KEY" "$DECODED")
fi
fi
done
if [[ -n "$FILE_BUF" ]]; then
echo "----------------------------------------------------" >>"$OUT"
echo "## File: $f" >>"$OUT"
echo -e "$FILE_BUF" >>"$OUT"
fi
done
fi
# --- HELPER: FORMAT POD LINE (macOS) ---
get_age() {
local f="$1"
local CREATED=$(yq eval '.Object.metadata.creationTimestamp // .metadata.creationTimestamp' "$f" 2>/dev/null)
local AGE="N/A"
if [[ -n "$CREATED" && "$CREATED" != "null" ]]; then
local NOW_SEC=$(date +%s)
local CREATED_SEC=$(date -j -f "%Y-%m-%dT%H:%M:%SZ" "$CREATED" +%s 2>/dev/null)
if [[ -n "$CREATED_SEC" ]]; then
local DIFF=$((NOW_SEC - CREATED_SEC))
if [ $DIFF -lt 0 ]; then DIFF=0; fi
if [ $DIFF -ge 86400 ]; then AGE="$((DIFF / 86400))d"
elif [ $DIFF -ge 3600 ]; then AGE="$((DIFF / 3600))h"
elif [ $DIFF -ge 60 ]; then AGE="$((DIFF / 60))m"
else AGE="${DIFF}s"; fi
fi
fi
echo "$AGE"
}
get_pod_line() {
local f="$1"
local NS=$(yq eval '.Object.metadata.namespace // .metadata.namespace' "$f" 2>/dev/null)
local NAME=$(yq eval '.Object.metadata.name // .metadata.name' "$f" 2>/dev/null)
local PHASE=$(yq eval '.Object.status.phase // .status.phase' "$f" 2>/dev/null)
local RESTARTS=$(yq eval '.Object.status.containerStatuses[].restartCount' "$f" 2>/dev/null | awk '{sum+=$1} END {print sum+0}')
local AGE=$(get_age "$f")
local NODE=$(yq eval '.Object.spec.nodeName // .spec.nodeName' "$f" 2>/dev/null)
printf "%-25s %-50s %-15s %-10s %-10s %-25s\n" "$NS" "$NAME" "$PHASE" "$RESTARTS" "$AGE" "$NODE"
}
# Pod Audit
for CL_DIR in "$MCC_DIR" "$MOS_DIR"; do
[[ -z "$CL_DIR" || ! -d "$CL_DIR" ]] && continue
CL_TYPE=$(basename "$CL_DIR" | tr '[:lower:]' '[:upper:]')
OUT="$LOGPATH/${CL_TYPE,,}_pods.yaml"
echo "Auditing $CL_TYPE Pods..."
echo "################# [$CL_TYPE POD STATUS] #################" >"$OUT"
HEADER=$(printf "%-25s %-50s %-15s %-10s %-10s %-25s\n" "NAMESPACE" "NAME" "PHASE" "RESTARTS" "AGE" "NODE")
echo "$HEADER" >>"$OUT"
find "$CL_DIR" -path "*/core/pods/*.yaml" -type f | while read -r f; do
get_pod_line "$f" >>"$OUT"
done
done
# --- EXECUTIVE SUMMARY ---
echo "Generating Summary..."
OUT="$LOGPATH/summary.yaml"
echo "################# [EXECUTIVE SUMMARY & CRITICAL FINDINGS] #################" >"$OUT"
echo "## 🚀 CLUSTER STATUS:" >>"$OUT"
[[ -f "$LOGPATH/mcc_cluster.yaml" ]] && grep "lcmOperationStuckMessage:" "$LOGPATH/mcc_cluster.yaml" -A 2 >>"$OUT"
[[ -f "$LOGPATH/mos_cluster.yaml" ]] && grep "lcmOperationStuckMessage:" "$LOGPATH/mos_cluster.yaml" -A 2 >>"$OUT"
echo -e "\n## 🖥️ NODE STATUS SUMMARY (Non-Ready):" >>"$OUT"
grep -h "|" "$LOGPATH"/*_cluster.yaml 2>/dev/null | grep -v "Ready: True" | grep "Node: " | sort | uniq -c >>"$OUT"
echo -e "\n## ⚠️ POD FAILURES (Top 10 Restarts):" >>"$OUT"
grep -h "|" "$LOGPATH"/*_pods.yaml 2>/dev/null | awk '$4 > 0' | sort -k4 -nr | head -n 10 >>"$OUT"
echo -e "\n## 🔍 TOP ERRORS & BLOCKERS:" >>"$OUT"
grep -hEi "error|fail|denied|forbidden|context deadline exceeded" "$LOGPATH"/*.yaml 2>/dev/null | sort | uniq -c | sort -nr | head -n 10 >>"$OUT"
# --- FINAL DASHBOARD ASSEMBLY ---
# Formatting (Add empty lines before ##)
echo "Formatting cards..."
for f in "$LOGPATH"/*.yaml; do
[[ -f "$f" ]] || continue
awk 'NR>1 && /^##/ && last !~ /^$/ {print ""} {print; last=$0}' "$f" > "$f.tmp" && mv "$f.tmp" "$f"
done
for yaml_file in $(ls "$LOGPATH"/*.yaml 2>/dev/null | sort); do
TITLE=$(basename "$yaml_file" .yaml | tr '_' ' ' | tr '[:lower:]' '[:upper:]')
ANCHOR=$(echo "$TITLE" | tr ' ' '-')
# Sidebar entry
CATEGORY="cluster"
[[ "$TITLE" == *SUMMARY* ]] && CATEGORY="all"
[[ "$TITLE" == MCC* ]] && CATEGORY="mcc"
[[ "$TITLE" == MOS* ]] && CATEGORY="mos"
echo "<li data-category='$CATEGORY'><a href='javascript:void(0)' onclick=\"toggleCard(this, '$ANCHOR')\">$TITLE</a></li>" >>"$HTML_REPORT"
done
printf "\n</ul>\n</nav>\n<main class=\"main-content\">\n" >>"$HTML_REPORT"
cat <<EOF >>"$HTML_REPORT"
<button class="toggle-sidebar-btn" onclick="toggleSidebar()" title="Toggle Sidebar">◀</button>
<div class="header" style="display: flex; justify-content: space-between;">
<div>
<h1>Myrha Dashboard</h1>
<p><strong>MCC:</strong> ${MCCNAME:-N/A}$MCC_VER_STR | <strong>MOS:</strong> ${MOSNAME:-N/A}$MOS_VER_STR</p>
</div>
<div style="text-align: right; font-size: 0.8rem;">
$MCC_LINKS_HTML
$MOS_LINKS_HTML
</div>
</div>
<div id="placeholder" class="placeholder-msg">
<h2>Select a section</h2>
<p>Choose one or more sections from the sidebar to analyze the dump.</p>
</div>
EOF
for yaml_file in $(ls "$LOGPATH"/*.yaml 2>/dev/null | sort); do
TITLE=$(basename "$yaml_file" .yaml | tr '_' ' ' | tr '[:lower:]' '[:upper:]')
ANCHOR=$(echo "$TITLE" | tr ' ' '-')
{
echo "<div class='card' id='$ANCHOR'>"
echo " <h2>$TITLE"
echo " <div class='card-header-actions'>"
echo " <div class='search-nav-container'>"
echo " <input type='text' class='card-search' placeholder='Search...' onkeyup=\"performSearch('$ANCHOR', this.value)\">"
echo " <span class='btn-tool' onclick=\"navigateSearch('$ANCHOR', 'prev')\">▲</span>"
echo " <span class='btn-tool' onclick=\"navigateSearch('$ANCHOR', 'next')\">▼</span>"
echo " <span class='search-count'>0/0</span>"
echo " </div>"
echo " <span class='btn-tool' onclick=\"scrollToLimit('$ANCHOR', 'top')\">Top</span>"
echo " <span class='btn-tool' onclick=\"scrollToLimit('$ANCHOR', 'bottom')\">Bottom</span>"
echo " <span class='btn-tool' onclick=\"toggleFullScreen(this, '$ANCHOR')\">Full Screen</span>"
echo " <span class='btn-tool btn-copy' onclick=\"copyToClipboard(this, '$ANCHOR')\">Copy</span>"
echo " <span class='btn-tool wrap-btn' onclick=\"toggleBlockWrap(this, '$ANCHOR')\">Wrap: OFF</span>"
echo " <span class='btn-tool btn-close' onclick=\"closeCard('$ANCHOR')\">✖</span>"
echo " </div>"
echo " </h2>"
echo " <pre class='language-yaml raw-code'><code>"
sed 's/&/\&/g; s/</\</g; s/>/\>/g' "$yaml_file"
echo " </code></pre>"
echo "</div>"
} >>"$HTML_REPORT"
done
cat <<EOF >>"$HTML_REPORT"
</main>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-yaml.min.js"></script>
<script>
window.onload = () => {
const summaryLink = Array.from(document.querySelectorAll('#sidebarList a')).find(a => a.innerText.includes('SUMMARY'));
if (summaryLink) toggleCard(summaryLink, 'EXECUTIVE-SUMMARY-&-CRITICAL-FINDINGS');
};
</script>
</body>
</html>
EOF
echo "✅ Dashboard ready: $HTML_REPORT"
open "$HTML_REPORT" 2>/dev/null