Solved

Java SNMP

Posted on 2002-04-30
6
260 Views
Last Modified: 2012-05-04
Actually my first question is basically part of my 2nd question. And I was wrong about the input. means, in my network elements(switches, routers) ping/echo services are not enabled.
So the part, I need to know is, how to find out the device
type from the snmp query ? Like, is it a router or ATM switch or firewall or SUN Solaris m/c etc.. ???
Is there any common mib ( mib II ??) or mibattribute
do I need to look ?
Is mib-II should be implemented if it is snmp enabled ?

anything will be appreciated.

Ramesh//
0
Comment
Question by:rameshaa
  • 3
  • 2
6 Comments
 
LVL 9

Expert Comment

by:Venci75
ID: 6980921
.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 6980952
Step 1 would require pinging those hosts. If you have access to the services running on all those hosts, you could run the Echo service on port 7, in which case you could use pure Java. Otherwise, you'd have to do a proper ping using ICMP, which would require you to use JNI.

Come back later about step 2!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 6981642
You could try this sort of thing:

mport java.io.*;
import java.net.*;
class Ping {
public static void main(String[] args) {
BufferedReader in = null;
try {
Runtime r = Runtime.getRuntime();
Process p = r.exec("ping 62.2.78.245");
if (p == null) {
System.out.println("Could not connect");
}
in = new BufferedReader(new InputStreamReader(p
.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
in.close();
} catch (IOException io) {
System.err.println(io.toString());
}
}
}
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Accepted Solution

by:
CEHJ earned 200 total points
ID: 6981659
Better indentation:

import java.io.*;
import java.net.*;

class Ping {

  public static void main(String[] args) {
    BufferedReader in = null;
    try {
      Runtime r = Runtime.getRuntime();
      Process p = r.exec("ping 62.2.78.245");
      if (p == null) {
        System.out.println("Could not connect");
      }
      in = new BufferedReader(new InputStreamReader(p.getInputStream()));
      String line;
      while ((line = in.readLine()) != null) {
        System.out.println(line);
      }
      in.close();
    }
    catch (IOException io) {
      System.err.println(io.toString());
    }
  }
}

0
 
LVL 9

Expert Comment

by:Venci75
ID: 7992748
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Answered by: CEHJ
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venci75
EE Cleanup Volunteer
0
 

Expert Comment

by:SpideyMod
ID: 8048335
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Should localization be done inside spring controller 5 37
Oracle SQL syntax check  without executing 6 107
throw exception 21 67
Java array 10 62
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question