use of org.netxms.client.datacollection.PerfTabDci in project netxms by netxms.
the class PerfTabGraph method refreshData.
/**
* Refresh graph's data
*/
public void refreshData() {
if (updateInProgress)
return;
updateInProgress = true;
chart.clearErrors();
ConsoleJob job = new ConsoleJob(Messages.get().PerfTabGraph_JobTitle, null, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {
private PerfTabDci currentDci;
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final Date from = new Date(System.currentTimeMillis() - timeInterval);
final Date to = new Date(System.currentTimeMillis());
synchronized (items) {
final DciData[] data = new DciData[items.size()];
for (int i = 0; i < data.length; i++) {
currentDci = items.get(i);
data[i] = session.getCollectedData(nodeId, currentDci.getId(), from, to, 0, false);
}
runInUIThread(new Runnable() {
@Override
public void run() {
if (!((Widget) chart).isDisposed()) {
chart.setTimeRange(from, to);
for (int i = 0; i < data.length; i++) chart.updateParameter(i, data[i], true);
}
updateInProgress = false;
}
});
}
}
@Override
protected String getErrorMessage() {
return String.format(Messages.get().PerfTabGraph_JobError, currentDci.getId(), currentDci.getDescription());
}
@Override
protected void jobFailureHandler() {
updateInProgress = false;
super.jobFailureHandler();
}
@Override
protected IStatus createFailureStatus(Exception e) {
runInUIThread(new Runnable() {
@Override
public void run() {
if (!((Widget) chart).isDisposed())
chart.addError(getErrorMessage());
}
});
return Status.OK_STATUS;
}
};
job.setUser(false);
job.start();
}
use of org.netxms.client.datacollection.PerfTabDci in project netxms by netxms.
the class NXCSession method getPerfTabItems.
/**
* Get list of DCIs configured to be shown on performance tab in console for
* given node.
*
* @param nodeId Node object ID
* @return List of performance tab DCIs
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public PerfTabDci[] getPerfTabItems(final long nodeId) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_PERFTAB_DCI_LIST);
msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) nodeId);
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_ITEMS);
PerfTabDci[] list = new PerfTabDci[count];
long base = NXCPCodes.VID_SYSDCI_LIST_BASE;
for (int i = 0; i < count; i++, base += 10) {
list[i] = new PerfTabDci(response, base);
}
return list;
}
use of org.netxms.client.datacollection.PerfTabDci in project netxms by netxms.
the class DataCollectionTest method testGetPerfTabItems.
public void testGetPerfTabItems() throws Exception {
final NXCSession session = connect();
PerfTabDci[] list = session.getPerfTabItems(TestConstants.NODE_ID);
assertNotNull(list);
assertTrue(list.length > 0);
for (PerfTabDci p : list) {
System.out.println("id=" + p.getId() + " descr='" + p.getDescription() + "' settings='" + p.getPerfTabSettings() + "'");
}
session.disconnect();
}
use of org.netxms.client.datacollection.PerfTabDci in project netxms by netxms.
the class PerformanceTab method objectChanged.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab#objectChanged(org.netxms.client.objects.AbstractObject)
*/
@Override
public void objectChanged(final AbstractObject object) {
for (PerfTabGraph chart : charts.values()) chart.dispose();
charts.clear();
if (object == null)
return;
if (waitingImage != null)
waitingImage.dispose();
waitingImage = new AnimatedImage(chartArea, SWT.NONE);
waitingImage.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true, 2, 1));
try {
// $NON-NLS-1$
waitingImage.setImage(new URL("platform:/plugin/org.netxms.webui.core/icons/progress.gif"));
} catch (MalformedURLException e) {
}
updateChartAreaLayout();
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
Job job = new Job(Messages.get().PerformanceTab_JobName) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
final PerfTabDci[] items = session.getPerfTabItems(object.getObjectId());
final Display display = PerformanceTab.this.getClientArea().getDisplay();
new UIJob(display, Messages.get(display).PerformanceTab_JobName) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
if (!getClientArea().isDisposed() && (PerformanceTab.this.getObject() != null) && (PerformanceTab.this.getObject().getObjectId() == object.getObjectId())) {
update(items);
}
return Status.OK_STATUS;
}
}.schedule();
} catch (Exception e) {
// $NON-NLS-1$
Activator.logError("Exception in performance tab loading job", e);
}
return Status.OK_STATUS;
}
};
job.setSystem(true);
job.schedule();
}
Aggregations