use of org.netxms.client.events.Alarm in project netxms by netxms.
the class AlarmDetails method refresh.
/**
* Refresh view
*/
private void refresh() {
new ConsoleJob(Messages.get().AlarmDetails_RefreshJobTitle, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final Alarm alarm = session.getAlarm(alarmId);
final List<AlarmComment> comments = session.getAlarmComments(alarmId);
List<EventInfo> _events = null;
try {
_events = session.getAlarmEvents(alarmId);
} catch (NXCException e) {
if (e.getErrorCode() != RCC.ACCESS_DENIED)
throw e;
}
final List<EventInfo> events = _events;
runInUIThread(new Runnable() {
@Override
public void run() {
updateAlarmDetails(alarm);
for (AlarmCommentsEditor e : editors.values()) e.dispose();
for (AlarmComment n : comments) editors.put(n.getId(), createEditor(n));
if (lastValuesWidget == null) {
AbstractObject object = session.findObjectById(alarm.getSourceObjectId());
if (object != null) {
// $NON-NLS-1$
lastValuesWidget = new LastValuesWidget(AlarmDetails.this, dataArea, SWT.BORDER, object, "AlarmDetails.LastValues", null);
lastValuesWidget.refresh();
}
}
if (events != null) {
eventViewer.setInput(events);
eventViewer.expandAll();
if (labelAccessDenied != null) {
labelAccessDenied.dispose();
labelAccessDenied = null;
}
} else if (labelAccessDenied == null) {
labelAccessDenied = new CLabel(eventViewer.getControl().getParent(), SWT.NONE);
toolkit.adapt(labelAccessDenied);
labelAccessDenied.setImage(StatusDisplayInfo.getStatusImage(Severity.CRITICAL));
labelAccessDenied.setText(Messages.get().AlarmDetails_RelatedEvents_AccessDenied);
labelAccessDenied.moveAbove(null);
labelAccessDenied.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
}
updateLayout();
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().AlarmDetails_RefreshJobError;
}
}.start();
}
use of org.netxms.client.events.Alarm in project netxms by netxms.
the class GrafanaAlarms method getCollection.
/* (non-Javadoc)
* @see org.netxms.websvc.handlers.AbstractHandler#getCollection(java.util.Map)
*/
@Override
public Object getCollection(Map<String, String> query) throws Exception {
if (!getSession().isObjectsSynchronized())
getSession().syncObjects();
if (query.isEmpty()) {
Set<Integer> classFilter = new HashSet<Integer>(5);
classFilter.add(AbstractObject.OBJECT_NODE);
classFilter.add(AbstractObject.OBJECT_MOBILEDEVICE);
classFilter.add(AbstractObject.OBJECT_RACK);
classFilter.add(AbstractObject.OBJECT_CLUSTER);
classFilter.add(AbstractObject.OBJECT_SENSOR);
AbstractObject[] objects = getSession().getTopLevelObjects(classFilter);
Map<Long, String> result = new HashMap<Long, String>();
for (AbstractObject o : objects) result.put(o.getObjectId(), o.getObjectName());
return result;
}
JsonObject root = new JsonObject();
JsonArray columns = new JsonArray();
columns.add(createColumn("Severity", true, true));
columns.add(createColumn("State", true, false));
columns.add(createColumn("Source", true, false));
columns.add(createColumn("Message", true, false));
columns.add(createColumn("Count", true, false));
columns.add(createColumn("Helpdesk ID", true, false));
columns.add(createColumn("Ack/Resolved By", true, false));
columns.add(createColumn("Created", true, false));
columns.add(createColumn("Last Change", true, false));
root.add("columns", columns);
JsonArray rows = new JsonArray();
JsonArray r = new JsonArray();
DateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
AbstractObject object = null;
AbstractUserObject user = null;
JsonParser parser = new JsonParser();
JsonElement element = parser.parse(query.get("targets"));
if (!element.isJsonArray())
return new JsonArray();
JsonArray targets = element.getAsJsonArray();
JsonObject alarmSource;
long sourceId = 0;
Map<Long, Alarm> alarms = getSession().getAlarms();
for (JsonElement e : targets) {
for (Alarm a : alarms.values()) {
if (e.getAsJsonObject().has("alarmSource")) {
alarmSource = e.getAsJsonObject().getAsJsonObject("alarmSource");
if (alarmSource.size() > 0)
sourceId = Long.parseLong(alarmSource.get("id").getAsString());
}
if (sourceId == 0 || a.getSourceObjectId() == sourceId) {
r.add(a.getCurrentSeverity().name());
r.add(STATES[a.getState()]);
object = getSession().findObjectById(a.getSourceObjectId());
if (object == null)
r.add(a.getSourceObjectId());
else
r.add(object.getObjectName());
r.add(a.getMessage());
r.add(a.getRepeatCount());
r.add(a.getHelpdeskReference());
user = getSession().findUserDBObjectById(a.getAckByUser());
if (user == null)
r.add("");
else
r.add(user.getName());
r.add(df.format(a.getCreationTime()));
r.add(df.format(a.getLastChangeTime()));
rows.add(r);
r = new JsonArray();
}
}
}
root.add("rows", rows);
root.addProperty("type", "table");
JsonArray wrapper = new JsonArray();
wrapper.add(root);
return wrapper;
}
use of org.netxms.client.events.Alarm in project netxms by netxms.
the class AlarmList method terminateAlarms.
/**
* Terminate selected alarms
*/
private void terminateAlarms() {
IStructuredSelection selection = (IStructuredSelection) alarmViewer.getSelection();
if (selection.isEmpty())
return;
final List<Long> alarmIds = new ArrayList<Long>(selection.size());
for (Object o : selection.toList()) alarmIds.add(((Alarm) o).getId());
new ConsoleJob(Messages.get().TerminateAlarm_JobTitle, viewPart, Activator.PLUGIN_ID, AlarmList.JOB_FAMILY) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final Map<Long, Integer> terminationFails = session.bulkTerminateAlarms(alarmIds);
if (!terminationFails.isEmpty()) {
runInUIThread(new Runnable() {
@Override
public void run() {
AlarmStateChangeFailureDialog dlg = new AlarmStateChangeFailureDialog(viewPart.getSite().getShell(), terminationFails);
if (dlg.open() == Window.OK) {
return;
}
}
});
}
}
@Override
protected String getErrorMessage() {
return Messages.get().TerminateAlarm_ErrorMessage;
}
}.start();
}
use of org.netxms.client.events.Alarm in project netxms by netxms.
the class AlarmList method acknowledgeAlarms.
/**
* Acknowledge selected alarms
*
* @param sticky
*/
private void acknowledgeAlarms(final boolean sticky, final int time) {
IStructuredSelection selection = (IStructuredSelection) alarmViewer.getSelection();
if (selection.size() == 0)
return;
final Object[] alarms = selection.toArray();
new ConsoleJob(Messages.get().AcknowledgeAlarm_JobName, viewPart, Activator.PLUGIN_ID, AlarmList.JOB_FAMILY) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
monitor.beginTask(Messages.get(getDisplay()).AcknowledgeAlarm_TaskName, alarms.length);
for (Object o : alarms) {
if (monitor.isCanceled())
break;
if (o instanceof Alarm)
session.acknowledgeAlarm(((Alarm) o).getId(), sticky, time);
monitor.worked(1);
}
monitor.done();
}
@Override
protected String getErrorMessage() {
return Messages.get().AcknowledgeAlarm_ErrorMessage;
}
}.start();
}
use of org.netxms.client.events.Alarm in project netxms by netxms.
the class AlarmList method showIssue.
/**
* Show in web browser helpdesk ticket (issue) linked to selected alarm
*/
private void showIssue() {
IStructuredSelection selection = (IStructuredSelection) alarmViewer.getSelection();
if (selection.size() != 1)
return;
final long id = ((Alarm) selection.getFirstElement()).getId();
new ConsoleJob(Messages.get().AlarmList_JobTitle_ShowTicket, viewPart, Activator.PLUGIN_ID, AlarmList.JOB_FAMILY) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final String url = session.getHelpdeskIssueUrl(id);
runInUIThread(new Runnable() {
@Override
public void run() {
UrlLauncher launcher = RWT.getClient().getService(UrlLauncher.class);
launcher.openURL(url);
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().AlarmList_JobError_ShowTicket;
}
}.start();
}
Aggregations