Mercurial Hosting > luan
comparison host/admin/src/private/tools/admin.html.luan @ 1995:301a6561fb6b
add host/admin
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 04 Jul 2025 10:25:38 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1994:035996323891 | 1995:301a6561fb6b |
---|---|
1 require "site:/init.luan" | |
2 local Luan = require "luan:Luan.luan" | |
3 local error = Luan.error | |
4 local Io = require "luan:Io.luan" | |
5 local uri = Io.uri or error() | |
6 local String = require "luan:String.luan" | |
7 local Http = require "luan:http/Http.luan" | |
8 require "java" | |
9 local Runtime = require "java:java.lang.Runtime" | |
10 local System = require "java:java.lang.System" | |
11 local Server = require "java:goodjava.webserver.Server" | |
12 | |
13 | |
14 return function() | |
15 local action = Http.request.parameters.action | |
16 if action == "gc" then | |
17 System.gc() | |
18 Http.response.send_redirect "admin.html" | |
19 return | |
20 end | |
21 | |
22 Io.stdout = Http.response.text_writer() | |
23 | |
24 local oneMega = 1024 * 1024; | |
25 local free = Runtime.getRuntime().freeMemory() / oneMega; | |
26 local total = Runtime.getRuntime().totalMemory() / oneMega; | |
27 local used = total - free; | |
28 | |
29 local loadAverage = uri("os:uptime").read_text() | |
30 --local loadAverage = new String(result).replaceAll(".*average:",""); | |
31 | |
32 local threadPool = Server.threadPool | |
33 local threads = threadPool.getPoolSize() | |
34 local active_threads = threadPool.getActiveCount() | |
35 %> | |
36 <!doctype html> | |
37 <html lang="en"> | |
38 <body> | |
39 | |
40 <table> | |
41 <tr> | |
42 <td>Free Memory</td> | |
43 <td> | |
44 <%=String.format("%.2f",free)%> Mb | |
45 </td> | |
46 </tr> | |
47 <tr> | |
48 <td>Used Memory</td> | |
49 <td><%=String.format("%.2f",used)%> Mb</td> | |
50 </tr> | |
51 <tr> | |
52 <td>Total Memory</td> | |
53 <td><%=String.format("%.2f",total)%> Mb</td> | |
54 </tr> | |
55 <tr> | |
56 <td>Load Average</td> | |
57 <td><%=loadAverage%></td> | |
58 </tr> | |
59 <tr> | |
60 <td>Threads</td> | |
61 <td><%= active_threads %> active, <%= threads - active_threads %> idle</td> | |
62 </tr> | |
63 <table> | |
64 | |
65 <p><a href="admin.html?action=gc">Run GC</a></p> | |
66 | |
67 </body> | |
68 </html> | |
69 <% | |
70 end |