public static void main(String[] args) throws FileNotFoundException { BasicConfigurator.configure(); Logger.getRootLogger().setLevel(Level.WARN); Mib2Events convertor = new Mib2Events(); convertor.parseCli(args); try { convertor.convert(); } catch (FileNotFoundException e) { printError(convertor.getMibLocation(), e); System.exit(1); } catch (IOException e) { printError(convertor.getMibLocation(), e); } catch (MibLoaderException e) { e.getLog().printTo(System.err); System.exit(1); } if (convertor.getMib().getLog().warningCount() > 0) { convertor.getMib().getLog().printTo(System.err); } PrintStream out = System.out; out.println( "<!-- Start of auto generated data from MIB: " + convertor.getMib().getName() + " -->"); try { convertor.printEvents(out); } catch (Throwable e) { printError(convertor.getMibLocation(), e); System.exit(1); } out.println( "<!-- End of auto generated data from MIB: " + convertor.getMib().getName() + " -->"); }
/** * Loads a MIB file from a specified source. * * @param src the MIB file or URL */ public void loadMib(String src) { String message = null; setStatus("Loading " + src + "..."); try { browser.loadMib(src); } catch (FileNotFoundException e) { message = "Failed to load " + e.getMessage(); } catch (IOException e) { message = "Failed to load " + src + ": " + e.getMessage(); } catch (MibLoaderException e) { message = "Failed to load " + src; ByteArrayOutputStream output = new ByteArrayOutputStream(); e.getLog().printTo(new PrintStream(output)); descriptionArea.append(output.toString()); } if (message != null) { JOptionPane.showMessageDialog(this, message, "MIB Loading Error", JOptionPane.ERROR_MESSAGE); } setStatus(null); }