SnmpGet.java.txt
上传用户:aonuowh
上传日期:2021-05-23
资源大小:35390k
文件大小:1k
- /*$Id: SnmpGet.java,v 1.1 2002/06/15 14:41:18 ram Exp $*/
- /*
- * @(#)SnmpGet.java
- * Copyright (c) 1996-2001 AdventNet, Inc. All Rights Reserved.
- * Please read the associated COPYRIGHTS file for more details.
- */
- /**
- * This is an example program to explain how to write an application
- * to retrieve information about the managed nodes that fall under
- * the system group in the localhost's RFC1213-MIB using
- * com.adventnet.snmp.beans package of AdventNetSNMP API.
- *
- */
- import com.adventnet.snmp.beans.*;
- public class SnmpGet {
- public static void main(String args[]) {
- // instantiate SNMP target bean
- SnmpTarget target = new SnmpTarget();
- // set the host in which the SNMP agent is running
- target.setTargetHost("localhost");
-
- // set the OID
- target.setObjectID(".1.3.6.1.2.1.1.0")
- // perform a GET request
- String result = target.snmpGet();
- if (result == null)
- {
- System.err.println("Request failed or timed out. n"+
- target.getErrorString());
- }
- else
- {
- // print the values
- System.out.println("Response received. Value:" + result);
- }
- System.exit(0);
- }
- }