public TabularIterator(SnmpConnection starter, Collection<OID> oids) { if(starter != null && starter.isStarted()) { Target snmpTarget = starter.getConnection(); if(snmpTarget != null) { DefaultPDUFactory localfactory = new DefaultPDUFactory(); TableUtils tableRet = new TableUtils(starter.getSnmp(), localfactory); tableRet.setMaxNumColumnsPerPDU(30); OID[] oidTab = new OID[oids.size()]; oids.toArray(oidTab); tabIterator = tableRet.getTable(snmpTarget, oidTab, null, null).iterator(); } } }
@Override public Map<OID, Object> doSnmpGet(SnmpConnection cnx, Collection<OID> oids) { Target snmpTarget = cnx.getConnection(); Snmp snmp = cnx.getSnmp(); if(cnx.isStarted() && snmpTarget != null && snmp != null) { TableUtils tableRet = new TableUtils(snmp, cnx.getPdufactory()); tableRet.setMaxNumColumnsPerPDU(30); OID[] oidTab = new OID[oids.size()]; oids.toArray(oidTab); SnmpVars retValue = new SnmpVars(); for(TableEvent te: tableRet.getTable(snmpTarget, oidTab, null, null)) { if(!cnx.isStarted()) { retValue = new SnmpVars(); break; } if(!te.isError()) { retValue.join(te.getColumns()); } } return retValue; } return Collections.emptyMap(); } },