use of org.netxms.client.snmp.SnmpObjectIdFormatException in project netxms by netxms.
the class GeneralTable method selectParameter.
/**
* Select parameter
*/
private void selectParameter() {
Dialog dlg;
editor.setSourceNode(sourceNode.getObjectId());
switch(origin.getSelectionIndex()) {
case DataCollectionObject.AGENT:
if (sourceNode.getObjectId() != 0)
dlg = new SelectAgentParamDlg(getShell(), sourceNode.getObjectId(), origin.getSelectionIndex(), true);
else
dlg = new SelectAgentParamDlg(getShell(), dci.getNodeId(), origin.getSelectionIndex(), true);
break;
case DataCollectionObject.SNMP:
case DataCollectionObject.CHECKPOINT_SNMP:
SnmpObjectId oid;
try {
oid = SnmpObjectId.parseSnmpObjectId(parameter.getText());
} catch (SnmpObjectIdFormatException e) {
oid = null;
}
if (sourceNode.getObjectId() != 0)
dlg = new SelectSnmpParamDlg(getShell(), oid, sourceNode.getObjectId());
else
dlg = new SelectSnmpParamDlg(getShell(), oid, dci.getNodeId());
break;
case DataCollectionItem.SCRIPT:
dlg = new SelectParameterScriptDialog(getShell());
break;
default:
dlg = null;
break;
}
if ((dlg != null) && (dlg.open() == Window.OK)) {
IParameterSelectionDialog pd = (IParameterSelectionDialog) dlg;
description.setText(pd.getParameterDescription());
parameter.setText(pd.getParameterName());
editor.fireOnSelectTableListeners(origin.getSelectionIndex(), pd.getParameterName(), pd.getParameterDescription());
}
}
use of org.netxms.client.snmp.SnmpObjectIdFormatException in project netxms by netxms.
the class MibSelectionDialog method doWalk.
/**
* Do SNMP walk
*/
private void doWalk() {
try {
final SnmpObjectId root = SnmpObjectId.parseSnmpObjectId(oid.getText());
MibWalkDialog dlg = new MibWalkDialog(getShell(), nodeId, root);
if (dlg.open() == Window.OK) {
SnmpValue v = dlg.getValue();
if (v != null) {
oid.setText(v.getName());
}
}
} catch (SnmpObjectIdFormatException e) {
MessageDialogHelper.openError(getShell(), Messages.get().MibSelectionDialog_Error, Messages.get().MibSelectionDialog_OIDParseError);
}
}
use of org.netxms.client.snmp.SnmpObjectIdFormatException in project netxms by netxms.
the class ParamMappingEditDialog method selectObjectId.
/**
* Select OID using MIB selection dialog
*/
private void selectObjectId() {
SnmpObjectId oid;
try {
oid = SnmpObjectId.parseSnmpObjectId(objectId.getText());
} catch (SnmpObjectIdFormatException e) {
oid = null;
}
MibSelectionDialog dlg = new MibSelectionDialog(getShell(), oid, 0);
if (dlg.open() == Window.OK) {
objectId.setText(dlg.getSelectedObjectId().toString());
objectId.setFocus();
}
}
use of org.netxms.client.snmp.SnmpObjectIdFormatException in project netxms by netxms.
the class SnmpTest method testSnmpObjectId.
public void testSnmpObjectId() throws Exception {
// Test parse and equals
final SnmpObjectId oid1 = new SnmpObjectId(new long[] { 1, 3, 6, 1, 2, 1, 1, 1, 0 });
final SnmpObjectId oid2 = SnmpObjectId.parseSnmpObjectId(".1.3.6.1.2.1.1.1.0");
assertEquals(oid1, oid2);
// Test toString
assertEquals(".1.3.6.1.2.1.1.1.0", oid1.toString());
// Test format exception
try {
SnmpObjectId.parseSnmpObjectId(".1.2.bad.4");
assertFalse(true);
} catch (SnmpObjectIdFormatException e) {
System.out.println("Bad OID format: " + e.getMessage());
}
try {
SnmpObjectId.parseSnmpObjectId("1.2.3.4");
assertFalse(true);
} catch (SnmpObjectIdFormatException e) {
System.out.println("Bad OID format: " + e.getMessage());
}
try {
SnmpObjectId.parseSnmpObjectId(".");
assertFalse(true);
} catch (SnmpObjectIdFormatException e) {
System.out.println("Bad OID format: " + e.getMessage());
}
}
use of org.netxms.client.snmp.SnmpObjectIdFormatException in project netxms by netxms.
the class General method selectParameter.
/**
* Select parameter
*/
private void selectParameter() {
Dialog dlg;
switch(origin.getSelectionIndex()) {
case DataCollectionItem.INTERNAL:
if (sourceNode.getObjectId() != 0)
dlg = new SelectInternalParamDlg(getShell(), sourceNode.getObjectId());
else
dlg = new SelectInternalParamDlg(getShell(), dci.getNodeId());
break;
case DataCollectionItem.AGENT:
case DataCollectionItem.DEVICE_DRIVER:
if (sourceNode.getObjectId() != 0)
dlg = new SelectAgentParamDlg(getShell(), sourceNode.getObjectId(), origin.getSelectionIndex(), false);
else
dlg = new SelectAgentParamDlg(getShell(), dci.getNodeId(), origin.getSelectionIndex(), false);
break;
case DataCollectionItem.SNMP:
case DataCollectionItem.CHECKPOINT_SNMP:
SnmpObjectId oid;
try {
oid = SnmpObjectId.parseSnmpObjectId(parameter.getText());
} catch (SnmpObjectIdFormatException e) {
oid = null;
}
if (sourceNode.getObjectId() != 0)
dlg = new SelectSnmpParamDlg(getShell(), oid, sourceNode.getObjectId());
else
dlg = new SelectSnmpParamDlg(getShell(), oid, dci.getNodeId());
break;
case DataCollectionItem.WINPERF:
if (sourceNode.getObjectId() != 0)
dlg = new WinPerfCounterSelectionDialog(getShell(), sourceNode.getObjectId());
else
dlg = new WinPerfCounterSelectionDialog(getShell(), dci.getNodeId());
break;
case DataCollectionItem.SCRIPT:
dlg = new SelectParameterScriptDialog(getShell());
break;
default:
dlg = null;
break;
}
if ((dlg != null) && (dlg.open() == Window.OK)) {
IParameterSelectionDialog pd = (IParameterSelectionDialog) dlg;
description.setText(pd.getParameterDescription());
parameter.setText(pd.getParameterName());
dataType.select(getDataTypePosition(pd.getParameterDataType()));
editor.fireOnSelectItemListeners(origin.getSelectionIndex(), pd.getParameterName(), pd.getParameterDescription(), pd.getParameterDataType());
}
}
Aggregations