Пример #1
0
 /**
  * Convert MIB to events.
  *
  * @param module the module object
  * @param ueibase the UEI base
  * @return the events
  */
 protected Events convertMibToEvents(SmiModule module, String ueibase) {
   Events events = new Events();
   for (SmiNotificationType trap : module.getNotificationTypes()) {
     events.addEvent(getTrapEvent(trap, ueibase));
   }
   for (SmiTrapType trap : module.getTrapTypes()) {
     events.addEvent(getTrapEvent(trap, ueibase));
   }
   return events;
 }
Пример #2
0
  public void printEvents(PrintStream out)
      throws MarshalException, ValidationException, ParserConfigurationException, SAXException,
          IOException {
    if (m_loader == null) {
      throw new IllegalStateException("convert() must be called first");
    }

    for (Mib mib : m_loader.getAllMibs()) {
      if (!mib.isLoaded()) {
        continue;
      }

      Events events = convertMibToEvents(mib, getEffectiveUeiBase());

      if (events.getEventCount() < 1) {
        System.err.println(
            "No trap or notification definitions found in this MIB ("
                + mib.getName()
                + "), exiting");
        System.exit(0);
      }

      if (!m_compat) {
        StringWriter writer = new StringWriter();

        events.marshal(writer);

        stripXmlNameSpace(writer.toString(), out);
      } else {
        for (Event event : events.getEventCollection()) {
          StringWriter writer = new StringWriter();

          event.marshal(writer);

          ByteArrayOutputStream formattedXml = new ByteArrayOutputStream();

          stripXmlNameSpace(writer.toString(), formattedXml);

          String noXmlProcessingInstruction =
              formattedXml
                  .toString()
                  .replaceAll("(?m)<\\?xml version=\"1.0\" encoding=\"UTF-8\"\\?>\n", "");
          out.print(
              noXmlProcessingInstruction.replaceAll("dest=\"logndisplay\"", "dest='logndisplay'"));
        }
      }
    }
  }
Пример #3
0
  public Events convertMibToEvents(Mib mib, String ueibase) {
    Events events = new Events();
    for (MibSymbol sym : getAllSymbolsFromMib(mib)) {
      if (!(sym instanceof MibValueSymbol)) {
        continue;
      }

      MibValueSymbol vsym = (MibValueSymbol) sym;
      if ((!(vsym.getType() instanceof SnmpNotificationType))
          && (!(vsym.getType() instanceof SnmpTrapType))) {
        continue;
      }

      events.addEvent(getTrapEvent(vsym, ueibase));
    }
    return events;
  }