Mercurial Hosting > luan
annotate host/admin/src/private/tools/admin.html.luan @ 2047:ea026254b3b6 default tip
show scheduler threads
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Sun, 09 Nov 2025 11:32:18 -0700 |
| parents | 301a6561fb6b |
| children |
| rev | line source |
|---|---|
| 1995 | 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" | |
|
2047
ea026254b3b6
show scheduler threads
Franklin Schmidt <fschmidt@gmail.com>
parents:
1995
diff
changeset
|
12 local threadPool = Server.threadPool |
|
ea026254b3b6
show scheduler threads
Franklin Schmidt <fschmidt@gmail.com>
parents:
1995
diff
changeset
|
13 local ThreadLuan = require "java:luan.modules.ThreadLuan" |
|
ea026254b3b6
show scheduler threads
Franklin Schmidt <fschmidt@gmail.com>
parents:
1995
diff
changeset
|
14 local scheduler = ThreadLuan.scheduler |
| 1995 | 15 |
| 16 | |
| 17 return function() | |
| 18 local action = Http.request.parameters.action | |
| 19 if action == "gc" then | |
| 20 System.gc() | |
| 21 Http.response.send_redirect "admin.html" | |
| 22 return | |
| 23 end | |
| 24 | |
| 25 Io.stdout = Http.response.text_writer() | |
| 26 | |
| 27 local oneMega = 1024 * 1024; | |
| 28 local free = Runtime.getRuntime().freeMemory() / oneMega; | |
| 29 local total = Runtime.getRuntime().totalMemory() / oneMega; | |
| 30 local used = total - free; | |
| 31 | |
| 32 local loadAverage = uri("os:uptime").read_text() | |
| 33 --local loadAverage = new String(result).replaceAll(".*average:",""); | |
| 34 | |
| 35 local threads = threadPool.getPoolSize() | |
| 36 local active_threads = threadPool.getActiveCount() | |
|
2047
ea026254b3b6
show scheduler threads
Franklin Schmidt <fschmidt@gmail.com>
parents:
1995
diff
changeset
|
37 |
|
ea026254b3b6
show scheduler threads
Franklin Schmidt <fschmidt@gmail.com>
parents:
1995
diff
changeset
|
38 local scheduler_threads = scheduler.getPoolSize() |
|
ea026254b3b6
show scheduler threads
Franklin Schmidt <fschmidt@gmail.com>
parents:
1995
diff
changeset
|
39 local scheduler_active_threads = scheduler.getActiveCount() |
| 1995 | 40 %> |
| 41 <!doctype html> | |
| 42 <html lang="en"> | |
| 43 <body> | |
| 44 | |
| 45 <table> | |
| 46 <tr> | |
| 47 <td>Free Memory</td> | |
| 48 <td> | |
| 49 <%=String.format("%.2f",free)%> Mb | |
| 50 </td> | |
| 51 </tr> | |
| 52 <tr> | |
| 53 <td>Used Memory</td> | |
| 54 <td><%=String.format("%.2f",used)%> Mb</td> | |
| 55 </tr> | |
| 56 <tr> | |
| 57 <td>Total Memory</td> | |
| 58 <td><%=String.format("%.2f",total)%> Mb</td> | |
| 59 </tr> | |
| 60 <tr> | |
| 61 <td>Load Average</td> | |
| 62 <td><%=loadAverage%></td> | |
| 63 </tr> | |
| 64 <tr> | |
|
2047
ea026254b3b6
show scheduler threads
Franklin Schmidt <fschmidt@gmail.com>
parents:
1995
diff
changeset
|
65 <td>Server Threads</td> |
| 1995 | 66 <td><%= active_threads %> active, <%= threads - active_threads %> idle</td> |
| 67 </tr> | |
|
2047
ea026254b3b6
show scheduler threads
Franklin Schmidt <fschmidt@gmail.com>
parents:
1995
diff
changeset
|
68 <tr> |
|
ea026254b3b6
show scheduler threads
Franklin Schmidt <fschmidt@gmail.com>
parents:
1995
diff
changeset
|
69 <td>Scheduler Threads</td> |
|
ea026254b3b6
show scheduler threads
Franklin Schmidt <fschmidt@gmail.com>
parents:
1995
diff
changeset
|
70 <td><%= scheduler_active_threads %> active, <%= scheduler_threads - scheduler_active_threads %> idle</td> |
|
ea026254b3b6
show scheduler threads
Franklin Schmidt <fschmidt@gmail.com>
parents:
1995
diff
changeset
|
71 </tr> |
| 1995 | 72 <table> |
| 73 | |
| 74 <p><a href="admin.html?action=gc">Run GC</a></p> | |
| 75 | |
| 76 </body> | |
| 77 </html> | |
| 78 <% | |
| 79 end |
