SnmpSet.java.txt
上传用户:aonuowh
上传日期:2021-05-23
资源大小:35390k
文件大小:1k
- /*$Id: SnmpSet.java,v 1.1 2002/06/15 14:41:18 ram Exp $*/
- /*
- * @(#)SnmpSet.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 change the value of sysName in the localhost's RFC1213-MIB using
- * com.adventnet.snmp.beans package of AdventNetSNMP API.
- *
- */
- import com.adventnet.snmp.beans.*;
- public class SnmpSet {
- 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.5")
- //load MIBs
- target.loadMibs("RFC-1213MIB");
- // perform a SET request
- String result = target.snmpSet("testing..");
- if (result == null)
- {
- System.err.println("Request failed or timed out. n"+
- target.getErrorString());
- }
- else
- {
- // print the values
- System.out.println("OBJECT ID: "+target.getObjectID()); System.out.println("Response: "+result);
- }
- System.exit(0);
- }
- }