Project

General

Profile

Feature #14886 ยป gateway.widget.php.patch

patch - Patrik Stahlman, 10/16/2023 07:24 PM

View differences:

gateways.widget.php 2023-10-16 21:06:58.663574000 +0200
54 54
                       if (in_array($gname, $hiddengateways)) {
55 55
                               continue;
56 56
                       }
57

  
58
                       if ($gateways_status[$gname]) {
59
                               if (stristr($gateways_status[$gname]['status'], "online")) {
60
                                       switch ($gateways_status[$gname]['substatus']) {
61
                                               case "highloss":
62
                                                       $online = gettext("Danger, Packetloss");
63
                                                       $bgcolor = "danger";
64
                                                       break;
65
                                               case "highdelay":
66
                                                       $online = gettext("Danger, Latency");
67
                                                       $bgcolor = "danger";
68
                                                       break;
69
                                               case "loss":
70
                                                       $online = gettext("Warning, Packetloss");
71
                                                       $bgcolor = "warning";
72
                                                       break;
73
                                               case "delay":
74
                                                       $online = gettext("Warning, Latency");
75
                                                       $bgcolor = "warning";
76
                                                       break;
77
                                               default:
78
                                                       if ($status['monitor_disable'] || ($status['monitorip'] == "none")) {
79
                                                               $online = gettext("Online <br/>(unmonitored)");
80
                                                       } else {
81
                                                               $online = gettext("Online");
82
                                                       }
83
                                                       $bgcolor = "success";
84
                                       }
85
                               } elseif (stristr($gateways_status[$gname]['status'], "down")) {
86
                                       $bgcolor = "danger";
87
                                       switch ($gateways_status[$gname]['substatus']) {
88
                                               case "force_down":
89
                                                       $online = gettext("Offline (forced)");
90
                                                       break;
91
                                               case "highloss":
92
                                                       $online = gettext("Offline, Packetloss");
93
                                                       break;
94
                                               case "highdelay":
95
                                                       $online = gettext("Offline, Latency");
96
                                                       break;
97
                                               default:
98
                                                       $online = gettext("Offline");
99
                                       }
100
                               } else {
101
                                       $online = gettext("Pending");
102
                                       $bgcolor = "info";  // lightgray
103
                               }
104
                       } else {
105
                               $online = gettext("Unknown");
106
                               $bgcolor = "info";  // lightblue
107
                       }
108

  
57 109
                       if (isset($gateway['inactive'])) {
58 110
                               $title = gettext("Gateway inactive, interface is missing");
59 111
                               $icon = 'fa-times-circle-o';
......
72 124

  
73 125
                       $gw_displayed = true;
74 126
                       $rtnstr .= "<tr>\n";
75
                       $rtnstr .=      "<td title='{$title}'><i class='fa {$icon}'></i></td>\n";
127
                       $rtnstr .=      "<td title='{$title}'><i class='fa {$icon} text-{$bgcolor}'></i></td>\n";
76 128
                       $rtnstr .=      "<td title='{$gtitle}'>\n";
77 129
                       $rtnstr .= htmlspecialchars($gateway['name']);
78 130
                       if (isset($gateway['isdefaultgw'])) {
......
124 176
                       $rtnstr .=              "</b>";
125 177
                       $rtnstr .=              "</div>\n";
126 178
                       $rtnstr .=      "</td>\n";
127

  
128
                       if ($gateways_status[$gname]) {
129
                               if (stristr($gateways_status[$gname]['status'], "online")) {
130
                                       switch ($gateways_status[$gname]['substatus']) {
131
                                               case "highloss":
132
                                                       $online = gettext("Danger, Packetloss");
133
                                                       $bgcolor = "danger";
134
                                                       break;
135
                                               case "highdelay":
136
                                                       $online = gettext("Danger, Latency");
137
                                                       $bgcolor = "danger";
138
                                                       break;
139
                                               case "loss":
140
                                                       $online = gettext("Warning, Packetloss");
141
                                                       $bgcolor = "warning";
142
                                                       break;
143
                                               case "delay":
144
                                                       $online = gettext("Warning, Latency");
145
                                                       $bgcolor = "warning";
146
                                                       break;
147
                                               default:
148
                                                       if ($status['monitor_disable'] || ($status['monitorip'] == "none")) {
149
                                                               $online = gettext("Online <br/>(unmonitored)");
150
                                                       } else {
151
                                                               $online = gettext("Online");
152
                                                       }
153
                                                       $bgcolor = "success";
154
                                       }
155
                               } elseif (stristr($gateways_status[$gname]['status'], "down")) {
156
                                       $bgcolor = "danger";
157
                                       switch ($gateways_status[$gname]['substatus']) {
158
                                               case "force_down":
159
                                                       $online = gettext("Offline (forced)");
160
                                                       break;
161
                                               case "highloss":
162
                                                       $online = gettext("Offline, Packetloss");
163
                                                       break;
164
                                               case "highdelay":
165
                                                       $online = gettext("Offline, Latency");
166
                                                       break;
167
                                               default:
168
                                                       $online = gettext("Offline");
169
                                       }
170
                               } else {
171
                                       $online = gettext("Pending");
172
                                       $bgcolor = "info";  // lightgray
173
                               }
174
                       } else {
175
                               $online = gettext("Unknown");
176
                               $bgcolor = "info";  // lightblue
177
                       }
178 179

  
179 180
                       $rtnstr .=      "<td>" . ($gateways_status[$gname] ? ($gateways_status[$gname]['delay'] ? htmlspecialchars(number_format((float)rtrim($gateways_status[$gname]['delay'], "ms"), 1)) . "ms" : '') : gettext("Pending")) . "</td>\n";
180 181
                       $rtnstr .=      "<td>" . ($gateways_status[$gname] ? ($gateways_status[$gname]['stddev'] ? htmlspecialchars(number_format((float)rtrim($gateways_status[$gname]['stddev'], "ms"), 1)) . "ms" : '') : gettext("Pending")) . "</td>\n";
    (1-1/1)