use of org.openmuc.framework.driver.snmp.SnmpDriver in project OpenMUC by isc-konstanz.
the class SnmpScannerExample method main.
/**
* @param args
*/
public static void main(String[] args) {
SnmpDriver myDriver = new SnmpDriver();
String settings = SnmpDriverSettingVariableNames.AUTHENTICATIONPASSPHRASE + "=adminadmin:" + SnmpDriverScanSettingVariableNames.STARTIP + "=192.168.1.0:" + SnmpDriverScanSettingVariableNames.ENDIP + "=192.168.10.0";
class TestListener implements DriverDeviceScanListener {
@Override
public void scanProgressUpdate(int progress) {
}
@Override
public void deviceFound(DeviceScanInfo device) {
System.out.println("-----------------------------");
System.out.println("New device found: ");
System.out.println("Address: " + device.getAddress());
System.out.println("Description: " + device.getDescription());
System.out.println("-----------------------------");
}
}
;
TestListener listener = new TestListener();
try {
myDriver.scanForDevices(settings, listener);
Thread.sleep(100);
} catch (InterruptedException iex) {
System.out.println("Request cancelled: " + iex.getMessage());
} catch (ArgumentSyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ScanException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ScanInterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.openmuc.framework.driver.snmp.SnmpDriver in project OpenMUC by isc-konstanz.
the class UsecaseExample method main.
/**
* @param args
*/
public static void main(String[] args) {
try {
SnmpDriver snmpDriver = new SnmpDriver();
// SNMPVersion=V2c:COMMUNITY=root:SECURITYNAME=root:AUTHENTICATIONPASSPHRASE=adminadmin:PRIVACYPASSPHRASE=adminadmin
String settings = SnmpDriverSettingVariableNames.SNMP_VERSION + "=" + SNMPVersion.V2c + ":" + SnmpDriverSettingVariableNames.USERNAME + "=root:" + SnmpDriverSettingVariableNames.SECURITYNAME + "=root:" + SnmpDriverSettingVariableNames.AUTHENTICATIONPASSPHRASE + "=adminadmin:" + SnmpDriverSettingVariableNames.PRIVACYPASSPHRASE + "=adminadmin";
System.out.println(settings);
SnmpDevice myDevice = (SnmpDevice) snmpDriver.connect("192.168.1.1/161", settings);
List<ChannelRecordContainer> containers = new ArrayList<>();
SnmpChannel ch1 = new SnmpChannel("192.168.1.1/161", "1.3.6.1.2.1.1.1.0");
SnmpChannel ch2 = new SnmpChannel("192.168.1.1/161", "1.3.6.1.2.1.25.1.1.0");
SnmpChannel ch3 = new SnmpChannel("192.168.1.1/161", "1.3.6.1.2.1.1.5.0");
containers.add(new SnmpChannelRecordContainer(ch1));
containers.add(new SnmpChannelRecordContainer(ch2));
containers.add(new SnmpChannelRecordContainer(ch3));
myDevice.read(containers, null, null);
for (ChannelRecordContainer container : containers) {
if (container.getRecord() != null) {
System.out.println(container.getRecord().getValue());
}
}
} catch (ConnectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ArgumentSyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.openmuc.framework.driver.snmp.SnmpDriver in project OpenMUC by isc-konstanz.
the class SnmpTest method beforeClass.
@BeforeAll
public static void beforeClass() {
snmpDriver = new SnmpDriver();
correctSetting = SnmpDriverSettingVariableNames.USERNAME + "=username:" + SnmpDriverSettingVariableNames.SECURITYNAME + "=securityname:" + SnmpDriverSettingVariableNames.AUTHENTICATIONPASSPHRASE + "=password:" + SnmpDriverSettingVariableNames.PRIVACYPASSPHRASE + "=privacy";
}
Aggregations