Fixed zutil changes
This commit is contained in:
parent
7bf6896473
commit
6ad7c2ed58
9 changed files with 144 additions and 56 deletions
85
src/wa/server/page/WALogPage.java
Executable file
85
src/wa/server/page/WALogPage.java
Executable file
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright (c) 2015 ezivkoc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package wa.server.page;
|
||||
|
||||
import zutil.net.http.HttpHeader;
|
||||
import zutil.net.http.HttpHeaderParser;
|
||||
import zutil.net.http.HttpPage;
|
||||
import zutil.net.http.HttpPrintStream;
|
||||
import zutil.parser.DataNode;
|
||||
import zutil.parser.json.JSONWriter;
|
||||
import zutil.struct.CircularBuffer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
/**
|
||||
* Created by Ziver on 2015-09-22.
|
||||
*/
|
||||
public class WALogPage extends Handler implements HttpPage {
|
||||
private CircularBuffer<LogRecord> logBuffer;
|
||||
|
||||
@Override
|
||||
public void publish(LogRecord record) {
|
||||
if(super.isLoggable(record)){
|
||||
logBuffer.add(record);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void flush() {}
|
||||
@Override
|
||||
public void close() throws SecurityException {
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void respond(HttpPrintStream out,
|
||||
HttpHeader client_info,
|
||||
Map<String, Object> session,
|
||||
Map<String, String> cookie,
|
||||
Map<String, String> request) throws IOException {
|
||||
|
||||
DataNode logNode = new DataNode(DataNode.DataType.List);
|
||||
Iterator<LogRecord> it = logBuffer.iterator();
|
||||
for(int i=0; i<20 && it.hasNext(); ++i){
|
||||
LogRecord record = it.next();
|
||||
DataNode node = new DataNode(DataNode.DataType.Map);
|
||||
node.set("timestamp", record.getMillis());
|
||||
node.set("source", record.getLoggerName());
|
||||
node.set("msg", record.getMessage());
|
||||
logNode.add(node);
|
||||
}
|
||||
|
||||
DataNode root = new DataNode(DataNode.DataType.Map);
|
||||
root.add(logNode);
|
||||
JSONWriter writer = new JSONWriter(out);
|
||||
writer.write(root);
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
3
src/wa/server/page/struct/WANavigation.java
Normal file → Executable file
3
src/wa/server/page/struct/WANavigation.java
Normal file → Executable file
|
|
@ -80,6 +80,9 @@ public class WANavigation implements Iterable{
|
|||
public String getName(){
|
||||
return name;
|
||||
}
|
||||
public String getUrl(){
|
||||
return url;
|
||||
}
|
||||
public Object getResource(){
|
||||
return resource;
|
||||
}
|
||||
|
|
|
|||
8
src/wa/server/plugin/apache/plugin.json
Normal file → Executable file
8
src/wa/server/plugin/apache/plugin.json
Normal file → Executable file
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"version": "1.0",
|
||||
"name": "Apache Web Server",
|
||||
"interfaces": {
|
||||
"wa.server.plugin.WAService": "wa.server.plugin.apache.ApacheService",
|
||||
"wa.server.plugin.WAServiceStatus": "wa.server.plugin.apache.ApacheStatus"
|
||||
}
|
||||
"interfaces": [
|
||||
{"wa.server.plugin.WAService": "wa.server.plugin.apache.ApacheService"},
|
||||
{"wa.server.plugin.WAServiceStatus": "wa.server.plugin.apache.ApacheStatus"}
|
||||
]
|
||||
}
|
||||
50
src/wa/server/plugin/hwstatus/HDDStatus.tmpl
Normal file → Executable file
50
src/wa/server/plugin/hwstatus/HDDStatus.tmpl
Normal file → Executable file
|
|
@ -8,30 +8,6 @@
|
|||
|
||||
<div id="hdd-container"></div>
|
||||
|
||||
<div id="template" class="hidden">
|
||||
<div id="" class="col-md-4"><div class="panel panel-default">
|
||||
<div class="panel-heading hdd-title">HDD: {{.mount}} ({{.size_total}})</div>
|
||||
<div class="panel-body">
|
||||
<center><img src="img/hdd_ok.png" /></center><br>
|
||||
<div class="progress">
|
||||
<div class="progress-bar hdd-used" role="progressbar"></div>
|
||||
<center class="hdd-free">{{.size_free}}</center>
|
||||
</div>
|
||||
<table class="table small hdd-detail">
|
||||
<thead><tr>
|
||||
<th data-field="mount">Mount</th>
|
||||
<th data-field="type" >Type</th>
|
||||
</tr></thead>
|
||||
<tr>
|
||||
<td class="hdd-mount"></td>
|
||||
<td class="hdd-filesystem"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!--<div><canvas id="hdd-io" height="400"></canvas></div>-->
|
||||
</div>
|
||||
</div></div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
|
|
@ -40,7 +16,7 @@ $(function() {
|
|||
});
|
||||
|
||||
function updateHdd(){
|
||||
$.getJSON("{{nav.url}}&json&hdd", function( data ) {
|
||||
$.getJSON("{{nav.getUrl()}}&json&hdd", function( data ) {
|
||||
$.each(data['hdd'], function( index, hdd ){
|
||||
var element = null;
|
||||
var html_id = "hdd-id-" + hdd.id;
|
||||
|
|
@ -78,3 +54,27 @@ function byteToString(value){
|
|||
return value+" "+sizes[total];
|
||||
}
|
||||
</script>
|
||||
|
||||
<div id="template" class="hidden">
|
||||
<div id="" class="col-md-4"><div class="panel panel-default">
|
||||
<div class="panel-heading hdd-title">HDD: {{.mount}} ({{.size_total}})</div>
|
||||
<div class="panel-body">
|
||||
<center><img src="img/hdd_ok.png" /></center><br>
|
||||
<div class="progress">
|
||||
<div class="progress-bar hdd-used" role="progressbar"></div>
|
||||
<center class="hdd-free">{{.size_free}}</center>
|
||||
</div>
|
||||
<table class="table small hdd-detail">
|
||||
<thead><tr>
|
||||
<th data-field="mount">Mount</th>
|
||||
<th data-field="type" >Type</th>
|
||||
</tr></thead>
|
||||
<tr>
|
||||
<td class="hdd-mount"></td>
|
||||
<td class="hdd-filesystem"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!--<div><canvas id="hdd-io" height="400"></canvas></div>-->
|
||||
</div>
|
||||
</div></div>
|
||||
</div>
|
||||
6
src/wa/server/plugin/hwstatus/HwStatus.tmpl
Normal file → Executable file
6
src/wa/server/plugin/hwstatus/HwStatus.tmpl
Normal file → Executable file
|
|
@ -54,7 +54,7 @@ var cpu_data = {
|
|||
};
|
||||
|
||||
function updateCpuChart(){
|
||||
$.getJSON("{{nav.url}}&json&cpu", function( data ) {
|
||||
$.getJSON("{{nav.getUrl()}}&json&cpu", function( data ) {
|
||||
// Setup graph
|
||||
if(cpu_chart == null){
|
||||
// Fill in cpus
|
||||
|
|
@ -102,7 +102,7 @@ var mem_data = [
|
|||
];
|
||||
|
||||
function updateMemChart(){
|
||||
$.getJSON("{{nav.url}}&json&memory", function( data ) {
|
||||
$.getJSON("{{nav.getUrl()}}&json&memory", function( data ) {
|
||||
if(mem_chart == null){
|
||||
var ctx = $("#mem-chart").get(0).getContext("2d");
|
||||
mem_chart = new Chart(ctx).Doughnut(mem_data, {
|
||||
|
|
@ -123,7 +123,7 @@ function updateMemChart(){
|
|||
|
||||
|
||||
function updateProcTable(){
|
||||
$.getJSON("{{nav.url}}&json&proc", function( data ) {
|
||||
$.getJSON("{{nav.getUrl()}}&json&proc", function( data ) {
|
||||
$('#proc-list').bootstrapTable({
|
||||
data: data['proc']
|
||||
});
|
||||
|
|
|
|||
2
src/wa/server/plugin/hwstatus/NetStatus.tmpl
Normal file → Executable file
2
src/wa/server/plugin/hwstatus/NetStatus.tmpl
Normal file → Executable file
|
|
@ -73,7 +73,7 @@ var net_chart_data = {
|
|||
};
|
||||
|
||||
function updateNet(){
|
||||
$.getJSON("{{nav.url}}&json&net", function( data ) {
|
||||
$.getJSON("{{nav.getUrl()}}&json&net", function( data ) {
|
||||
$.each(data['net'], function( index, net ){
|
||||
var element = null;
|
||||
var html_id = "net-" + net.id;
|
||||
|
|
|
|||
2
src/wa/server/plugin/tomcat/plugin.json
Normal file → Executable file
2
src/wa/server/plugin/tomcat/plugin.json
Normal file → Executable file
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"version": "1.0",
|
||||
"name": "Apache Tomcat",
|
||||
"name": "Tomcat",
|
||||
"interfaces": {
|
||||
"wa.server.plugin.WAService": "wa.server.plugin.apache.TomcatService",
|
||||
"wa.server.plugin.WAServiceStatus": "wa.server.plugin.tomcat.TomcatStatus"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue