status.php
14.2 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
<?php
/**
* Provides the most important status information about the Resin server.
*
* @author Sam
*/
require_once "WEB-INF/php/inc.php";
$server_id = $_GET["server-id"];
if ($server_id) {
$mbean_server = new MBeanServer($server_id);
if (! $mbean_server) {
$title = "Resin: Status for server $server_id";
display_header("thread.php", $title, $server);
echo "<h3 class='fail'>Can't contact $server_id</h3>";
return;
}
}
else
$mbean_server = new MBeanServer();
if ($mbean_server) {
$resin = $mbean_server->lookup("resin:type=Resin");
$server = $mbean_server->lookup("resin:type=Server");
}
$title = "Resin: Status";
if (! empty($server->Id))
$title = $title . " for server " . $server->Id;
?>
<?php
display_header("status.php", $title, $server, true);
if (! $server) {
echo "<h2 class='fail'>Can't contact '$server_id'</h2>";
return;
}
?>
<h2>Server: <?= $server->Id ?></h2>
<table class="data">
<tr title="The server id used when starting this instance of Resin, the value of `-server'.">
<th>Server id:</th>
<td><?= $server->Id ? $server->Id : '\"\"' ?></td>
</tr>
<tr title="The configuration file used when starting this instance of Resin, the value of `-conf'.">
<th>Version:</th>
<td><?= $resin->Version ?></td>
</tr>
<tr title="The configuration file used when starting this instance of Resin, the value of `-conf'.">
<th>Config file:</th>
<td><?= $resin->ConfigFile ?></td>
</tr>
<tr title="The Resin home directory used when starting this instance of Resin. This is the location of the Resin program files.">
<th>Resin home:</th>
<td><?= $resin->ResinHome ?></td>
</tr>
<tr title="The resin root directory used when starting this instance of Resin. This is the root directory of the web server files.">
<th>Resin root:</th>
<td><?= $resin->RootDirectory ?></td>
</tr>
<tr title="The ip address of the machine that is running this instance of Resin.">
<th>Local host:</th>
<td><?= $resin->LocalHost ?></td>
</tr>
<tr title="The current lifecycle state">
<th>State:</th>
<td class="<?= $server->State ?>"><?= $server->State ?></td>
</tr>
<tr title="The time that this instance was last started or restarted.">
<th>Uptime:</th>
<?php
$start_time = $server->StartTime->time / 1000;
$now = $server->CurrentTime->time / 1000;
$uptime = $now - $start_time;
if ($uptime < 12 * 3600)
echo "<td class='warmup'>";
else
echo "<td>";
echo sprintf("%d days %02d:%02d:%02d",
$uptime / (24 * 3600),
$uptime / 3600 % 24,
$uptime / 60 % 60,
$uptime % 60);
echo " -- " . format_datetime($server->StartTime);
?>
</td>
</tr>
<tr title="The current total amount of memory available for the JVM, in bytes.">
<th>Total memory:</th>
<td><?= format_memory($server->RuntimeMemory) ?></td>
</tr>
<tr title="The current free amount of memory available for the JVM, in bytes.">
<th>Free memory:</th>
<td><?= format_memory($server->RuntimeMemoryFree) ?></td>
</tr>
<tr title="The current CPU load average.">
<th>CPU Load:</th>
<td><?= sprintf("%.2f", $server->CpuLoadAvg) ?></td>
</tr>
<?php
if ($mbean_server) {
$block_cache = $mbean_server->lookup("resin:type=BlockManager");
$proxy_cache = $mbean_server->lookup("resin:type=ProxyCache");
}
?>
<tr title="Percentage of requests that have been served from the proxy cache:">
<th>Proxy cache miss ratio:</th>
<td><?= format_miss_ratio($proxy_cache->HitCountTotal,
$proxy_cache->MissCountTotal) ?></td>
</tr>
<tr title="Percentage of requests that have been served from the proxy cache:">
<th><?= info("Block cache miss ratio") ?>:</th>
<td><?= format_miss_ratio($block_cache->HitCountTotal,
$block_cache->MissCountTotal) ?></td>
</tr>
<!-- XXX: show how cacheable apps are: cacheable/non-cacheable -->
<tr>
<th>Invocation miss ratio:</th>
<td><?= format_miss_ratio($server->InvocationCacheHitCountTotal,
$server->InvocationCacheMissCountTotal) ?></td>
</tr>
</table>
<?php
$thread_pool = $server->ThreadPool;
?>
<!--
"Restart" - "Exit this instance cleanly and allow the wrapper script to start a new JVM."
-->
<h2>Thread pool</h2>
<!--
<div class="description">
The ThreadPool manages all threads used by Resin.
</div>
-->
<table class="data">
<tr>
<th colspan='3'>Threads</th>
<th colspan='2'>Config</th>
</tr>
<tr>
<th title="The number of active threads. These threads are busy servicing requests or performing other tasks.">Active</th>
<th title="The number of idle threads. These threads are allocated but inactive, available for new requests or tasks.">Idle</th>
<th title="The current number of threads managed by the pool.">Total</th>
<th title="The maximum number of threads that Resin can allocate.">thread-max</th>
<th title="The minimum number of threads Resin should have available for new requests or other tasks. This value causes a minimum number of idle threads, useful for situations where there is a sudden increase in the number of threads required.">thread-idle-min</th>
</tr>
<tr align='right'>
<td><?= $thread_pool->ThreadActiveCount ?></td>
<td><?= $thread_pool->ThreadIdleCount ?></td>
<td><?= $thread_pool->ThreadCount ?></td>
<td><?= $thread_pool->ThreadMax ?></td>
<td><?= $thread_pool->ThreadIdleMin ?></td>
</tr>
</table>
<!-- TCP ports -->
<?php
$ports = $server->Ports;
if ($ports) {
?>
<h2>TCP ports</h2>
<table class="data">
<tr>
<th colspan='2'> </th>
<th colspan='3'>Threads</th>
<th colspan='4'>Keepalive</th>
<tr>
<th> </th>
<th>Status</th>
<th>Active</th>
<th>Idle</th>
<th>Total</th>
<th>Total</th>
<th>Thread</th>
<th>Select</th>
<th>Comet</th>
</tr>
<?php
$count = 0;
foreach ($ports as $port) {
?>
<tr class='<?= $count++ % 2 == 0 ? "ra" : "rb" ?>'>
<td class='item'><?= $port->ProtocolName ?>://<?= $port->Address ? $port->Address : "*" ?>:<?= $port->Port ?></td>
<td class="<?= $port->State ?>"><?= $port->State ?></td>
<td><?= $port->ThreadActiveCount ?></td>
<td><?= $port->ThreadIdleCount ?></td>
<td><?= $port->ThreadCount ?></td>
<td><?= $port->KeepaliveCount ?></td>
<td><?= $port->KeepaliveThreadCount ?></td>
<td><?= $port->KeepaliveSelectCount ?></td>
<td><?= $port->CometIdleCount ?>
</tr>
<?php
}
}
?>
</table>
<!-- Cluster -->
<h2>Server Connectors</h2>
<table class="data">
<tr>
<th>Server</th>
<th>Address</th>
<th>Status</th>
<th>Active</th>
<th>Idle</th>
<th>Connection Miss</th>
<th>Load</th>
<th>Latency</th>
<th colspan='2'>Failures</th>
<th colspan='2'>Busy</th>
</tr>
<?php
foreach ($resin->Clusters as $cluster) {
if (empty($cluster->Servers))
continue;
echo "<tr><td class='group' colspan='12'>$cluster->Name</td></tr>\n";
$count = 0;
foreach ($cluster->Servers as $client) {
?>
<tr class='<?= $count++ % 2 == 0 ? "ra" : "rb" ?>'>
<td class='item'><?= $client->Name ?></td>
<td><?= $client->Address ?>:<?= $client->Port ?></td>
<td class="<?= $client->State ?>"><?= $client->State ?></td>
<td><?= $client->ConnectionActiveCount ?></td>
<td><?= $client->ConnectionIdleCount ?></td>
<td><?= format_miss_ratio($client->ConnectionKeepaliveCountTotal,
$client->ConnectionNewCountTotal) ?></td>
<td><?= sprintf("%.2f", $client->ServerCpuLoadAvg) ?></td>
<td><?= sprintf("%.2f", $client->LatencyFactor) ?></td>
<?php
format_ago_td_pair($client->ConnectionFailCountTotal,
$client->LastFailTime);
format_ago_td_pair($client->ConnectionBusyCountTotal,
$client->LastBusyTime);
?>
</tr>
<?php
}
}
?>
</table>
<!-- Connection pools -->
<?php
if ($mbean_server) {
$db_pools = $mbean_server->query("resin:*,type=ConnectionPool");
}
if ($db_pools) {
?>
<h2>Connection pools</h2>
<table class="data">
<tr>
<th> </th>
<th colspan='5'>Connections</th>
<th colspan='2'>Config</th>
</tr>
<tr>
<th>Name</th>
<th>Active</th>
<th>Idle</th>
<th>Created</th>
<th colspan='2'>Failed</th>
<th>max-connections</th>
<th>idle-time</th>
</tr>
<?php
$row = 0;
foreach ($db_pools as $pool) {
?>
<tr class='<?= row_style($row++) ?>'>
<td><?= $pool->Name ?></td>
<td><?= $pool->ConnectionActiveCount ?></td>
<td><?= $pool->ConnectionIdleCount ?></td>
<td><?= format_miss_ratio($pool->ConnectionCountTotal,
$pool->ConnectionCreateCountTotal) ?></td>
<td><?= $pool->ConnectionFailCountTotal ?></td>
<td class='<?= format_ago_class($pool->LastFailTime) ?>'>
<?= format_ago($pool->LastFailTime) ?></td>
<td><?= $pool->MaxConnections ?></td>
<td><?= $pool->MaxIdleTime ?></td>
</tr>
<?php
}
?>
</table>
<?php
}
?>
<?php
if ($mbean_server) {
$mbean = $mbean_server->lookup("resin:type=LogService");
}
//
// recent messages
//
if ($mbean) {
$now = time();
$messages = $mbean->findMessages(($now - 24 * 3600) * 1000, $now * 1000);
if (! empty($messages)) {
echo "<h2>Recent Messages</h2>\n";
echo "<table class='data'>\n";
/*
//echo "<thead class='scroll'>\n";
echo "<tr><th class='date'>Date</th>"
echo " <th class='level'>Level</th>"
echo " <th class='message'>Message</th></tr>\n";
//echo "</thead>\n";
*/
$messages = array_reverse($messages);
echo "<tbody class='scroll'>\n";
foreach ($messages as $message) {
echo "<tr class='{$message->level}'>";
echo " <td class='date'>";
echo strftime("%Y-%m-%d %H:%M:%S", $message->timestamp / 1000);
echo "</td>";
echo " <td class='level'>{$message->level}</td>";
echo " <td class='message'>" . htmlspecialchars(wordwrap($message->message, 90));
echo " </td>";
echo "</tr>";
}
echo "</tbody>\n";
echo "</table>\n";
}
//
// startup
//
$start_time = $server->StartTime->time / 1000;
$messages = $mbean->findMessages(($start_time - 15 * 60) * 1000, ($start_time - 2) * 1000);
if (! empty($messages)) {
echo "<h2>Shutdown Messages</h2>\n";
echo "<table class='data'>\n";
/*
//echo "<thead class='scroll'>\n";
echo "<tr><th class='date'>Date</th>"
echo " <th class='level'>Level</th>"
echo " <th class='message'>Message</th></tr>\n";
//echo "</thead>\n";
*/
$messages = array_reverse($messages);
echo "<tbody class='scroll'>\n";
// mark the start time
echo "<tr class='warning'>";
echo " <td class='date'>";
echo strftime("%Y-%m-%d %H:%M:%S", $start_time);
echo "</td>";
echo " <td class='level'></td>";
echo " <td class='message'>Start Time</td>";
echo "</tr>";
foreach ($messages as $message) {
echo "<tr class='{$message->level}'>";
echo " <td class='date'>";
echo strftime("%Y-%m-%d %H:%M:%S", $message->timestamp / 1000);
echo "</td>";
echo " <td class='level'>{$message->level}</td>";
echo " <td class='message'>" . htmlspecialchars(wordwrap($message->message, 90)) . "</td>";
echo "</tr>";
}
echo "</tbody>\n";
echo "</table>\n";
}
}
?>
<!-- Persistent store -->
<?php
if ($mbean_server) {
$store = $mbean_server->lookup("resin:type=PersistentStore");
}
if ($store) {
echo "<h2>Persistent Store: $store->StoreType</h2>\n";
echo "<table class='data'>";
echo "<tr><th>Object Count</th><td>$store->ObjectCount</td>\n";
echo "<tr><th>Load Count</th><td>$store->LoadCountTotal</td>\n";
echo "<tr><th>Load Fail Count</th><td>$store->LoadFailCountTotal</td>\n";
echo "<tr><th>Save Count</th><td>$store->SaveCountTotal</td>\n";
echo "<tr><th>Save Fail Count</th><td>$store->SaveFailCountTotal</td>\n";
echo "</table>";
}
?>
<!-- Applications -->
<h2>WebApps</h2>
<table class="data">
<tr>
<th>Web-App</th>
<th>State</th>
<th>Active</th>
<th>Sessions</th>
<th>Uptime</th>
<th colspan='2'>500</th>
</tr>
<?php
function sort_host($a, $b)
{
return strcmp($a->URL, $b->URL);
}
if ($mbean_server) {
$hosts = $mbean_server->query("resin:*,type=Host");
}
usort($hosts, "sort_host");
foreach ($hosts as $host) {
$hostName = empty($host->HostName) ? "default" : $host->HostName;
?>
<tr title='<?= $hostObjectName ?>'><td class='group' colspan='7'><?= $host->URL ?></td></tr>
<?php
function sort_webapp($a, $b)
{
return strcmp($a->ContextPath, $b->ContextPath);
}
$webapps = $host->WebApps;
usort($webapps, "sort_webapp");
$count = 0;
foreach ($webapps as $webapp) {
$session = $webapp->SessionManager;
?>
<tr class='<?= row_style($count++) ?>'>
<td class='item'>
<?= empty($webapp->ContextPath) ? "/" : $webapp->ContextPath ?>
</td>
<td class='<?= format_state_class($webapp->State) ?>'>
<?= $webapp->State ?>
</td>
<td><?= $webapp->RequestCount ?></td>
<td><?= $session->SessionActiveCount ?></td>
<td class='<?= format_ago_class($webapp->StartTime) ?>'>
<?= format_ago($webapp->StartTime) ?>
</td>
<?php
format_ago_td_pair($webapp->Status500CountTotal,
$webapp->Status500LastTime);
?>
</tr>
<?php
} // webapps
} // hosts
?>
</table>
<?php
/*
if ($mbean_server) {
$tcp_conn = $mbean_server->query("resin:*,type=TcpConnection");
}
$slow_conn = array();
echo "<table class='data'>";
foreach ($tcp_conn as $conn_name) {
$conn = $mbeanServer->lookup($conn_name);
echo "<tr><td>" . $conn->ThreadId . "<td>" . $conn->State . "<td>" . $conn->ActiveTime;
if ($conn->ActiveTime > 60000)
$slow_conn[] = $conn;
}
echo "</table>";
if ($mbean_server) {
$thread_mgr = $mbean_server->lookup("java.lang:type=Threading");
}
foreach ($slow_conn as $slow) {
echo "<h3>" . $slow->ObjectName . " " . ($slow->ActiveTime / 1000) . "</h3>";
$thread_id = $slow->ThreadId;
resin_var_dump($thread_id);
$info = $thread_mgr->getThreadInfo($thread_id, 16);
if ($info) {
$bean = Java("java.lang.management.ThreadInfo");
$info = $bean->from($info);
}
resin_var_dump($info->getStackTrace());
}
*/
?>
<?php display_footer("status.php"); ?>