DeleteRowSMIv2.java.txt
上传用户:aonuowh
上传日期:2021-05-23
资源大小:35390k
文件大小:2k
- * @(#)DeleteRowSMIv2.java
- * Copyright (c) 1996-2003 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
- * delete a arow from an SMIv2 table
- * by using com.adventnet.snmp.snmp2 package of AdventNetSNMP API.
- *
- * The user could run this application by giving the following usage.
- *
- * java DeleteRowSMIv2
- *
- *
- import java.lang.*;
- import java.util.*;
- import java.net.*;
- import com.adventnet.snmp.snmp2.*;
- public class DeleteRowSMIv2 {
- public static void main(String args[]) {
- // Start SNMP API
- SnmpAPI api = new SnmpAPI();
-
- // Open session
- SnmpSession session = new SnmpSession(api);
- try
- {
- session.open();
- }
- catch (SnmpException e )
- {
- System.err.println("Error opening socket: "+e);
- }
- // Build Get request PDU
- SnmpPDU pdu = new SnmpPDU();
- UDPProtocolOptions option = new UDPProtocolOptions("localhost");
- pdu.setProtocolOptions(option);
- pdu.setCommand(SnmpAPI.SET_REQ_MSG);
- //get oids
- SnmpOID oid=new SnmpOID(".1.3.6.1.4.1.2.2.1.4.15");
- //create SnmpVar object
- SnmpVar var = SnmpVar.createVariable("6",SnmpAPI.INTEGER);//6 refers to destroy.
- // add varbinds
- SnmpVarBind varbind = new SnmpVarBind(oid,var);
- pdu.addVariableBinding(varbind);
- // Send PDU and receive response PDU
- session.open();
- session.syncSend(pdu);
-
- // close session
- session.close();
-
- // close api thread
- api.close();
-
- }
- }