SnmpGetTable.java.txt
上传用户:aonuowh
上传日期:2021-05-23
资源大小:35390k
文件大小:1k
- /* $Id: SnmpGetTable.java,v 1.1 2002/06/15 14:41:18 ram Exp $ */
- /* SnmpGetTable.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 {
- public static void main(String args[]) {
- if (args.length < 1)
- {
- System.out.println ("Usage : java SnmpGetTable tableoid");
- System.exit (0);
- }
- String tableoid = args[0];
- SnmpTable table = new SnmpTable();
- table.setTargetHost("localhost);
- try
- {
- table.loadMibs("RFC1213-MIB");
- table.setTableOID(tableoid);
- }
- catch (Exception ex)
- {
- System.err.println("Error: "+ex);
- }
- System.out.println("Getting table. Table items:");
- // allow some time to get all rows
- Thread.sleep(5000);
- StringBuffer sb = new StringBuffer();
- try
- {
- // allow some time to get all rows
- Thread.sleep(10000);
- }
- 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);
- }
- }