private void sendRequest(BlockPdu pdu) {
   setButton.setEnabled(false);
   getButton.setEnabled(false);
   getNextButton.setEnabled(false);
   lmessage.setText("Sending request ..");
   lmessage.setBackground(Color.white);
   try {
     varbind var = pdu.getResponseVariableBinding();
     AsnObjectId oid = var.getOid();
     AsnObject res = var.getValue();
     if (res != null) {
       toid.setText(oid.toString());
       tvalue.setText(res.toString());
       lmessage.setText("Received aswer ");
       lmessage.setBackground(Color.white);
     } else {
       lmessage.setText("Received no aswer ");
       lmessage.setBackground(Color.red);
     }
   } catch (PduException exc) {
     lmessage.setText("PduException: " + exc.getMessage());
     lmessage.setBackground(Color.red);
     exc.printStackTrace();
   } catch (java.io.IOException exc) {
     lmessage.setText("IOException: " + exc.getMessage());
     lmessage.setBackground(Color.red);
     exc.printStackTrace();
   }
   setButton.setEnabled(true);
   getButton.setEnabled(true);
   getNextButton.setEnabled(true);
 }
Beispiel #2
0
 public void start() {
   if (context != null) {
     try {
       UpSincePdu up = new UpSincePdu(context, this);
     } catch (java.io.IOException exc) {
       System.out.println("start(): IOException " + exc.getMessage());
     } catch (PduException exc) {
       System.out.println("start(): PduException " + exc.getMessage());
     }
   }
 }
  private void createContext(String host, int port, String comm, String socketType) {
    myFrame.setTitle("Set One  - " + host);

    if (context != null) {
      context.destroy();
    }
    try {
      context = new SnmpContextPool(host, port, socketType);
      context.setCommunity(comm);
    } catch (java.io.IOException exc) {
      lmessage.setText("IOException: " + exc.getMessage());
      lmessage.setBackground(Color.red);
    }
  }
Beispiel #4
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 run() {
   // We might not get an error, since it is not sure if an
   // interface exists with this intfIndex as index!
   InterfacePdu up2;
   while (context != null) {
     try {
       up2 = new InterfacePdu(context, this, intfIndex);
       Thread.sleep(interval);
     } catch (InterruptedException exc) {;
     } catch (java.io.IOException exc) {
       System.out.println("run(): IOException " + exc.getMessage());
     } catch (PduException exc) {
       System.out.println("run(): PduException " + exc.getMessage());
     }
   }
 }
  /** Commits changes on all known Bean preference editors. */
  private void commit() {
    java.util.Iterator i = mPrefsBeans.iterator();

    while (i.hasNext()) {
      BeanPreferences bean = (BeanPreferences) i.next();

      try {
        bean.save();
      } catch (java.io.IOException io_ex) {
        JOptionPane.showMessageDialog(
            null,
            "Could not save preferences for " + bean.getEditorName() + ": " + io_ex.getMessage(),
            "I/O Exception on Save",
            JOptionPane.ERROR_MESSAGE);
      }
    }
  }
  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 createContext(String host, String portStr, String comm, String socketType) {
    int port = SnmpContextBasisFace.DEFAULT_PORT;
    try {
      port = Integer.valueOf(portStr).intValue();
    } catch (NumberFormatException exc) {
    }

    if (context != null) {
      context.destroy();
      // context.dumpContexts("destroy");
    }
    try {
      context = new SnmpContextPool(host, port, socketType);
      context.setCommunity(comm);
      // context.dumpContexts("create:");
      System.out.println(context);
    } catch (java.io.IOException exc) {
      exc.printStackTrace();
    }
  }
