1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00
libwebsockets/plugins/server-status.html
Andy Green 748a2210bd cgi lifecycle logging
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-21 17:50:58 +08:00

241 lines
6 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8 http-equiv="Content-Language" content="en"/>
<title>LWS Server Status</title>
<style type="text/css">
span.title { font-size:18pt; font: Arial; font-weight:normal;
text-align:center; color:#000000; }
span.mount { font-size:10pt; font: Arial; font-weight:normal;
text-align:center; color:#000000; }
.browser { font-size:18pt; font: Arial; font-weight:normal; text-align:center; color:#ffff00; vertical-align:middle; text-align:center; background:#d0b070; padding:12px; -webkit-border-radius:10px; -moz-border-radius:10px; border-radius:10px;}
.group2 { vertical-align:middle;
text-align:center;
background:#f0f0e0;
padding:12px;
-webkit-border-radius:10px;
-moz-border-radius:10px;
border-radius:10px; }
.explain { vertical-align:middle;
text-align:center;
background:#f0f0c0; padding:12px;
-webkit-border-radius:10px;
-moz-border-radius:10px;
border-radius:10px;
color:#404000; }
td.wsstatus { vertical-align:middle; width:200px; height:50px;
text-align:center;
background:#f0f0c0; padding:6px;
-webkit-border-radius:8px;
-moz-border-radius:8px;
border-radius:8px;
color:#404000; }
td.l { vertical-align:middle;
text-align:center;
background:#d0d0b0;
padding:3px;
-webkit-border-radius:3px;
-moz-border-radius:3px;
border-radius:3px; }
td.c { vertical-align:middle;
text-align:center;
background:#c0c0a0;
padding:3px;
-webkit-border-radius:3px;
-moz-border-radius:3px;
border-radius:3px; }
td.t { vertical-align:middle;
text-align:center;
background:#e0e0c0;
padding:3px;
-webkit-border-radius:3px;
-moz-border-radius:3px;
border-radius:3px; }
.content { vertical-align:top; text-align:center; background:#fffff0; padding:12px; -webkit-border-radius:10px; -moz-border-radius:10px; border-radius:10px; }
.canvas { vertical-align:top; text-align:center; background:#efefd0; padding:12px; -webkit-border-radius:10px; -moz-border-radius:10px; border-radius:10px; }
.tabs {
position: relative;
min-height: 750px; /* This part sucks */
clear: both;
margin: 25px 0;
}
.tab {
float: left;
}
.tab label {
background: #eee;
padding: 10px;
border: 1px solid #ccc;
margin-left: -1px;
position: relative;
left: 1px;
}
.tab [type=radio] {
display: none;
}
.content {
position: absolute;
top: 28px;
left: 0;
background: white;
right: 0;
bottom: 0;
padding: 20px;
border: 1px solid #ccc;
}
[type=radio]:checked ~ label {
background: white;
border-bottom: 1px solid white;
z-index: 2;
}
[type=radio]:checked ~ label ~ .content {
z-index: 1;
}
</style>
</head>
<body>
<header></header>
<article>
<table><tr><td align=center>
<div id="conninfo">...</div>
</td></tr>
</table>
</article>
<script>
/*
* We display untrusted stuff in html context... reject anything
* that has HTML stuff in it
*/
function san(s)
{
if (s.search("<") != -1)
return "invalid string";
return s;
}
var pos = 0;
function get_appropriate_ws_url()
{
var pcol;
var u = document.URL;
/*
* We open the websocket encrypted if this page came on an
* https:// url itself, otherwise unencrypted
*/
if (u.substring(0, 5) == "https") {
pcol = "wss://";
u = u.substr(8);
} else {
pcol = "ws://";
if (u.substring(0, 4) == "http")
u = u.substr(7);
}
u = u.split('/');
/* + "/xxx" bit is for IE10 workaround */
return pcol + u[0] + "/xxx";
}
var socket_status, jso, s;
if (typeof MozWebSocket != "undefined") {
socket_status = new MozWebSocket(get_appropriate_ws_url(),
"lws-server-status");
} else {
socket_status = new WebSocket(get_appropriate_ws_url(),
"lws-server-status");
}
try {
socket_status.onopen = function() {
}
socket_status.onmessage =function got_packet(msg) {
document.getElementById("conninfo").innerHTML = "<pre>"+msg.data+"</pre>";
jso = JSON.parse(msg.data);
s="<table><tr><td class=\"c\">" +
"Context</td><td>Uptime: " + san(jso.uptime) + ", " +
"Listening wsi: " + san(jso.listen_wsi) + ", " +
"Current wsi alive: " + (parseInt(san(jso.wsi_alive)) -
parseInt(san(jso.listen_wsi))) + "<br>" +
"Current cgi alive: " + san(jso.cgi_alive) + ", " +
"Total CGI spawned: " + san(jso.cgi_spawned) +
"</td></tr>";
var n;
for (n = 0; n < jso.pt.length; n++) {
s = s + "<tr><td class=\"l\">service thread " + (n + 1) +
"</td><td>" +
"fds: " + san(jso.pt[n].fds_count) + " / " +
san(jso.pt_fd_max) + ", ";
s = s + "ah pool: " + san(jso.pt[n].ah_pool_inuse) + " / " +
san(jso.ah_pool_max) + ", " +
"ah waiting list: " + san(jso.pt[n].ah_wait_list);
s = s + "</td></tr>";
}
for (n = 0; n < jso.vhosts.length; n++) {
s = s + "<tr><td class=\"l\">vhost " + (n + 1) +
"</td><td><b>";
if (jso.vhosts[n].use_ssl == '1')
s = s + "https://";
else
s = s + "http://";
s = s + san(jso.vhosts[n].name) + ":" +
san(jso.vhosts[n].port) + "</b>";
if (jso.vhosts[n].sts == '1')
s = s + " (STS)";
s = s +"<br>" +
"rx " + san(jso.vhosts[n].rx) + ", " +
"tx " + san(jso.vhosts[n].tx) + "<br>" +
"total connections " + san(jso.vhosts[n].conn) + ", " +
"total http transactions " + san(jso.vhosts[n].trans) + "<br>" +
"Upgrades to ws: " + san(jso.vhosts[n].ws_upg) + ", " +
"to http/2: " + san(jso.vhosts[n].http2_upg) + "<br>" +
"<table><tr><td class=t colspan=2>Mounts</td></tr>";
var m;
for (m = 0; m < jso.vhosts[n].mounts.length; m++) {
s = s + "<tr><td>";
s = s + san(jso.vhosts[n].mounts[m].mountpoint) +
"</td><td>" +
san(jso.vhosts[n].mounts[m].origin);
s = s + "</td></tr>"
}
s = s + "</table>";
s = s + "</td></tr>";
}
s = s + "</table>";
document.getElementById("conninfo").innerHTML = s;
}
socket_status.onclose = function(){
document.getElementById("s_statustd").style.backgroundColor = "#ff4040";
document.getElementById("s_status").textContent = " websocket connection CLOSED ";
}
} catch(exception) {
alert('<p>Error' + exception);
}
</script>
</body>
</html>