/* $Id: TrapViewerApplication.java,v 1.3.2.4 2009/10/13 07:45:34 prathika Exp $ */ /* * @(#)TrapViewerApplication.java * Copyright (c) 1996-2009 ZOHO Corp. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. */ /** * This is a example program for TrapViewer bean . * The TrapViewer is used to receive traps on a specified port, parsing received * traps based on a parser file and display the parsed traps. Traps are shown based * on match criteria. Trap parser file should have set of match criteria. The * match criteria is called TrapParser. We can specify any number of TrapParsers * in a TrapParser file. */ import javax.swing.*; import java.awt.event.*; import com.adventnet.snmp.ui.*; //import ParseOptions; public class TrapViewerApplication extends JFrame { // the main method for this application public static void main(String [] args) { String usage = "java TrapViewerApplication [-p port] [-c community] [-m MIB_files] [-f parser_file]"; String options[] = { "-p", "-c", "-m", "-f"}; String values[] = { null, null, null, null}; ParseOptions opt = new ParseOptions(args,options,values, usage); //Instantiate TrapViewer TrapViewer trapviewer = new TrapViewer(); if (values[0] != null) { try { // set the port for receiving traps trapviewer.setPort(Integer.parseInt(values[0])); } catch (Exception ex) { System.err.println("Error setting port : " + ex.getMessage()); } } if (values[1] != null) { trapviewer.setCommunity(values[1]); } if(values[2] != null) { try { trapviewer.setMibModules(values[2]); } catch(Exception e) { System.out.println("Mib Loading Failed: " + e.getMessage()); } } if (values[3] != null) { // set the parser file for parsing traps trapviewer.setFileName(values[3]); } TrapViewerApplication frame = new TrapViewerApplication(); frame.setTitle("TrapViewerApplication"); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); frame.getContentPane().add(trapviewer); frame.setSize(600,350); frame.setVisible(true); } }