SnmpGetTable_one.java.txt
上传用户:aonuowh
上传日期:2021-05-23
资源大小:35390k
文件大小:1k
- /* $Id: SnmpGetTable_one.java,v 1.1 2002/06/15 14:40:08 ram Exp $ */
- /* SnmpGetTable_one.java
- * Copyright (c) 1996-2003 AdventNet, Inc. All Rights Reserved.
- * Please read the associated COPYRIGHTS file for more details.
- */
- import com.adventnet.snmp.beans.*;
- public class SnmpGetTable_one {
- public static void main(String args[]) {
- if (args.length < 2)
- {
- System.out.println ("Usage : java SnmpGetTable_one hostname tableoid ");
- System.exit (0);
- }
- String remoteHost = args[0];
- String tableoid = args[1];
- SnmpTable table = new SnmpTable();
- table.setTargetHost(remoteHost);
-
- try {
- table.loadMibs("RFC1213-MIB");
- table.setTableOID(tableoid);
- }catch (Exception ex) {
- }
-
- System.out.println("Getting table. Table items:");
- StringBuffer sb = new StringBuffer();
-
- try { Thread.sleep(10000); } // allow some time to get all rows
- catch (InterruptedException ex) {}
- for (int i=0;i<table.getColumnCount();i++) // print column names
- sb.append(table.getColumnName(i)+" t");
- System.out.println(sb.toString());
- StringBuffer sb2 = new StringBuffer();
- for (int i=0;i<table.getColumnCount();i++)
- for (int j=0;j<table.getRowCount();j++)
- sb2.append(table.getValueAt(j,i)+" t");
- System.out.println(sb2.toString());
- System.exit(0);
-
- }
-
- }