Skip to content

Commit 84386fb

Browse files
committed
sort lb_urls before use them
1 parent 626cc77 commit 84386fb

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

public/index.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
array_push($lbs_array, array('name'=> $lb_path, 'url' => $baseurl . trim($lb_path)));
3030
}
3131
}
32-
32+
ksort($lb_urls);
3333
foreach ($lb_urls as $key => $value) {
3434
$value_parts = explode("#", $value);
3535
$name = str_replace('_', ' ',$value_parts[0]);
@@ -75,7 +75,7 @@ function secondsToTime($seconds) {
7575
<meta charset="utf-8">
7676
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7777
<meta name="viewport" content="width=device-width, initial-scale=0.7">
78-
<?php if ($refresh) echo '<META HTTP-EQUIV="Refresh" CONTENT="' . $refresh_interval . '">' ?>
78+
<?php if ($refresh) echo '<META HTTP-EQUIV="Refresh" CONTENT="' . $refresh_interval . '">' ?>
7979
<title>HaProxy Visualizer </title>
8080
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
8181
<style>
@@ -103,7 +103,7 @@ function secondsToTime($seconds) {
103103
<a class="refresh-tooltip" href="?<?php echo ($refresh) ? 'norefresh' : '' ?>">
104104
<?php echo ($refresh) ? 'Auto-Refresh Enabled' : 'Auto-Refresh Disabled'; ?> </a>
105105
<div class="">
106-
<div class="d-flex flex-row flex-wrap justify-content-center">
106+
<div class="d-flex flex-row flex-wrap justify-content-center">
107107
<?php
108108
foreach ($lbs_data as $lb_name=>$lb_stats) {
109109
echo '<div class="table-box">';
@@ -114,23 +114,23 @@ function secondsToTime($seconds) {
114114
$lb_servers = array_filter($lb_stats, function ($var) {
115115
return ($var['pxname'] == 'servers');
116116
});
117-
117+
118118
foreach ($lb_servers as $lb_server) {
119-
119+
120120
$rowStyle = "background: " . (($lb_server['status'] == 'UP') ? 'lightgreen' : 'lightcoral');
121-
122-
123-
echo '<tr style="'. $rowStyle . '"><td>' . $lb_server['svname']. '</td><td> '
124-
. $lb_server['status'] . '</td><td>'
125-
. secondsToTime( $lb_server['lastchg']) . '</td><td>'
126-
. $lb_server['check_status'] . "/"
127-
. $lb_server['check_code'] . " in "
128-
. $lb_server['check_duration'] . 'ms</td><td>'
121+
122+
123+
echo '<tr style="'. $rowStyle . '"><td>' . $lb_server['svname']. '</td><td> '
124+
. $lb_server['status'] . '</td><td>'
125+
. secondsToTime( $lb_server['lastchg']) . '</td><td>'
126+
. $lb_server['check_status'] . "/"
127+
. $lb_server['check_code'] . " in "
128+
. $lb_server['check_duration'] . 'ms</td><td>'
129129
. secondsToTime($lb_server['downtime']) . '</td></tr>';
130130
}
131131

132132
echo '</tbody></table>';
133-
echo '</div>';
133+
echo '</div>';
134134
}
135135
?>
136136
</div>
@@ -140,5 +140,5 @@ function secondsToTime($seconds) {
140140
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
141141
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
142142
</body>
143-
144-
</html>
143+
144+
</html>

0 commit comments

Comments
 (0)