Rounding cpu load
This commit is contained in:
parent
aa4e110832
commit
e38355aa56
2 changed files with 8 additions and 6 deletions
|
|
@ -61,13 +61,14 @@ public abstract class AbstractPage implements HttpPage{
|
|||
HttpHeaderParser client_info,
|
||||
Map<String, Object> session,
|
||||
Map<String, String> cookie,
|
||||
Map<String, String> request) {
|
||||
Map<String, String> request) throws IOException {
|
||||
WAContext context = (WAContext)session.get("context");
|
||||
if(context == null){
|
||||
context = new WAContext();
|
||||
}
|
||||
|
||||
if(("application/json").equals(client_info.getHeader("ContentType"))){
|
||||
if(("application/json").equals(client_info.getHeader("ContentType")) ||
|
||||
request.containsKey("json")){
|
||||
DataNode node = jsonResponse(context, client_info, session, cookie, request);
|
||||
if(node != null) {
|
||||
out.setHeader("Content-Type", "application/json");
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import zutil.io.file.FileUtil;
|
|||
import zutil.parser.DataNode;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
* Created by Ziver on 2015-04-07.
|
||||
|
|
@ -57,11 +58,11 @@ public class CpuStatus implements WAStatus {
|
|||
|
||||
try{
|
||||
Sigar sigar = new Shell().getSigar();
|
||||
for(CpuInfo cpu_info : sigar.getCpuInfoList()){
|
||||
for(CpuPerc cpu : sigar.getCpuPercList()){
|
||||
cpuNode.add(cpu.getCombined());
|
||||
}
|
||||
CpuInfo cpu_info = sigar.getCpuInfoList()[0];
|
||||
for(CpuPerc cpu : sigar.getCpuPercList()){
|
||||
cpuNode.add(Math.round(cpu.getCombined() * 100.0) / 100.0 );
|
||||
}
|
||||
|
||||
} catch (SigarException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue