Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
376 views
in Technique[技术] by (71.8m points)

java - How to define oid to realize one to many relationship between database instance and database parameter using SNMP4J_AGENT?

I am trying to monitore database information through snmp4j-agent. First, I found the RDBMS-MIB.txt file and implemented the corresponding RdbmsMib.java. Then, I follow the SampleAgent.java example and tips of snmp4j-agent-1.4-InstrumentationGuide.pdf, learn how to dynamically update the table by overwriting MOMutableColumn.java; but here I encounter some problems:

  1. When RdbmsMib.java When creating entry in, the corresponding index definition will be created according to the corresponding MIB file, but I don't know the use of these indexes;
public class MyMIB 
//--AgentGen BEGIN=_EXTENDS
//--AgentGen END
implements MOGroup 
//--AgentGen BEGIN=_IMPLEMENTS
//--AgentGen END
{
    .
    .
    .

public static final OID oidTableEntry = 
    new OID(new int[] { 1,3,6,1,4,1,1,99,5,4,1,3,1 });
    .
    .
    .

private void createTableEntry(MOFactory moFactory) {
// Index definition // question 1
    .
    .
    .
// Columns definition
    .
    .
    .

// Table model
tableEntryModel = 
  moFactory.createTableModel(oidTableEntry,
                         tableEntryIndex,
                         tableEntryColumns);
((MOMutableTableModel)tableEntryModel).setRowFactory(
  new TableEntryRowFactory());
tableEntry = 
  moFactory.createTable(oidTableEntry,
                    tableEntryIndex,
                    tableEntryColumns,
                    tableEntryModel);

//Adding rows
ArrayList<Integer> oidMon1List= new ArrayList<Integer>();
oidRow1List = this.getListFromArray(oidTableEntry.getValue());
oidRow1List.add(1);

ArrayList<Integer> oidMon2List= new ArrayList<Integer>();
oidRow2List = this.getListFromArray(oidTableEntry.getValue());
oidRow2List.add(2);

DefaultMOMutableTableModel model =
               (DefaultMOMutableTableModel)tableEntry.getModel();

synchronized(model){
//question 2 : the relationship of new OID("1") and index definition
model.addRow(
        model.createRow(
                new OID("1"), 
                new Variable[]{
                    new Integer32(123)
                    }));

model.addRow(
        model.createRow(
                new OID("2"), 
                new Variable[]{
                    new Integer32(456)
                    }));   
    }
}
  1. How to define OID to realize one to many relationship between database instance and database parameter using SNMP4J-AGENT?. For example, I have a database instance, which has many parameter names and corresponding parameter information (including parameter values and parameter descriptions), which is similar to RDBMS-MIB.txt rdbmsDbParamTable. However, what I understand is that they all correspond to an OID value, so I don't know how to distinguish them? Is it related to index in question 1?
paramName paramVal paramComment
-------------------------------
pageSize  20       the page size
-------------------------------
logSize   30       the log size
   .
   .
   .

For example, I have two database instance, db1 and db2. So, db1 has params(pageSize=20,logSize=30,...) and db2 has params(pageSize=40,logSize=50), but in Rdbms-MIB.txt, they use one table entry OID ...39.1.3.1, in this case, How to distinguish them and define OID? Say thanks advance.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...