Skip to content

Commit 9e76671

Browse files
committed
Merge pull request #57 from scouter-project/dev
Dev
2 parents c06fe43 + a5f9ad0 commit 9e76671

File tree

101 files changed

+2632
-3224
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+2632
-3224
lines changed

scouter.agent.host/src/scouter/agent/counter/task/HostPerf.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package scouter.agent.counter.task;
22

3+
import org.hyperic.sigar.CpuPerc;
34
import org.hyperic.sigar.FileSystem;
45
import org.hyperic.sigar.FileSystemUsage;
56
import org.hyperic.sigar.Mem;
@@ -45,8 +46,11 @@ void domain(CounterBasket pw) throws SigarException {
4546

4647
Configure conf = Configure.getInstance();
4748

48-
float cpu = (float) ((1.0D - sigar.getCpuPerc().getIdle()) * 100);
49+
CpuPerc cpuPerc = sigar.getCpuPerc();
50+
float cpu = (float) ((1.0D - cpuPerc.getIdle()) * 100);
4951
alertCpu(cpu);
52+
float sysCpu = (float) cpuPerc.getSys() * 100;
53+
float userCpu = (float) cpuPerc.getUser() * 100;
5054

5155
Mem m = sigar.getMem();
5256
alertMem(m);
@@ -65,6 +69,8 @@ void domain(CounterBasket pw) throws SigarException {
6569

6670
PerfCounterPack p = pw.getPack(conf.objName, TimeTypeEnum.REALTIME);
6771
p.put(CounterConstants.HOST_CPU, new FloatValue(cpu));
72+
p.put(CounterConstants.HOST_SYSCPU, new FloatValue(sysCpu));
73+
p.put(CounterConstants.HOST_USERCPU, new FloatValue(userCpu));
6874
p.put(CounterConstants.HOST_MEM, new FloatValue(memrate));
6975
p.put(CounterConstants.HOST_MEM_TOTAL, new DecimalValue(tmem / 1024 / 1024));
7076
p.put(CounterConstants.HOST_MEM_USED, new DecimalValue(umem / 1024 / 1024));
@@ -241,19 +247,19 @@ public void disk(CounterBasket pw) {
241247
if (pct >= conf.disk_fatal_pct && fatal.length() < 32756) {
242248
long avail = usage.getAvail();
243249
long total = usage.getTotal();
244-
if (fatal.length() == 0) {
250+
if (fatal.length() > 0) {
245251
fatal.append("\n");
246252
}
247253
fatal.append(dir).append(" usage ").append((int) pct).append("% total=")
248-
.append(total / 1024 / 1024 / 1024).append(" GB available=").append(prt(avail));
254+
.append(FormatUtil.print(total / 1024.0 / 1024, "#0.0#")).append("GB.. available=").append(prt(avail * 1024));
249255
} else if (pct >= conf.disk_warning_pct && warn.length() < 32756) {
250256
long avail = usage.getAvail();
251257
long total = usage.getTotal();
252-
if (warn.length() == 0) {
258+
if (warn.length() > 0) {
253259
warn.append("\n");
254260
}
255261
warn.append(dir).append(" usage ").append((int) pct).append("% total=")
256-
.append(total / 1024 / 1024 / 1024).append(" GB available=").append(prt(avail));
262+
.append(FormatUtil.print(total / 1024.0 / 1024, "#0.0#")).append("GB.. available=").append(prt(avail * 1024));
257263
}
258264

259265
}
@@ -281,4 +287,9 @@ private String prt(long free) {
281287
free /= 1024;
282288
return FormatUtil.print(free, "#,##0") + " GB";
283289
}
290+
291+
public static void main(String[] args) {
292+
long total = 9126805504L / 1024 / 1204 / 1024;
293+
System.out.println(total);
294+
}
284295
}

0 commit comments

Comments
 (0)