Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
  }
Exemplo n.º 4
0
 public SnmpDeviceHistoryBaseStatus process(Results results) {
   SnmpDeviceHistoryBaseStatus baseStatus = null; // 保存状态和入库信息
   HostDeviceStatus hostDeviceStatus = new HostDeviceStatus(); // 状态信息,供前台调用
   if (results != null && results.getResultList() != null) {
     for (Result result : results.getResultList()) {
       String deviceName = result.getTrackerName();
       if ("ifTable".equals(deviceName)) {
         // 网络设备状态
         NetworkStatus networkStatus = convertNetworkStatus(result);
         hostDeviceStatus.setNetworkStatus(networkStatus);
         continue;
       }
       if ("hrStorageTable".equals(deviceName)) {
         // 内存状态
         hostDeviceStatus.setMemoryStatus(convertMemoryStatus(result));
         // 硬盘状态
         hostDeviceStatus.setHardDiskStatus(convertHardDiskStatus(result));
         continue;
       }
       if ("hrProcessorTable".equals(deviceName)) {
         // CPU状态
         hostDeviceStatus.setCpuStatus(convertCPUStatus(result));
         continue;
       }
       if ("hrSWRunTable".equals(deviceName)) {
         // 进程状态
         hostDeviceStatus.setProcessesStatus(convertProcessesStatus(result));
         continue;
       }
     }
   }
   // 入库设置
   if (!m_hostEntityList.isEmpty()) {
     baseStatus = new SnmpDeviceHistoryBaseStatus();
     copyProperties(results.getNodeid(), results.getIpAddr(), results.getBrand());
     baseStatus.setSnmpDeviceHistoryBaseEntity(m_baseEntity);
     hostDeviceStatus.setActive(true);
     hostDeviceStatus.setNodeid(results.getNodeid());
     hostDeviceStatus.setIpAddr(results.getIpAddr());
     hostDeviceStatus.setDomain(SnmpDeviceLocator.getDomainId(results.getNodeid()));
     baseStatus.setHostDeviceStatus(hostDeviceStatus);
   }
   return baseStatus;
 }
Exemplo n.º 5
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;
 }
Exemplo n.º 6
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;
 }