// Home | Go Back //
import com.ireasoning.protocol.snmp.*;
import com.ireasoning.util.ParseArguments;
public class snmpgetbulk extends snmp
{
int _nonRepeators;
int _maxRepetitions;
public static void main(String[] args)
{
snmpgetbulk s = new snmpgetbulk();
s.parseOptions(args, "snmpgetbulk");
s.getbulk();
}
private void getbulk()
{
try
{
SnmpSession session = new SnmpSession(_host, _port, _community,
_community, _version, _transportLayer);
if(_isSnmpV3)
{
session.setV3Params(_user, _authProtocol, _authPassword, _privProtocol, _privPassword, _context, null);
}
SnmpPdu retPdu = session.snmpGetBulkRequest(_oids, _nonRepeators, _maxRepetitions);
print(retPdu);
session.close();
}
catch(Exception e)
{
System.out.println(e);
e.printStackTrace();
}
}
protected void moreOptions()
{
System.out.println( "-n <n>\tNon-Repeators value");
System.out.println( "-r <r>\tMax-Repetitions value");
}
protected void printExample(String programName)
{
System.out.println( "java " + programName + " -n 1 -r 5 localhost .1.3.6.1.2.1.1.1.0 .1.3.6.1.2.1.1.3");
}
protected void parseOptions(String[] args, String program)
{
super.parseOptions(args, program);
String nr = _parseArgs.getOptionValue('n');
if(nr == null)
{
throw new RuntimeException("Non-Repeators must be specified.");
}
_nonRepeators = Integer.parseInt(nr);
String mr = _parseArgs.getOptionValue('r');
if(mr == null)
{
throw new RuntimeException("Max-Repetitions must be specified.");
}
_maxRepetitions = Integer.parseInt(mr);
}
protected void printMoreOptions()
{
System.out.println( "Non-Repeators =\t\t" + _nonRepeators);
System.out.println( "Max-Repetitions =\t" + _maxRepetitions);
}
protected ParseArguments newParseArgumentsInstance(String[] args)
{
return new ParseArguments(args, "?ho", "utvaAXxcpmnrk");
}
}