Commit d1e9b7b1 authored by 38823's avatar 38823

建机:系统监控开发

parent a5ada5d1
......@@ -173,6 +173,14 @@
<systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/gson-2.6.2.jar</systemPath>
</dependency>
<dependency>
<groupId>com.sigar</groupId>
<artifactId>sys-sigar</artifactId>
<version>1.6.4</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/sigar-1.6.4.jar</systemPath>
</dependency>
<!--end -->
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: Administrator
$Date: 2019-7-26 下午1:50:02
$Revision: 1.0
$Purpose:
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" accessControlMode="false">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[select count(*) count from sys_function]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:fields>
<bm:field name="count"/>
</bm:fields>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<a:service xmlns:p="uncertain.proc" xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script"
trace="true">
<a:init-procedure>
<s:server-script><![CDATA[
main();
function main() {
var cpu_rate = new String();
for (var j = 0;j < 10;j++) {
try {
java.lang.Thread.sleep(1000);
cpu_rate = cpu_rate + "," + cpu();
} catch (e) {
println(e);
}
}
$ctx.parameter.cpu_rate = cpu_rate.substring(1);
}
function cpu() {
var sigar = new org.hyperic.sigar.Sigar();
var infos = sigar.getCpuInfoList();
var cpuList = null;
cpuList = sigar.getCpuPercList();
var total = 0;
for (var i = 0;i < infos.length;i++) { // 不管是单块CPU还是多CPU都适用
var info = infos[i];
total = cpuList[i].getCombined() + total;
}
total = Math.round(1000 * total / infos.length) / 1000;
total = total*100;
total = total.toFixed(2);
return total+'%';
}
]]></s:server-script>
</a:init-procedure>
<a:service-output output="/parameter"/>
</a:service>
<?xml version="1.0" encoding="UTF-8"?>
<a:service xmlns:p="uncertain.proc" xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script"
trace="true">
<a:init-procedure>
<s:server-script><![CDATA[
function main() {
var data = $bm('tst.sys_function_query').queryAsMap().getChildren();
$ctx.parameter.count = data[0].count;
}
main();
]]></s:server-script>
</a:init-procedure>
<a:service-output output="/parameter"/>
</a:service>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment