-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
1665 lines (1556 loc) · 68.4 KB
/
index.php
File metadata and controls
1665 lines (1556 loc) · 68.4 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
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
*
* aql - Active Query Listing
*
* Copyright (C) 2018 Kevin Benton - kbcmdba [at] gmail [dot] com
*
* 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.
*
*/
namespace com\kbcmdba\aql ;
session_start() ;
require('vendor/autoload.php');
require('utility.php');
use com\kbcmdba\aql\Libs\Config ;
use com\kbcmdba\aql\Libs\DBConnection ;
use com\kbcmdba\aql\Libs\Exceptions\ConfigurationException ;
use com\kbcmdba\aql\Libs\Exceptions\DaoException;
use com\kbcmdba\aql\Libs\MaintenanceWindow ;
use com\kbcmdba\aql\Libs\Tools ;
use com\kbcmdba\aql\Libs\WebPage ;
// ///////////////////////////////////////////////////////////////////////////
function xTable( $prefix, $linkId, $tableId, $headerFooter, $id, $cols ) {
return <<<HTML
<p />
<a id="{$prefix}$linkId"></a>
<table border=1 cellspacing=0 cellpadding=2 id="{$prefix}{$tableId}Table" width="100%" class="tablesorter aql-listing">
<thead>
$headerFooter
</thead>
<tbody id="{$prefix}{$id}tbodyid">
<tr id="{$prefix}{$id}figment">
<td colspan="$cols">
<center>Data loading</center>
</td>
</tr>
</tbody>
</table>
HTML;
}
// ///////////////////////////////////////////////////////////////////////////
$hostList = Tools::params( 'hosts' ) ;
if ( ! is_array( $hostList ) ) {
$hostList = [ Tools::params('hosts') ] ;
}
$processCols = 15 ;
$processHeaderFooterCols = <<<HTML
<tr class="mytr">
<th>Server</th>
<th>Alert<br />Level</th>
<th>Thread<br />ID</th>
<th>User</th>
<th>From<br />Host:Port</th>
<th>DB</th>
<th>Command <a href="https://dev.mysql.com/doc/refman/5.6/en/thread-commands.html" target="_blank">?</a></th>
<th>Time<br />Secs</th>
<th>Friendly<br>Time</th>
<th>State <a href="https://dev.mysql.com/doc/refman/5.6/en/general-thread-states.html" target="_blank">?</a></th>
<th>R/O</th>
<th>Dupe <span class="help-link" data-tooltip="Possible states are Unique, Similar, Duplicate and Blank. Similar indicates that a query is identical to another query except that the numbers and strings may be different. Duplicate means the entire query is identical to another query.">?</span><br>State</th>
<th>Lock <span class="help-link" data-tooltip="Shows if this query is BLOCKED waiting for a lock, or is BLOCKING other queries.">?</span><br>Status</th>
<th>Info</th>
<th>Actions</th>
</tr>
HTML;
$fullProcessHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$processCols">Full Process Listing</th>
</tr>
$processHeaderFooterCols
HTML;
$NWProcessHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$processCols">Noteworthy Process Listing</th>
</tr>
$processHeaderFooterCols
HTML;
$slaveCols = 8 ;
$slaveHeaderFooterCols = <<<HTML
<tr class="mytr">
<th>Server</th>
<th>Connection<br />Name</th>
<th>Slave Of</th>
<th>Seconds<br />Behind</th>
<th>IO Thread<br />Running</th>
<th>SQL Thread<br />Running</th>
<th>IO Thread<br />Last Error</th>
<th>SQL Thread<br />Last Error</th>
</tr>
HTML;
$fullSlaveHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$slaveCols">Full Slave Status</th>
</tr>
$slaveHeaderFooterCols
HTML;
$NWSlaveHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$slaveCols">Noteworthy Slave Status</th>
</tr>
$slaveHeaderFooterCols
HTML;
$overviewCols = 22 ;
$overviewHeaderFooterCols = <<<HTML
<tr class="mytr">
<th>Server</th>
<th>Version</th>
<th>Longest<br />Running</th>
<th>aQPS</th>
<th>Running <span class="help-link" data-tooltip="Threads actively executing (includes internal threads, replication, event scheduler)">?</span></th>
<th>Conn% <span class="help-link" data-tooltip="Client connections as percentage of max_connections">?</span></th>
<th>Uptime</th>
<th>L0</th>
<th>L1</th>
<th>L2</th>
<th>L3</th>
<th>L4</th>
<th>L9</th>
<th>RO</th>
<th>RW</th>
<th>Blocking</th>
<th>Blocked</th>
<th>Blank</th>
<th>Duplicate</th>
<th>Similar</th>
<th>Threads</th>
<th>Unique</th>
</tr>
HTML;
$fullOverviewHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$overviewCols">Full Status Overview</th>
</tr>
$overviewHeaderFooterCols
HTML;
$NWOverviewHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$overviewCols">Noteworthy Status Overview</th>
</tr>
$overviewHeaderFooterCols
HTML;
// Redis Overview table configuration
$redisOverviewCols = 14 ;
$redisOverviewHeaderFooterCols = <<<HTML
<tr class="mytr">
<th>Server</th>
<th>Version</th>
<th>Uptime</th>
<th>Memory <span class="help-link" data-tooltip="Used memory / max memory">?</span></th>
<th>Mem% <span class="help-link" data-tooltip="Memory usage as percentage of maxmemory">?</span></th>
<th>Clients</th>
<th>Blocked <span class="help-link" data-tooltip="Clients waiting on blocking commands (BLPOP, etc.)">?</span></th>
<th>Hit% <span class="help-link" data-tooltip="Cache hit ratio: hits / (hits + misses)">?</span></th>
<th>Evicted <span class="help-link" data-tooltip="Keys evicted due to maxmemory - indicates data loss!">?</span></th>
<th>Rejected <span class="help-link" data-tooltip="Connections rejected (maxclients exceeded)">?</span></th>
<th>Frag <span class="help-link" data-tooltip="Memory fragmentation ratio (used_memory_rss / used_memory). >1.5 is concerning.">?</span></th>
<th>RDB <span class="help-link" data-tooltip="Time since last RDB save / pending changes">?</span></th>
<th>AOF <span class="help-link" data-tooltip="AOF enabled status">?</span></th>
<th>Level</th>
</tr>
HTML;
$fullRedisOverviewHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$redisOverviewCols">Full Redis Status Overview</th>
</tr>
$redisOverviewHeaderFooterCols
HTML;
$NWRedisOverviewHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$redisOverviewCols">Noteworthy Redis Status Overview</th>
</tr>
$redisOverviewHeaderFooterCols
HTML;
// Redis Slowlog table configuration
$redisSlowlogCols = 5 ;
$redisSlowlogHeaderFooterCols = <<<HTML
<tr class="mytr">
<th>Server</th>
<th>Timestamp</th>
<th>Duration <span class="help-link" data-tooltip="Command execution time in microseconds">?</span></th>
<th>Command</th>
<th>Level</th>
</tr>
HTML;
$fullRedisSlowlogHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$redisSlowlogCols">Full Redis Slowlog</th>
</tr>
$redisSlowlogHeaderFooterCols
HTML;
$NWRedisSlowlogHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$redisSlowlogCols">Noteworthy Redis Slowlog</th>
</tr>
$redisSlowlogHeaderFooterCols
HTML;
// Redis Clients table configuration
$redisClientsCols = 8 ;
$redisClientsHeaderFooterCols = <<<HTML
<tr class="mytr">
<th>Server</th>
<th>Client ID</th>
<th>Address</th>
<th>Name</th>
<th>Age <span class="help-link" data-tooltip="Connection lifetime">?</span></th>
<th>Idle <span class="help-link" data-tooltip="Time since last command">?</span></th>
<th>DB</th>
<th>Command <span class="help-link" data-tooltip="Last command executed">?</span></th>
</tr>
HTML;
$fullRedisClientsHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$redisClientsCols">Redis Connected Clients</th>
</tr>
$redisClientsHeaderFooterCols
HTML;
// Redis Command Stats table configuration
$redisCmdStatsCols = 5 ;
$redisCmdStatsHeaderFooterCols = <<<HTML
<tr class="mytr">
<th>Server</th>
<th>Command</th>
<th>Calls <span class="help-link" data-tooltip="Total number of calls">?</span></th>
<th>Total μs <span class="help-link" data-tooltip="Total microseconds spent on this command">?</span></th>
<th>Avg μs/call <span class="help-link" data-tooltip="Average microseconds per call">?</span></th>
</tr>
HTML;
$fullRedisCmdStatsHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$redisCmdStatsCols">Redis Command Statistics (Top 10)</th>
</tr>
$redisCmdStatsHeaderFooterCols
HTML;
// Redis Memory Stats table configuration (Phase 3)
$redisMemStatsCols = 6 ;
$redisMemStatsHeaderFooterCols = <<<HTML
<tr class="mytr">
<th>Server</th>
<th>Peak Alloc <span class="help-link" data-tooltip="Peak memory allocated since instance started">?</span></th>
<th>Total Alloc <span class="help-link" data-tooltip="Total memory allocated">?</span></th>
<th>Keys</th>
<th>Frag Ratio <span class="help-link" data-tooltip="Memory fragmentation ratio (used_memory_rss / used_memory). >1.5 is concerning.">?</span></th>
<th>Frag Bytes</th>
</tr>
HTML;
$fullRedisMemStatsHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$redisMemStatsCols">Redis Memory Statistics</th>
</tr>
$redisMemStatsHeaderFooterCols
HTML;
// Redis Streams table configuration (Phase 3)
$redisStreamsCols = 5 ;
$redisStreamsHeaderFooterCols = <<<HTML
<tr class="mytr">
<th>Server</th>
<th>Stream Key</th>
<th>Length</th>
<th>Groups</th>
<th>Last Entry ID</th>
</tr>
HTML;
$fullRedisStreamsHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$redisStreamsCols">Redis Streams</th>
</tr>
$redisStreamsHeaderFooterCols
HTML;
// Redis Latency History table configuration (Phase 3)
$redisLatencyHistCols = 4 ;
$redisLatencyHistHeaderFooterCols = <<<HTML
<tr class="mytr">
<th>Server</th>
<th>Event <span class="help-link" data-tooltip="Latency event type (e.g., command, fast-command, fork)">?</span></th>
<th>Time</th>
<th>Latency (ms)</th>
</tr>
HTML;
$fullRedisLatencyHistHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$redisLatencyHistCols">Redis Latency History</th>
</tr>
$redisLatencyHistHeaderFooterCols
HTML;
// Redis Pending Entries table configuration (Phase 3)
$redisPendingCols = 7 ;
$redisPendingHeaderFooterCols = <<<HTML
<tr class="mytr">
<th>Server</th>
<th>Stream</th>
<th>Group</th>
<th>Pending <span class="help-link" data-tooltip="Number of entries awaiting acknowledgment">?</span></th>
<th>Lag <span class="help-link" data-tooltip="Entries in stream not yet delivered to group">?</span></th>
<th>Consumers</th>
<th>ID Range</th>
</tr>
HTML;
$fullRedisPendingHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$redisPendingCols">Redis Stream Pending Entries</th>
</tr>
$redisPendingHeaderFooterCols
HTML;
// Redis Diagnostics table configuration (Phase 3 - LATENCY DOCTOR / MEMORY DOCTOR)
$redisDiagCols = 3 ;
$redisDiagHeaderFooterCols = <<<HTML
<tr class="mytr">
<th>Server</th>
<th>Type</th>
<th>Diagnostic Report</th>
</tr>
HTML;
$fullRedisDiagHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$redisDiagCols">Redis Diagnostics (LATENCY DOCTOR / MEMORY DOCTOR)</th>
</tr>
$redisDiagHeaderFooterCols
HTML;
// Redis Debug Mode tables configuration (only shown when debug=Redis)
$redisDebugKeyspaceCols = 5 ;
$redisDebugKeyspaceHeaderFooterCols = <<<HTML
<tr class="mytr">
<th>Server</th>
<th>Database</th>
<th>Keys</th>
<th>Expiring</th>
<th>Avg TTL</th>
</tr>
HTML;
$fullRedisDebugKeyspaceHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$redisDebugKeyspaceCols">Redis Debug: Keyspace Breakdown</th>
</tr>
$redisDebugKeyspaceHeaderFooterCols
HTML;
$redisDebugOpsCols = 7 ;
$redisDebugOpsHeaderFooterCols = <<<HTML
<tr class="mytr">
<th>Server</th>
<th>Ops/sec</th>
<th>Input KB/s</th>
<th>Output KB/s</th>
<th>Total Cmds</th>
<th>Total In</th>
<th>Total Out</th>
</tr>
HTML;
$fullRedisDebugOpsHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$redisDebugOpsCols">Redis Debug: Throughput (Ops/sec & Network)</th>
</tr>
$redisDebugOpsHeaderFooterCols
HTML;
$redisDebugCpuCols = 5 ;
$redisDebugCpuHeaderFooterCols = <<<HTML
<tr class="mytr">
<th>Server</th>
<th>CPU Sys</th>
<th>CPU User</th>
<th>CPU Sys (Children)</th>
<th>CPU User (Children)</th>
</tr>
HTML;
$fullRedisDebugCpuHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$redisDebugCpuCols">Redis Debug: CPU Usage (seconds)</th>
</tr>
$redisDebugCpuHeaderFooterCols
HTML;
$redisDebugPersistCols = 5 ;
$redisDebugPersistHeaderFooterCols = <<<HTML
<tr class="mytr">
<th>Server</th>
<th>RDB Status</th>
<th>RDB Time</th>
<th>AOF Status</th>
<th>AOF Time</th>
</tr>
HTML;
$fullRedisDebugPersistHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$redisDebugPersistCols">Redis Debug: Persistence Status</th>
</tr>
$redisDebugPersistHeaderFooterCols
HTML;
$redisDebugBuffersCols = 9 ;
$redisDebugBuffersHeaderFooterCols = <<<HTML
<tr class="mytr">
<th>Server</th>
<th>Client ID</th>
<th>Address</th>
<th>Name</th>
<th>Output Buf</th>
<th>Query Buf</th>
<th>Query Buf Free</th>
<th>Cmd</th>
<th>Flags</th>
</tr>
HTML;
$fullRedisDebugBuffersHeaderFooter = <<<HTML
<tr class="mytr">
<th colspan="$redisDebugBuffersCols">Redis Debug: Client Buffer Details</th>
</tr>
$redisDebugBuffersHeaderFooterCols
HTML;
$muted = Tools::param('mute') === "1" ;
$page = new WebPage('Active Queries List');
$config = new Config();
$redisEnabled = $config->getRedisEnabled() ;
// Get DB types in use for per-type debug checkboxes
$cfgDbc = new DBConnection() ;
$cfgDbh = $cfgDbc->getConnection() ;
$dbTypesInUse = $config->getDbTypesInUse( $cfgDbh ) ;
// Debug mode - single param: debug=MySQL,Redis,AQL (AQL means all)
// Backward compat: debug=1 maps to debug=AQL
$debugParam = Tools::param('debug') ;
$debugTypes = [] ;
$debugAQL = false ;
if ( $debugParam === "1" || $debugParam === "AQL" ) {
$debugAQL = true ;
$debugTypes = $dbTypesInUse ;
} elseif ( ! empty( $debugParam ) ) {
$requestedTypes = array_map( 'trim', explode( ',', $debugParam ) ) ;
if ( in_array( 'AQL', $requestedTypes ) ) {
$debugAQL = true ;
$debugTypes = $dbTypesInUse ;
} else {
$debugTypes = array_intersect( $requestedTypes, $dbTypesInUse ) ;
}
}
// Legacy $debug for backward compat with existing code
$debug = $debugAQL ;
// Scoreboard debug - separate from DBType debug
$debugScoreboard = Tools::param('debugScoreboard') === '1' ;
$defaultRefresh = $config->getDefaultRefresh() ;
$minRefresh = $config->getMinRefresh() ;
$reloadSeconds = Tools::param('refresh', $defaultRefresh) ;
if ( $reloadSeconds < $minRefresh ) {
$reloadSeconds = $minRefresh ;
}
$js = [ 'Blocks' => 0
, 'AjaxCalls' => ''
] ;
try {
$config = new Config();
}
catch ( ConfigurationException $e ) {
print("Has AQL been configured? " . $e->getMessage());
exit(1);
}
$dbc = new DBConnection();
$dbh = $dbc->getConnection();
$dbh->set_charset('utf8');
// Fetch active maintenance windows for display
$activeMaintenanceWindows = [] ;
if ( $config->getEnableMaintenanceWindows() ) {
$activeMaintenanceWindows = MaintenanceWindow::getAllActiveWindows( $dbh ) ;
}
// Get enabled DB types from config (reads types from DDL, filters by config settings)
$enabledDbTypes = $config->getEnabledDbTypes( $dbh ) ;
$dbTypeList = empty( $enabledDbTypes ) ? "''" : "'" . implode( "', '", $enabledDbTypes ) . "'";
$allHostsQuery = <<<SQL
SELECT CONCAT( h.hostname, ':', h.port_number )
, h.alert_crit_secs
, h.alert_warn_secs
, h.alert_info_secs
, h.alert_low_secs
FROM aql_db.host AS h
WHERE h.decommissioned = 0
AND h.should_monitor = 1
AND h.db_type IN ( $dbTypeList )
ORDER BY h.hostname, h.port_number
SQL;
$in = "'"
. implode("', '", array_map( [ $dbh, 'real_escape_string' ], $hostList ) )
. "'" ;
$someHostsQuery = <<<SQL
SELECT CONCAT( h.hostname, ':', h.port_number )
, h.alert_crit_secs
, h.alert_warn_secs
, h.alert_info_secs
, h.alert_low_secs
FROM aql_db.host AS h
WHERE h.decommissioned = 0
AND CONCAT( h.hostname, ':', h.port_number ) IN ( $in )
AND h.db_type IN ( 'MySQL', 'MariaDB', 'InnoDBCluster' )
ORDER BY h.hostname, h.port_number
SQL ;
$allHostGroupsQuery = <<<SQL
SELECT hg.host_group_id, hg.tag, CONCAT( '"', GROUP_CONCAT( CONCAT( h.hostname, ':', h.port_number ) SEPARATOR '", "' ), '"' )
FROM host_group AS hg
LEFT
JOIN host_group_map AS hgm
USING ( host_group_id )
LEFT
JOIN host AS h
USING ( host_id )
WHERE h.db_type IN ( 'MySQL', 'MariaDB', 'InnoDBCluster' )
GROUP BY hg.host_group_id
ORDER BY hg.tag
SQL ;
$allGroupsList = '' ;
$allHostsList = '' ;
$baseUrl = $config->getBaseUrl() ;
$showAllHosts = ( 0 === count( $hostList ) ) ;
$hgjson = 'hostGroupMap = { ' ;
try {
$hgResult = $dbh->query( $allHostGroupsQuery ) ;
if ( ! $hgResult ) {
throw new \ErrorException( "Query failed: $allHostGroupsQuery\n Error: " . $dbh->error ) ;
}
while ( $row = $hgResult->fetch_row() ) {
$hostGroupId = $row[ 0 ] ;
$hostGroupTag = $row[ 1 ] ;
$hostGroupHostList = ( '""' === $row[ 2 ] ) ? '' : $row[ 2 ] ;
$allGroupsList .= " <option value=\"$hostGroupTag\">$hostGroupTag</option>\n" ;
$hgjson .= "\"$hostGroupTag\": [$hostGroupHostList]," ;
}
$hgResult->close() ;
$hgjson .= ' }' ;
$result = $dbh->query( $allHostsQuery ) ;
if ( ! $result ) {
throw new \ErrorException( "Query failed: $allHostsQuery\n Error: " . $dbh->error ) ;
}
while ( $row = $result->fetch_row() ) {
$serverName = htmlentities( $row[0] ) ;
$selected = ( in_array( $row[0], $hostList ) ) ? 'selected="selected"' : '' ;
$allHostsList .= " <option value=\"$serverName\" $selected>$serverName</option>\n" ;
if ( $showAllHosts ) {
processHost($js, $row[0], $baseUrl, $row[1], $row[2], $row[3], $row[4]);
}
}
if ( ! $showAllHosts ) {
$result = $dbh->query( $someHostsQuery );
if (! $result) {
throw new \ErrorException( "Query failed: $someHostsQuery\n Error: " . $dbh->error );
}
while ($row = $result->fetch_row()) {
processHost($js, $row[0], $baseUrl, $row[1], $row[2], $row[3], $row[4]);
}
}
$ajaxCalls = $js['AjaxCalls'];
$totalRequests = $js['Blocks'];
$jiraConfigJson = json_encode([
'enabled' => $config->getJiraEnabled(),
'baseUrl' => $config->getIssueTrackerBaseUrl(),
'projectId' => $config->getJiraProjectId(),
'issueTypeId' => $config->getJiraIssueTypeId(),
'queryHashFieldId' => $config->getJiraQueryHashFieldId()
]);
// Build Redis-specific JS conditionally
$redisEnabledJs = $redisEnabled ? 'true' : 'false' ;
$speechAlertsEnabledJs = $config->getEnableSpeechAlerts() ? 'true' : 'false' ;
$redisTableInitJs = '' ;
$redisFigmentRemoveJs = '' ;
$redisTableSortJs = '' ;
if ( $redisEnabled ) {
$redisTableInitJs = <<<JSREDIS
\$("#nwredisoverviewtbodyid").html( '<tr id="nwRedisOverviewfigment"><td colspan="$redisOverviewCols"><center>Data loading</center></td></tr>' ) ;
\$("#nwredisslowlogtbodyid").html( '<tr id="nwRedisSlowlogfigment"><td colspan="$redisSlowlogCols"><center>Data loading</center></td></tr>' ) ;
\$("#fullredisoverviewtbodyid").html( '<tr id="fullRedisOverviewfigment"><td colspan="$redisOverviewCols"><center>Data loading</center></td></tr>' ) ;
\$("#fullredisslowlogtbodyid").html( '<tr id="fullRedisSlowlogfigment"><td colspan="$redisSlowlogCols"><center>Data loading</center></td></tr>' ) ;
\$("#fullredisclientstbodyid").html( '<tr id="fullRedisClientsfigment"><td colspan="$redisClientsCols"><center>Data loading</center></td></tr>' ) ;
\$("#fullrediscmdstatstbodyid").html( '<tr id="fullRedisCmdStatsfigment"><td colspan="$redisCmdStatsCols"><center>Data loading</center></td></tr>' ) ;
\$("#fullredismemstatstbodyid").html( '<tr id="fullRedisMemStatsfigment"><td colspan="$redisMemStatsCols"><center>Data loading</center></td></tr>' ) ;
\$("#fullredisstreamstbodyid").html( '<tr id="fullRedisStreamsfigment"><td colspan="$redisStreamsCols"><center>Data loading</center></td></tr>' ) ;
\$("#fullredislatencyhisttbodyid").html( '<tr id="fullRedisLatencyHistfigment"><td colspan="$redisLatencyHistCols"><center>Data loading</center></td></tr>' ) ;
\$("#fullredispendingtbodyid").html( '<tr id="fullRedisPendingfigment"><td colspan="$redisPendingCols"><center>Data loading</center></td></tr>' ) ;
\$("#fullredisdiagtbodyid").html( '<tr id="fullRedisDiagfigment"><td colspan="$redisDiagCols"><center>Data loading</center></td></tr>' ) ;
JSREDIS;
$redisFigmentRemoveJs = <<<JSREDIS
\$("#nwRedisOverviewfigment").remove() ;
\$("#nwRedisSlowlogfigment").remove() ;
\$("#fullRedisOverviewfigment").remove() ;
\$("#fullRedisSlowlogfigment").remove() ;
\$("#fullRedisClientsfigment").remove() ;
\$("#fullRedisCmdStatsfigment").remove() ;
\$("#fullRedisMemStatsfigment").remove() ;
\$("#fullRedisStreamsfigment").remove() ;
\$("#fullRedisLatencyHistfigment").remove() ;
\$("#fullRedisPendingfigment").remove() ;
\$("#fullRedisDiagfigment").remove() ;
JSREDIS;
$redisTableSortJs = <<<JSREDIS
// Redis tables
initTableSortWithUrl('#nwRedisOverviewTable', 'nwredisoverview', [[4, 1]]); // Mem% desc
initTableSortWithUrl('#nwRedisSlowlogTable', 'nwredisslowlog', [[2, 1]]); // Duration desc
initTableSortWithUrl('#fullRedisOverviewTable', 'fullredisoverview', [[4, 1]]);
initTableSortWithUrl('#fullRedisSlowlogTable', 'fullredisslowlog', [[2, 1]]);
initTableSortWithUrl('#fullRedisClientsTable', 'fullredisclients', [[5, 1]]); // Idle desc
initTableSortWithUrl('#fullRedisCmdStatsTable', 'fullrediscmdstats', [[2, 1]]); // Calls desc
initTableSortWithUrl('#fullRedisMemStatsTable', 'fullredismemstats', [[4, 1]]); // Frag ratio desc
initTableSortWithUrl('#fullRedisStreamsTable', 'fullredisstreams', [[2, 1]]); // Length desc
initTableSortWithUrl('#fullRedisLatencyHistTable', 'fullredislatencyhist', [[3, 1]]); // Latency desc
initTableSortWithUrl('#fullRedisPendingTable', 'fullredispending', [[3, 1]]); // Pending desc
initTableSortWithUrl('#fullRedisDiagTable', 'fullredisdiag', [[0, 0]]); // Server asc
JSREDIS;
}
// Redis Debug Mode JS (only when debug=Redis is enabled)
$redisDebugTableInitJs = '' ;
$redisDebugFigmentRemoveJs = '' ;
$redisDebugTableSortJs = '' ;
if ( $redisEnabled && in_array( 'Redis', $debugTypes ) ) {
$redisDebugTableInitJs = <<<JSREDIS
\$("#redisdebugkeyspacetbodyid").html( '<tr id="redisDebugKeyspacefigment"><td colspan="$redisDebugKeyspaceCols"><center>Data loading</center></td></tr>' ) ;
\$("#redisdebugopstbodyid").html( '<tr id="redisDebugOpsfigment"><td colspan="$redisDebugOpsCols"><center>Data loading</center></td></tr>' ) ;
\$("#redisdebugcputbodyid").html( '<tr id="redisDebugCpufigment"><td colspan="$redisDebugCpuCols"><center>Data loading</center></td></tr>' ) ;
\$("#redisdebugpersisttbodyid").html( '<tr id="redisDebugPersistfigment"><td colspan="$redisDebugPersistCols"><center>Data loading</center></td></tr>' ) ;
\$("#redisdebugbufferstbodyid").html( '<tr id="redisDebugBuffersfigment"><td colspan="$redisDebugBuffersCols"><center>Data loading</center></td></tr>' ) ;
JSREDIS;
$redisDebugFigmentRemoveJs = <<<JSREDIS
\$("#redisDebugKeyspacefigment").remove() ;
\$("#redisDebugOpsfigment").remove() ;
\$("#redisDebugCpufigment").remove() ;
\$("#redisDebugPersistfigment").remove() ;
\$("#redisDebugBuffersfigment").remove() ;
JSREDIS;
$redisDebugTableSortJs = <<<JSREDIS
// Redis Debug tables
initTableSortWithUrl('#fullRedisDebugKeyspaceTable', 'fullredisdebugkeyspace', [[0, 0]]); // Server asc
initTableSortWithUrl('#fullRedisDebugOpsTable', 'fullredisdebugops', [[1, 1]]); // Ops/sec desc
initTableSortWithUrl('#fullRedisDebugCpuTable', 'fullredisdebugcpu', [[0, 0]]); // Server asc
initTableSortWithUrl('#fullRedisDebugPersistTable', 'fullredisdebugpersist', [[0, 0]]); // Server asc
initTableSortWithUrl('#fullRedisDebugBuffersTable', 'fullredisdebugbuffers', [[4, 1]]); // Output Buf desc
JSREDIS;
}
$page->setBottom(
<<<JS
<script>
var timeoutId = null;
var autoRefreshPaused = false ;
var reloadSeconds = $reloadSeconds * 1000 ;
var jiraConfig = {$jiraConfigJson};
var redisEnabled = $redisEnabledJs ;
var speechAlertsEnabled = $speechAlertsEnabledJs ;
// Table column counts for dynamic colspan calculation
var colCounts = {
overview: $overviewCols,
process: $processCols,
redisOverview: $redisOverviewCols
};
// Debug logging: enable with ?refresh_debug=1 in URL
var REFRESH_DEBUG = new URLSearchParams(window.location.search).get('refresh_debug') === '1';
var refreshLog = function() { if (REFRESH_DEBUG) console.log.apply(console, ['[refresh]'].concat(Array.prototype.slice.call(arguments))); };
// Reset the refresh timer when user interacts with form controls
function resetRefreshTimer() {
if ( autoRefreshPaused ) return ;
if (timeoutId !== null) {
clearTimeout(timeoutId);
timeoutId = setTimeout(function() { window.location.reload(1); }, reloadSeconds);
refreshLog('Timer reset, next refresh in', reloadSeconds / 1000, 'seconds');
}
}
// Toggle automatic page refresh on/off
function toggleAutoRefresh() {
autoRefreshPaused = !autoRefreshPaused ;
var btn = \$('#pauseRefreshBtn') ;
if ( autoRefreshPaused ) {
if ( timeoutId !== null ) {
clearTimeout( timeoutId ) ;
timeoutId = null ;
}
btn.html( '▶ Resume Auto-Refresh' ) ;
btn.attr( 'title', 'Resume automatic page refresh' ) ;
refreshLog( 'Auto-refresh paused' ) ;
} else {
timeoutId = setTimeout( function() { window.location.reload( 1 ) ; }, reloadSeconds ) ;
btn.html( '⏸ Pause Auto-Refresh' ) ;
btn.attr( 'title', 'Pause automatic page refresh' ) ;
refreshLog( 'Auto-refresh resumed, next refresh in', reloadSeconds / 1000, 'seconds' ) ;
}
}
///////////////////////////////////////////////////////////////////////////////
// Track AJAX completion - each request calls onAjaxComplete when done (success or failure)
var totalRequests = $totalRequests ;
var completedRequests = 0 ;
var pendingHosts = {} ;
function getPendingHostsList() {
return Object.keys( pendingHosts ).join( ', ' ) ;
}
function onAjaxComplete() {
completedRequests++ ;
// Update progress indicator - show count and pending hosts
var pending = Object.keys( pendingHosts ) ;
if ( pending.length > 0 && pending.length <= 5 ) {
\$('#ajaxProgress').html( completedRequests + '/' + totalRequests + '<br><small>Waiting: ' + pending.join( ', ' ) + '</small>' ) ;
} else if ( pending.length > 5 ) {
\$('#ajaxProgress').html( completedRequests + '/' + totalRequests + '<br><small>Waiting: ' + pending.length + ' hosts</small>' ) ;
} else {
\$('#ajaxProgress').text( completedRequests + '/' + totalRequests ) ;
}
if ( completedRequests >= totalRequests ) {
finalizeLoad() ;
}
}
function finalizeLoad() {
// Remove "Data loading" placeholders
\$("#nwSlavefigment").remove() ;
\$("#nwOverviewfigment").remove() ;
\$("#nwProcessfigment").remove() ;
\$("#fullSlavefigment").remove() ;
\$("#fullOverviewfigment").remove() ;
\$("#fullProcessfigment").remove() ;
$redisFigmentRemoveJs
$redisDebugFigmentRemoveJs
\$("#fullProcessTable").tablesorter( {sortList: [[1, 1], [7, 1]]} ) ;
initTableSorting();
displayCharts() ;
updateDbTypeOverview() ;
updateScoreboard() ;
updateLocalSilencesUI() ;
displayRenderTimes() ;
scrollToHashIfPresent() ;
\$('#ajaxProgress').text( 'done' ) ;
}
function loadPage() {
resetDbTypeStats() ;
ajaxRenderTimes = {} ;
completedRequests = 0 ;
pendingHosts = {} ;
\$("#nwslavetbodyid").html( '<tr id="nwSlavefigment"><td colspan="$slaveCols"><center>Data loading <span id=\"ajaxProgress\">0/$totalRequests</span></center></td></tr>' ) ;
\$("#nwoverviewtbodyid").html( '<tr id="nwOverviewfigment"><td colspan="$overviewCols"><center>Data loading</center></td></tr>' ) ;
\$("#nwprocesstbodyid").html( '<tr id="nwProcessfigment"><td colspan="$processCols"><center>Data loading</center></td></tr>' ) ;
\$("#fullslavetbodyid").html( '<tr id="fullSlavefigment"><td colspan="$slaveCols"><center>Data loading</center></td></tr>' ) ;
\$("#fulloverviewtbodyid").html( '<tr id="fullOverviewfigment"><td colspan="$overviewCols"><center>Data loading</center></td></tr>' ) ;
\$("#fullprocesstbodyid").html( '<tr id="fullProcessfigment"><td colspan="$processCols"><center>Data loading</center></td></tr>' ) ;
$redisTableInitJs
$redisDebugTableInitJs
// Fire all AJAX requests - each processes its data immediately on success
// Failed requests show error and still count toward completion
$ajaxCalls
\$('#nwprocesstbodyid').on('click', '.morelink', flipFlop) ;
\$('#fullprocesstbodyid').on('click', '.morelink', flipFlop) ;
if ( !autoRefreshPaused ) {
timeoutId = setTimeout( function() { window.location.reload( 1 ) ; }, reloadSeconds ) ;
}
}
\$(document).ready( loadPage ) ;
// Populate Settings dropdown with page controls (content defined in body HTML as hidden divs)
\$(document).ready(function() {
// Move hidden content into Settings dropdown placeholders
\$('#settingsRefreshItem').html( \$('#settingsRefreshContent').html() ).show() ;
\$('#settingsDebugItem').html( \$('#settingsDebugContent').html() ).show() ;
// Remove the hidden source divs
\$('#settingsRefreshContent, #settingsDebugContent').remove() ;
// Sync settings to host form when any setting changes
\$(document).on('change input', '#settingsRefreshSeconds, #settingsDebugScoreboard, .settings-debug-type-cb', syncSettingsToHostForm) ;
}) ;
// Apply settings from the navbar dropdown
function applySettings() {
var params = [] ;
// Carry forward selected hosts
\$('#hostList option:selected').each(function() {
params.push( 'hosts[]=' + encodeURIComponent( \$(this).val() ) ) ;
}) ;
// Refresh seconds
var refresh = \$('#settingsRefreshSeconds').val() ;
if ( refresh ) {
params.push( 'refresh=' + encodeURIComponent( refresh ) ) ;
}
// Debug param
var debugParts = [] ;
if ( \$('#settingsDebugAQL').is(':checked') ) {
debugParts.push('AQL') ;
} else {
\$('.settings-debug-type-cb:checked').each(function() {
debugParts.push( \$(this).data('type') ) ;
}) ;
}
if ( debugParts.length > 0 ) {
params.push( 'debug=' + encodeURIComponent( debugParts.join(',') ) ) ;
}
// Scoreboard debug
if ( \$('#settingsDebugScoreboard').is(':checked') ) {
params.push( 'debugScoreboard=1' ) ;
}
var url = window.location.pathname ;
if ( params.length > 0 ) {
url += '?' + params.join('&') ;
}
window.location = url ;
}
// Build debug param from Settings dropdown checkboxes and sync to host form
function updateSettingsDebugParam() {
if ( \$('#settingsDebugAQL').is(':checked') ) {
\$('.settings-debug-type-cb').prop('checked', false) ;
}
syncSettingsToHostForm() ;
}
// Keep the host form's hidden fields in sync with Settings dropdown values
function syncSettingsToHostForm() {
// Refresh seconds
var refresh = \$('#settingsRefreshSeconds').val() ;
if ( refresh ) {
\$('#hostFormRefresh').val( refresh ) ;
}
// Debug param
var debugParts = [] ;
if ( \$('#settingsDebugAQL').is(':checked') ) {
debugParts.push('AQL') ;
} else {
\$('.settings-debug-type-cb:checked').each(function() {
debugParts.push( \$(this).data('type') ) ;
}) ;
}
\$('#hostFormDebug').val( debugParts.join(',') ) ;
// Scoreboard
\$('#hostFormDebugScoreboard').val( \$('#settingsDebugScoreboard').is(':checked') ? '1' : '0' ) ;
}
// Reset refresh timer when user interacts with form controls
\$(document).ready(function() {
// Host and group selection dropdowns
\$('#hostList, #groupSelection').on('change focus', resetRefreshTimer);
// Refresh interval and debug checkbox
\$('input[name="refresh"], input[name="debug"]').on('focus change input', resetRefreshTimer);
// Mute duration inputs and datetime picker
\$('#muteDays, #muteHours, #muteMinutes, #muteUntilDateTime').on('focus change input', resetRefreshTimer);
// Navigation menu dropdowns - reset timer when opened or interacted with
\$('.navbar .dropdown').on('show.bs.dropdown hide.bs.dropdown', resetRefreshTimer);
\$('.navbar .dropdown-menu').on('click', 'a', resetRefreshTimer);
refreshLog('Event listeners attached for refresh timer reset');
});
// Initialize sorting for data tables (uses functions from common.js)
function initTableSorting() {
// Noteworthy tables
initTableSortWithUrl('#nwSlaveTable', 'nwslave', [[3, 1]]); // Seconds Behind desc
initTableSortWithUrl('#nwOverviewTable', 'nwoverview', [[2, 1]]); // Longest Running desc
initTableSortWithUrl('#nwProcessTable', 'nwprocess', [[7, 1]]); // Time Secs desc
// Full tables
initTableSortWithUrl('#fullSlaveTable', 'fullslave', [[3, 1]]); // Seconds Behind desc
initTableSortWithUrl('#fullOverviewTable', 'fulloverview', [[2, 1]]); // Longest Running desc
$redisTableSortJs
$redisDebugTableSortJs
// Summary tables
initTableSortWithUrl('#versionSummaryTable', 'versionsummary', [[0, 0]]); // Version asc
refreshLog('Table sorting initialized');
}
$hgjson
function addGroupSelection() {
var elements = document.getElementById( 'groupSelection' ).options ;
var selectedIndex = elements.selectedIndex ;
var hostGroupName = elements[ selectedIndex ].attributes[ 0 ].value ;
var selectedHostList = hostGroupMap[ hostGroupName ] ;
var hostList = document.getElementById( 'hostList' ) ;
for ( var i = 0 ; i < selectedHostList.length ; i++ ) {
for ( var j = 0 ; j < hostList.length ; j++ ) {
if ( hostList[ j ].attributes[ 0 ].value == selectedHostList[ i ] ) {
hostList[ j ].selected = true ;
}
}
}
}
</script>
JS
);
$now = Tools::currentTimestamp();
$aqlVersion = Config::VERSION ;
$debugAQLChecked = ( $debugAQL ) ? 'checked="checked"' : '' ;
$debugScoreboardChecked = ( $debugScoreboard ) ? 'checked="checked"' : '' ;
$debugScoreboardValue = ( $debugScoreboard ) ? '1' : '0' ;
// Generate per-type debug checkboxes for Settings dropdown
$settingsDebugTypeCheckboxes = '' ;
foreach ( $dbTypesInUse as $dbType ) {
$checked = in_array( $dbType, $debugTypes ) && ! $debugAQL ? 'checked="checked"' : '' ;
$settingsDebugTypeCheckboxes .= '<input type="checkbox" class="settings-debug-type-cb" data-type="' . htmlspecialchars( $dbType ) . '" ' . $checked . ' onchange="updateSettingsDebugParam()"/> ' . htmlspecialchars( $dbType ) . '<br />' ;
}
// Build initial debug param value for hidden input
$debugParamValue = '' ;
if ( $debugAQL ) {
$debugParamValue = 'AQL' ;
} elseif ( ! empty( $debugTypes ) ) {
$debugParamValue = implode( ',', $debugTypes ) ;
}
$muteButtonText = ( $muted ) ? 'Unmute Alerts' : 'Mute Alerts' ;
$muteToggleValue = ( $muted ) ? '0' : '1' ;
$cb = function ($fn) { return $fn; };
// Generate group options for silence modal
$groupOptionsHtml = '' ;
try {
$groupDbc = new DBConnection() ;
$groupDbh = $groupDbc->getConnection() ;
$groupResult = $groupDbh->query( "SELECT host_group_id, tag, short_description FROM aql_db.host_group ORDER BY tag" ) ;
if ( $groupResult !== false ) {
while ( $row = $groupResult->fetch_assoc() ) {
$groupOptionsHtml .= " <option value=\"" . intval( $row['host_group_id'] ) . "\">" . htmlspecialchars( $row['tag'] . ' - ' . $row['short_description'] ) . "</option>\n" ;
}
$groupResult->close() ;
}
} catch ( \Exception $e ) {
// Silently ignore errors loading groups
}
// Build active maintenance windows display HTML
$maintenanceWindowsHtml = '' ;
if ( ! empty( $activeMaintenanceWindows ) ) {
$maintenanceWindowsHtml = '<div id="activeMaintenanceWindows" class="maintenance-windows-panel">' ;
$maintenanceWindowsHtml .= '<h4>Active Maintenance Windows</h4>' ;
$maintenanceWindowsHtml .= '<table class="maintenance-windows-table">' ;
$maintenanceWindowsHtml .= '<thead><tr><th class="mw-type">Type</th><th class="mw-desc">Description</th><th class="mw-details">Details</th><th class="mw-hosts">Affected Hosts</th></tr></thead>' ;
$maintenanceWindowsHtml .= '<tbody>' ;
foreach ( $activeMaintenanceWindows as $win ) {
$typeIcon = ( $win['windowType'] === 'adhoc' ) ? '🔇' : '🔧' ;
$typeLabel = ucfirst( $win['windowType'] ) ;
$desc = htmlspecialchars( $win['description'] ?? 'No description' ) ;
// Build details column
$details = '' ;
if ( $win['windowType'] === 'adhoc' && ! empty( $win['expiresAt'] ) ) {
$details = 'Expires: ' . htmlspecialchars( $win['expiresAt'] ) ;
} elseif ( ! empty( $win['timeWindow'] ) ) {
$details = htmlspecialchars( $win['timeWindow'] ) ;
if ( ! empty( $win['daysOfWeek'] ) ) {
$details .= ' (' . htmlspecialchars( $win['daysOfWeek'] ) . ')' ;
}
}
// Build hosts list
$hostsHtml = '' ;
if ( ! empty( $win['hosts'] ) ) {
$hostsHtml = implode( ', ', array_map( 'htmlspecialchars', $win['hosts'] ) ) ;
}
$maintenanceWindowsHtml .= "<tr><td class=\"mw-type\">{$typeIcon} {$typeLabel}</td><td class=\"mw-desc\">{$desc}</td><td class=\"mw-details\">{$details}</td><td class=\"mw-hosts\">{$hostsHtml}</td></tr>" ;
}
$maintenanceWindowsHtml .= '</tbody></table></div>' ;