public boolean isRequisitioned(OnmsMonitoredService monSvc) {
    String foreignSource = monSvc.getIpInterface().getNode().getForeignSource();
    String foreignId = monSvc.getIpInterface().getNode().getForeignId();

    // is this a discovered node
    if (foreignSource == null) return false;

    OnmsNode reqNode = getRequisitionedNode(foreignSource, foreignId);
    if (reqNode == null) {
      // this is no requisition node?
      LogUtils.errorf(
          "No requistion exists for node with foreignSource %s and foreignId %s.  Treating node as unrequistioned",
          foreignSource, foreignId);
      return false;
    }

    OnmsIpInterface reqIp = reqNode.getIpInterfaceByIpAddress(monSvc.getIpAddress());
    if (reqIp == null) {
      // there is no matching requistion ip so the interface was discovered
      return false;
    }

    OnmsMonitoredService reqSvc = reqIp.getMonitoredServiceByServiceType(monSvc.getServiceName());

    // if we found the service then its a requistion service
    return reqSvc != null;
  }
 /**
  * setMonitoredService
  *
  * @param monitoredService a {@link org.opennms.netmgt.model.OnmsMonitoredService} object.
  * @return a {@link org.opennms.netmgt.model.events.EventBuilder} object.
  */
 public EventBuilder setMonitoredService(final OnmsMonitoredService monitoredService) {
   if (monitoredService != null) {
     m_event.setNodeid(monitoredService.getNodeId().longValue());
     m_event.setInterfaceAddress(monitoredService.getIpAddress());
     m_event.setService(monitoredService.getServiceName());
   }
   return this;
 }
Beispiel #3
0
  Service(OnmsMonitoredService monSvc) {
    setId(monSvc.getId());
    setNodeId(monSvc.getNodeId());

    setIpAddress(InetAddressUtils.str(monSvc.getIpAddress()));
    setServiceId(monSvc.getServiceId());
    setServiceName(monSvc.getServiceName());
    if (monSvc.getLastGood() != null) {
      setLastGood(monSvc.getLastGood().toString());
    }
    if (monSvc.getLastFail() != null) {
      setLastFail(monSvc.getLastFail().toString());
    }
    setNotify(monSvc.getNotify());
    if (monSvc.getStatus() != null) {
      setStatus(monSvc.getStatus().charAt(0));
    }
  }
  @Override
  public List<String[]> getNodeServices(int nodeId) {
    final LinkedList<String[]> servicemap = new LinkedList<String[]>();

    Criteria criteria = new Criteria(OnmsMonitoredService.class);
    criteria.setAliases(
        Arrays.asList(
            new Alias[] {
              new Alias("ipInterface", "ipInterface", JoinType.LEFT_JOIN),
              new Alias("ipInterface.node", "node", JoinType.LEFT_JOIN)
            }));
    criteria.addRestriction(new EqRestriction("node.id", nodeId));
    criteria.addRestriction(new NeRestriction("status", "F")); // Ignore forced-unmanaged
    for (OnmsMonitoredService service : m_monitoredServiceDao.findMatching(criteria)) {
      servicemap.add(new String[] {service.getIpAddressAsString(), service.getServiceName()});
    }

    return servicemap;
  }