Beispiel #9
0
 /**
  * Gets an image resource.
  *
  * @param strResourceFilename Name of the image file.
  * @param srcClass Class from which the location of the resource is determined.
  * @return Instance of an <code>Image</code>.
  */
 public static Image getImageResourceFile(String strResourceFilename, Class srcClass) {
   PngImage pngImage = null;
   Image image = null;
   try {
     BufferedInputStream in =
         new BufferedInputStream(srcClass.getResourceAsStream(strResourceFilename));
     if (in == null) {
       System.err.println("Image not found:" + strResourceFilename);
       return null;
     }
     if (strResourceFilename.endsWith(".png")) {
       pngImage = new PngImage(in);
       image = Toolkit.getDefaultToolkit().createImage(pngImage);
     } else {
       ByteArrayOutputStream out = new ByteArrayOutputStream();
       copy(in, out);
       image = Toolkit.getDefaultToolkit().createImage(out.toByteArray());
     }
   } catch (java.io.IOException e) {
     System.err.println("Unable to read image " + strResourceFilename + ".");
     e.printStackTrace();
   }
   return (image);
 }
  private VirtualMachine launch(DebuggerInfo info) throws DebuggerException {
    // create process & read password for local debugging

    // create main class & arguments ...............................................
    StringBuffer sb = new StringBuffer();
    sb.append(mainClassName);
    String[] infoArgs = info.getArguments();
    int i, k = infoArgs.length;
    for (i = 0; i < k; i++) sb.append(" \"").append(infoArgs[i]).append('"'); // NOI18N
    String main = new String(sb);

    // create connector ..............................................................
    VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
    java.util.List lcs = vmm.launchingConnectors();
    k = lcs.size();
    for (i = 0; i < k; i++)
      if (((LaunchingConnector) lcs.get(i)).name().indexOf("RawCommandLineLaunch") >= 0) // NOI18N
      break;
    if (i == k) {
      finishDebugger();
      throw new DebuggerException(
          new MessageFormat(bundle.getString("EXC_Cannot_find_launcher"))
              .format(
                  new Object[] {
                    "RawCommandLineLaunch" // NOI18N
                  }));
    }
    LaunchingConnector lc = (LaunchingConnector) lcs.get(i);
    String transport = lc.transport().name();

    // create commandLine & NbProcessDescriptor ..............................
    NbProcessDescriptor debugerProcess;
    if (info instanceof ProcessDebuggerInfo)
      debugerProcess = ((ProcessDebuggerInfo) info).getDebuggerProcess();
    else debugerProcess = ProcessDebuggerType.DEFAULT_DEBUGGER_PROCESS;

    // generate password
    String password;
    if (transport.equals("dt_shmem")) { // NOI18N
      connector = getAttachingConnectorFor("dt_shmem");
      password = generatePassword();
      args = connector.defaultArguments();
      ((Argument) args.get("name")).setValue(password);
    } else {
      try {
        java.net.ServerSocket ss = new java.net.ServerSocket(0);
        password = "" + ss.getLocalPort(); // NOI18N
        ss.close();
      } catch (java.io.IOException e) {
        finishDebugger();
        throw new DebuggerException(
            new MessageFormat(bundle.getString("EXC_Cannot_find_empty_local_port"))
                .format(new Object[] {e.toString()}));
      }
      connector = getAttachingConnectorFor("dt_socket");
      args = connector.defaultArguments();
      ((Argument) args.get("port")).setValue(password);
    }
    HashMap map =
        Utils.processDebuggerInfo(
            info,
            "-Xdebug -Xnoagent -Xrunjdwp:transport="
                + // NOI18N
                transport
                + ",address="
                + // NOI18N
                password
                + ",suspend=y ", // NOI18N
            main);
    MapFormat format = new MapFormat(map);
    String commandLine =
        format.format(
            debugerProcess.getProcessName()
                + " "
                + // NOI18N
                debugerProcess.getArguments());
    println(commandLine, ERR_OUT);
    /*
    We mus wait on process start to connect...
    try {
      process = debugerProcess.exec (format);
    } catch (java.io.IOException exc) {
      finishDebugger ();
      throw new DebuggerException (
        new MessageFormat (bundle.getString ("EXC_While_create_debuggee")).
          format (new Object[] {
            debugerProcess.getProcessName (),
            exc.toString ()
          }),
        exc
      );
    }
    return connect (
      null,
      connector,
      args
    );*/

    /*      S ystem.out.println ("attaching: ");
    Utils.showConnectors (vmm.attachingConnectors ());

    S ystem.out.println ("launching: ");
    Utils.showConnectors (vmm.launchingConnectors ());

    S ystem.out.println ("listening: ");
    Utils.showConnectors (vmm.listeningConnectors ());*/

    // set debugger-start arguments
    Map params = lc.defaultArguments();
    ((Argument) params.get("command"))
        .setValue( // NOI18N
            commandLine);
    ((Argument) params.get("address"))
        .setValue( // NOI18N
            password);

    // launch VM
    try {
      return lc.launch(params);
    } catch (VMStartException exc) {
      showOutput(process = exc.process(), ERR_OUT, ERR_OUT);
      finishDebugger();
      throw new DebuggerException(
          new MessageFormat(bundle.getString("EXC_While_create_debuggee"))
              .format(
                  new Object[] {format.format(debugerProcess.getProcessName()), exc.toString()}),
          exc);
    } catch (Exception exc) {
      finishDebugger();
      throw new DebuggerException(
          new MessageFormat(bundle.getString("EXC_While_create_debuggee"))
              .format(
                  new Object[] {format.format(debugerProcess.getProcessName()), exc.toString()}),
          exc);
    }
  }