use of org.netxms.client.snmp.SnmpTrap in project netxms by netxms.
the class SnmpTrapEditor method deleteTraps.
/**
* Delete selected traps
*/
protected void deleteTraps() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
final Object[] objects = selection.toArray();
new ConsoleJob(Messages.get().SnmpTrapEditor_DeleteJob_Title, this, Activator.PLUGIN_ID, null) {
@Override
protected String getErrorMessage() {
return Messages.get().SnmpTrapEditor_DeleteJob_Error;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (int i = 0; i < objects.length; i++) {
session.deleteSnmpTrapConfiguration(((SnmpTrap) objects[i]).getId());
}
}
}.start();
}
use of org.netxms.client.snmp.SnmpTrap in project netxms by netxms.
the class SnmpTrapComparator method compare.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
TableColumn sortColumn = ((TableViewer) viewer).getTable().getSortColumn();
if (sortColumn == null)
return 0;
int rc;
SnmpTrap trap1 = (SnmpTrap) e1;
SnmpTrap trap2 = (SnmpTrap) e2;
switch(// $NON-NLS-1$
(Integer) sortColumn.getData("ID")) {
case SnmpTrapEditor.COLUMN_ID:
rc = Long.signum(trap1.getId() - trap2.getId());
break;
case SnmpTrapEditor.COLUMN_TRAP_OID:
rc = trap1.getObjectId().compareTo(trap2.getObjectId());
break;
case SnmpTrapEditor.COLUMN_EVENT:
EventObject evo1 = session.findEventObjectByCode(trap1.getEventCode());
EventObject evo2 = session.findEventObjectByCode(trap2.getEventCode());
String name1 = (evo1 != null) ? evo1.getName() : Messages.get().SnmpTrapComparator_Unknown;
String name2 = (evo2 != null) ? evo2.getName() : Messages.get().SnmpTrapComparator_Unknown;
rc = name1.compareToIgnoreCase(name2);
break;
case SnmpTrapEditor.COLUMN_DESCRIPTION:
rc = trap1.getDescription().compareToIgnoreCase(trap2.getDescription());
break;
default:
rc = 0;
break;
}
int dir = ((TableViewer) viewer).getTable().getSortDirection();
return (dir == SWT.UP) ? rc : -rc;
}
use of org.netxms.client.snmp.SnmpTrap in project netxms by netxms.
the class ExportFileBuilder method doExport.
/**
* Do export operation and call completion handler when done
*
* @param completionHandler
*/
private void doExport(final ExportCompletionHandler completionHandler) {
final long[] eventList = new long[events.size()];
int i = 0;
for (EventObject o : events.values()) eventList[i++] = o.getCode();
final long[] templateList = new long[templates.size()];
i = 0;
for (Template t : templates.values()) templateList[i++] = t.getObjectId();
final long[] trapList = new long[traps.size()];
i = 0;
for (SnmpTrap t : traps.values()) trapList[i++] = t.getId();
final UUID[] ruleList = new UUID[rules.size()];
i = 0;
for (EventProcessingPolicyRule r : rules.values()) ruleList[i++] = r.getGuid();
final long[] scriptList = new long[scripts.size()];
i = 0;
for (Script s : scripts.values()) scriptList[i++] = s.getId();
final long[] toolList = new long[tools.size()];
i = 0;
for (ObjectTool t : tools.values()) toolList[i++] = t.getId();
final long[] summaryTableList = new long[summaryTables.size()];
i = 0;
for (DciSummaryTableDescriptor t : summaryTables.values()) summaryTableList[i++] = t.getId();
final long[] actionList = new long[actions.size()];
i = 0;
for (ServerAction a : actions.values()) actionList[i++] = a.getId();
final String descriptionText = description.getText();
new ConsoleJob(Messages.get().ExportFileBuilder_ExportJobName, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final String xml = session.exportConfiguration(descriptionText, eventList, trapList, templateList, ruleList, scriptList, toolList, summaryTableList, actionList);
runInUIThread(new Runnable() {
@Override
public void run() {
completionHandler.exportCompleted(xml);
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().ExportFileBuilder_ExportJobError;
}
}.start();
}
use of org.netxms.client.snmp.SnmpTrap in project netxms by netxms.
the class ExportFileBuilder method addTraps.
/**
* Add traps to list
*/
private void addTraps() {
SelectSnmpTrapDialog dlg = new SelectSnmpTrapDialog(getSite().getShell(), snmpTrapCache);
if (dlg.open() == Window.OK) {
final Set<Long> eventCodes = new HashSet<Long>();
for (SnmpTrap t : dlg.getSelection()) {
traps.put(t.getId(), t);
if (t.getEventCode() >= 100000) {
eventCodes.add((long) t.getEventCode());
}
}
trapViewer.setInput(traps.values().toArray());
setModified();
if (eventCodes.size() > 0) {
for (EventObject o : session.findMultipleEventObjects(eventCodes.toArray(new Long[eventCodes.size()]))) {
events.put(o.getCode(), o);
}
eventViewer.setInput(events.values().toArray());
}
;
}
}
use of org.netxms.client.snmp.SnmpTrap in project netxms by netxms.
the class NXCSession method getSnmpTrapsConfigurationSummary.
/**
* Get summary of SNMP trap mapping. Trap configurations returned without parameter mapping.
*
* @return List of SnmpTrap objects
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public List<SnmpTrap> getSnmpTrapsConfigurationSummary() throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_TRAP_CFG_RO);
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_TRAPS);
List<SnmpTrap> list = new ArrayList<SnmpTrap>(count);
long varId = NXCPCodes.VID_TRAP_INFO_BASE;
for (int i = 0; i < count; i++) {
list.add(new SnmpTrap(response, varId));
varId += 10;
}
return list;
}
Aggregations