Beispiel #1
0
  public void init() {
    String host = util.getHost();
    String bindAddr = util.getBindAddress();
    int port = util.getPort(ListeningContextFace.DEFAULT_TRAP_PORT);
    String socketType = util.getSocketType();
    // String oid = util.getOid();
    String community = util.getCommunity();

    try {
      context = new SnmpContextv2c(host, port, bindAddr, socketType);
      context.setCommunity(community);

      pdu = new TrapPduv2(context);
      pdu.addOid(sysUpTime, new AsnUnsInteger(5));
      pdu.addOid(snmpTrapOID, new AsnObjectId(warmStart));

      System.out.println(pdu.toString());
      pdu.send();

      // when calling destroy, the pdu might not be sent
      // context.destroy();
    } catch (java.io.IOException exc) {
      System.out.println("IOException " + exc.getMessage());
    } catch (uk.co.westhawk.snmp.stack.PduException exc) {
      System.out.println("PduException " + exc.getMessage());
    }
    // System.exit(0);
  }
  private void createPropertyDialog() {
    propDialog = new propertyDialog(null);

    String host = util.getHost();
    String port = "" + util.getPort(SnmpContextBasisFace.DEFAULT_PORT);
    String socketType = util.getSocketType();
    String comm = util.getCommunity();

    if (host != null) {
      propDialog.setHost(host);
    }
    if (port != null) {
      propDialog.setPort(port);
    }
    if (comm != null) {
      propDialog.setCommunityName(comm);
    }
    if (socketType != null) {
      propDialog.setSocketType(socketType);
    }
    propDialog.addActionListener(this);
    propDialog.pack();
  }
Beispiel #3
0
  public void init() {
    String host = util.getHost();

    h = new JLabel(host + " up since: ");
    v = new JLabel(" unknown ");
    setLayout(new GridLayout(2, 1));
    add(h);
    add(v);
    try {
      context = new SnmpContext(host, port);
    } catch (java.io.IOException exc) {
      System.out.println("IOException " + exc.getMessage());
      System.exit(0);
    }
  }
  public void init() {
    // get the host name
    String host = util.getHost();

    h = new JLabel("Host " + host + ", Interface " + intfIndex + " speed");
    try {
      context = new SnmpContext(host, port);
      context.setCommunity(community);

      setLayout(new GridLayout(2, 1));
      add(h);
      v = new JLabel(" unknown ");
      add(v);
    } catch (java.io.IOException exc) {
      System.out.println("IOException " + exc.getMessage());
      System.exit(0);
    }
  }
  private void jbInit() throws Exception {
    JLabel loid, lvalue;

    loid = new JLabel("OID: ");
    lvalue = new JLabel("Value: ");
    lmessage = new JLabel("");
    lmessage.setOpaque(true);

    String oid = util.getOid(sysContact);
    toid = new JTextField(oid);
    tvalue = new JTextField();

    setButton = new JButton("Set");
    getButton = new JButton("Get");
    getNextButton = new JButton("GetNext");

    Vector sw = new Vector(2);
    sw.addElement(setButton);
    sw.addElement(getButton);

    GridBagLayout grid = new GridBagLayout();
    Container cont = this;
    cont.setLayout(grid);

    addToGridBag(grid, cont, loid, 0, 0, 0.33, 1.0);
    addToGridBag(grid, cont, toid, 1, 0, 2, 1, 0.33, 1.0);
    addToGridBag(grid, cont, lvalue, 0, 1, 0.33, 1.0);
    addToGridBag(grid, cont, tvalue, 1, 1, 2, 1, 0.33, 1.0);
    addToGridBag(grid, cont, setButton, 0, 2, 0.33, 1.0);
    addToGridBag(grid, cont, getButton, 1, 2, 0.33, 1.0);
    addToGridBag(grid, cont, getNextButton, 2, 2, 0.33, 1.0);
    addToGridBag(grid, cont, lmessage, 0, 3, 3, 1, 0.33, 1.0);

    lmessage.setBackground(Color.white);

    setButton.addActionListener(this);
    getButton.addActionListener(this);
    getNextButton.addActionListener(this);
    this.addMouseListener(this);
  }