Package org.ngrinder.monitor.share.domain

Examples of org.ngrinder.monitor.share.domain.SystemInfo


  private void initSigar() {
    if (sigar == null) {
      sigar = new Sigar();
      try {
        netInterfaces = sigar.getNetInterfaceList();
        prev = new SystemInfo();
        prev.setBandWidth(getNetworkUsage());
      } catch (SigarException e) {
        LOGGER.error("Network usage data retrieval failed.", e);
      }
    }
View Full Code Here


   * Execute the collector to get the system info model.
   *
   * @return SystemInfo in current time
   */
  public synchronized SystemInfo execute() {
    SystemInfo systemInfo = new SystemInfo();
    systemInfo.setCollectTime(System.currentTimeMillis());
    try {
      BandWidth networkUsage = getNetworkUsage();
      BandWidth bandWidth = networkUsage.adjust(prev.getBandWidth());
      systemInfo.setBandWidth(bandWidth);
      systemInfo.setCPUUsedPercentage((float) sigar.getCpuPerc().getCombined() * 100);
      Cpu cpu = sigar.getCpu();
      systemInfo.setTotalCpuValue(cpu.getTotal());
      systemInfo.setIdleCpuValue(cpu.getIdle());
      Mem mem = sigar.getMem();
      systemInfo.setTotalMemory(mem.getTotal() / 1024L);
      systemInfo.setFreeMemory(mem.getActualFree() / 1024L);
      systemInfo.setSystem(OperatingSystem.IS_WIN32 ? SystemInfo.System.WINDOW : SystemInfo.System.LINUX);
      systemInfo.setCustomValues(getCustomMonitorData());
    } catch (Throwable e) {
      LOGGER.error("Error while getting system perf data:{}", e.getMessage());
      LOGGER.debug("Error trace is ", e);
    }
    prev = systemInfo;
View Full Code Here

    Map<String, SystemDataModel> rtnMap = new HashMap<String, SystemDataModel>();

    Random random = new Random();
    for (int i = 0; i < 80; i++) {
      client.update();
      SystemInfo info = client.getSystemInfo();
      if (info == null) {
        return;
      }
      info.setCustomValues(random.nextInt() + "," + random.nextInt());
      SystemDataModel data1 = new SystemDataModel(info, "3.1.2");
      rtnMap.put("test-" + random.nextInt(), data1);
      ThreadUtils.sleep(100);
    }
    String statusString = perfTestService.getProperSizedStatusString(rtnMap);
View Full Code Here

  @Override
  public void sampling(ISingleConsole singleConsole, PerfTest perfTest, IPerfTestService perfTestService, ImmutableStatisticsSet intervalStatistics, ImmutableStatisticsSet cumulativeStatistics) {
    for (Map.Entry<MonitorClientService, BufferedWriter> each : clientMap.entrySet()) {
      try {
        SystemInfo currentInfo = each.getKey().getSystemInfo();
        BufferedWriter bw = each.getValue();
        bw.write(currentInfo.toRecordString());
        bw.newLine();
      } catch (IOException e) {
        LOGGER.error("Error while saving file :" + e.getMessage());
      }
    }
View Full Code Here

    int i = 0;
    boolean sent = false;
    boolean received = false;

    while (i++ < 3) {
      SystemInfo systemInfo = collector.execute();
      ThreadUtils.sleep(2000);
      BandWidth bandWidth = systemInfo.getBandWidth();
      if (bandWidth.getReceivedPerSec() != 0) {
        received = true;
      }
      if (bandWidth.getSentPerSec() != 0) {
        sent = true;
      }
      assertThat(systemInfo.getFreeMemory(), not(0l));
      assertThat(systemInfo.getTotalMemory(), not(0l));
    }
    assertThat("sent", sent, is(true));
    assertThat("received", received, is(true));
  }
View Full Code Here

  public void run() {
    if (!this.clientMap.isEmpty()) {
      Map<String, SystemDataModel> systemInfoMap = newHashMap();
      for (MonitorClientService each : this.clientMap.keySet()) {
        each.update();
        final SystemInfo systemInfo = each.getSystemInfo();
        if (systemInfo.isParsed()) {
          systemInfoMap.put(each.getIp(), new SystemDataModel(systemInfo, "UNKNOWN"));
        }
      }
      perfTestService.updateMonitorStat(perfTestId, systemInfoMap);
    }
View Full Code Here

   *
   * @return {@link SystemDataModel} instance
   */
  public SystemDataModel getSystemDataModel() {
    try {
      SystemInfo systemInfo = agentSystemDataCollector.execute();
      return new SystemDataModel(systemInfo, this.version);
    } catch (Exception e) {
      LOGGER.error("Error while getting system data model : {} ", e.getMessage());
      LOGGER.debug("The error detail is ", e);
      return emptySystemDataModel;
View Full Code Here

   */
  public void update() {
    try {
      if (mBeanClient.isConnected()) {
        CompositeData cd = cast(mBeanClient.getAttribute(objectName, "SystemInfo"));
        SystemInfo systemInfo = new SystemInfo();
        systemInfo.parse(cd);
        systemInfo.setIp(ip);
        this.systemInfo = systemInfo;
      }
    } catch (Exception e) {
      LOGGER.error("Error while MonitorExecutorWorker is running. Disconnect this MBean client.", e);
    }
View Full Code Here

      @Override
      public SystemInfo call() {
        return monitorInfoStore.getSystemInfo(ip, getConfig().getMonitorPort());
      }
    });
    SystemInfo systemInfo = checkNotNull(submit.get(2, TimeUnit.SECONDS), "Monitoring data is not available.");
    return toJsonHttpEntity(new SystemDataModel(systemInfo, "UNKNOWN"));
  }
View Full Code Here

  @Test
  public void testMonitorClient() throws IOException {
    MonitorClientService client = new MonitorClientService("127.0.0.1", 13243);
    client.init();
    final SystemInfo monitorData = client.getSystemInfo();
    assertThat(monitorData.isParsed(), is(false));
    sleep(3000);
    client.update();
    SystemInfo monitorData2 = client.getSystemInfo();
    assertThat(monitorData2.isParsed(), is(true));
    assertThat(monitorData2, Matchers.notNullValue());
    assertThat(monitorData, not(monitorData2));

  }
View Full Code Here

TOP

Related Classes of org.ngrinder.monitor.share.domain.SystemInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.