public void produceCpuEvents(NodePojo node) throws ExecutionException, InterruptedException, IOException { ChartPrettyRandomGenerator genUser = cpuUserGenerator.get(node.getIpAddress()); if (genUser == null) { genUser = new ChartPrettyRandomGenerator(true, 80, 20); cpuUserGenerator.put(node.getIpAddress(), genUser); } ChartPrettyRandomGenerator genSys = cpuSysGenerator.get(node.getIpAddress()); if (genSys == null) { genSys = new ChartPrettyRandomGenerator(true, 80, 20); cpuSysGenerator.put(node.getIpAddress(), genSys); } List<SamplePojo> samples = new ArrayList<SamplePojo>(); long userCpu = Long.parseLong(genUser.getNextValue()); long systemCpu = Long.parseLong(genSys.getNextValue()); long idleCpu; if (userCpu + systemCpu > 100) { systemCpu = 100 - userCpu; idleCpu = 0; } else { idleCpu = 100 - (userCpu + systemCpu); } samples.add(new SamplePojo("User", Long.toString(userCpu))); samples.add(new SamplePojo("Sys", Long.toString(systemCpu))); samples.add(new SamplePojo("Idle", Long.toString(idleCpu))); listener.publishEvent( new EventPojo(node.getIpAddress(), symTime, TopLevelConst.CPU_LINE_CHART_DATA, samples)); }
public void produceSwapEvents(NodePojo node) throws ExecutionException, InterruptedException, IOException { ChartPrettyRandomGenerator gen = swapGenerator.get(node.getIpAddress()); if (gen == null) { gen = new ChartPrettyRandomGenerator(true, 12800000, 1000); swapGenerator.put(node.getIpAddress(), gen); } List<SamplePojo> samples = new ArrayList<SamplePojo>(); samples.add(new SamplePojo("Swap", gen.getNextValue(), "12800000")); listener.publishEvent(new EventPojo(node.getIpAddress(), symTime, "swap", samples)); }
public void produceMemEvents(NodePojo node) throws ExecutionException, InterruptedException, IOException { ChartPrettyRandomGenerator gen = memGenerator.get(node.getIpAddress()); if (gen == null) { gen = new ChartPrettyRandomGenerator(true, 128000000, 1000000); memGenerator.put(node.getIpAddress(), gen); } List<SamplePojo> samples = new ArrayList<SamplePojo>(); samples.add(new SamplePojo("Used", gen.getNextValue(), "128000000")); listener.publishEvent( new EventPojo(node.getIpAddress(), symTime, TopLevelConst.MEMORY_LINE_CHART_DATA, samples)); }