Пример #1
0
 // convert CPU status
 private CPUStatus convertCPUStatus(Result result) {
   CPUStatus cpuStatus = new CPUStatus();
   int[] loads = new int[result.getListResults().size()];
   int i = 0;
   for (Map<String, Object> properties : result.getListResults()) {
     int load = Integer.parseInt(String.valueOf(properties.get("cpuLoad")));
     loads[i++] = load;
     //			log().info(" cpu load " + load);
     // 加入到历史信息集合,便于后面存入DB
     m_hostEntityList.add(converHostHistory(properties, SnmpDeviceConstants.CPU));
   }
   cpuStatus.setLoads(loads);
   return cpuStatus;
 }
Пример #2
0
 // convert network status
 private NetworkStatus convertNetworkStatus(Result result) {
   NetworkStatus networkStatus = new NetworkStatus();
   int size = result.getListResults().size();
   InterfaceStatus[] interfaceStatus = new InterfaceStatus[size];
   int i = 0;
   for (Map<String, Object> properties : result.getListResults()) {
     InterfaceStatus bean = new InterfaceStatus();
     populate(bean, properties);
     //			log().info(bean.toString());
     interfaceStatus[i++] = bean;
     // 加入到历史信息集合,便于后面存入DB
     m_hostEntityList.add(converHostHistory(properties, SnmpDeviceConstants.NETWORK));
   }
   networkStatus.setInterfaceStatus(interfaceStatus);
   return networkStatus;
 }
Пример #3
0
  // convert hardDisk status
  private HardDiskStatus convertHardDiskStatus(Result result) {
    HardDiskStatus hardDiskStatus = new HardDiskStatus();
    List<PartitionStatus> partitionStatus = new ArrayList<PartitionStatus>();
    long used = 0;
    long size = 0;
    for (Map<String, Object> properties : result.getListResults()) {
      // 根据硬盘盘符类型OID判断 获取各盘符信息
      if (String.valueOf(properties.get("type")).equals(".1.3.6.1.2.1.25.2.1.4")) {
        PartitionStatus bean = new PartitionStatus();
        populate(bean, properties);
        //				log().info(bean.toString());
        // 加入到历史信息集合,便于后面存入DB
        m_hostEntityList.add(converHostHistory(properties, SnmpDeviceConstants.HARDDISK));

        used += bean.getUsed();
        size += bean.getSize();
        System.out.println(bean.getLabel());
        partitionStatus.add(bean);
      }
    }
    hardDiskStatus.setSize(size);
    hardDiskStatus.setUsed(used);
    hardDiskStatus.setPartitionStatus(partitionStatus);
    return hardDiskStatus;
  }
Пример #4
0
 // convert memory status
 private MemoryStatus convertMemoryStatus(Result result) {
   MemoryStatus memoryStatus = new MemoryStatus();
   for (Map<String, Object> properties : result.getListResults()) {
     // log().info(properties.toString());
     if (Integer.parseInt(String.valueOf(properties.get("index"))) == 8) {
       populate(memoryStatus, properties);
       //				log().info(memoryStatus.toString());
       // 加入到历史信息集合,便于后面存入DB
       m_hostEntityList.add(converHostHistory(properties, SnmpDeviceConstants.MEMORY));
       break;
     }
   }
   return memoryStatus;
 }
Пример #5
0
 // convert process status
 private ProcessesStatus convertProcessesStatus(Result result) {
   ProcessesStatus processesStatus = new ProcessesStatus();
   List<ProcessStatus> processStatuses = new ArrayList<ProcessStatus>();
   for (Map<String, Object> properties : result.getListResults()) {
     ProcessStatus bean = new ProcessStatus();
     populate(bean, properties);
     //			log().info(bean.toString());
     processStatuses.add(bean);
     // 加入到历史信息集合,便于后面存入DB
     //			m_hostHistoryEntity.add(converHostHistory(properties,
     //					SnmpDeviceConstants.PROCESS_HOST_RESOURCE));
   }
   processesStatus.setProcessStatus(processStatuses);
   log().info(processesStatus.toString());
   return processesStatus;
 }