Search in sources :

Example 1 with PerfTabDci

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();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Widget(org.eclipse.swt.widgets.Widget) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) DciData(org.netxms.client.datacollection.DciData) PerfTabDci(org.netxms.client.datacollection.PerfTabDci) Date(java.util.Date) PartInitException(org.eclipse.ui.PartInitException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 2 with PerfTabDci

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;
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint) PerfTabDci(org.netxms.client.datacollection.PerfTabDci)

Example 3 with PerfTabDci

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();
}
Also used : PerfTabDci(org.netxms.client.datacollection.PerfTabDci)

Example 4 with PerfTabDci

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();
}
Also used : MalformedURLException(java.net.MalformedURLException) IStatus(org.eclipse.core.runtime.IStatus) NXCSession(org.netxms.client.NXCSession) PerfTabGraph(org.netxms.ui.eclipse.perfview.objecttabs.internal.PerfTabGraph) AnimatedImage(org.netxms.ui.eclipse.widgets.AnimatedImage) URL(java.net.URL) PerfTabDci(org.netxms.client.datacollection.PerfTabDci) MalformedURLException(java.net.MalformedURLException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) GridData(org.eclipse.swt.layout.GridData) UIJob(org.eclipse.ui.progress.UIJob) Job(org.eclipse.core.runtime.jobs.Job) UIJob(org.eclipse.ui.progress.UIJob) Display(org.eclipse.swt.widgets.Display)

Aggregations

PerfTabDci (org.netxms.client.datacollection.PerfTabDci)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Date (java.util.Date)1 IStatus (org.eclipse.core.runtime.IStatus)1 Job (org.eclipse.core.runtime.jobs.Job)1 GridData (org.eclipse.swt.layout.GridData)1 Display (org.eclipse.swt.widgets.Display)1 Widget (org.eclipse.swt.widgets.Widget)1 PartInitException (org.eclipse.ui.PartInitException)1 UIJob (org.eclipse.ui.progress.UIJob)1 NXCPMessage (org.netxms.base.NXCPMessage)1 NXCSession (org.netxms.client.NXCSession)1 DciData (org.netxms.client.datacollection.DciData)1 AccessPoint (org.netxms.client.objects.AccessPoint)1 ConnectionPoint (org.netxms.client.topology.ConnectionPoint)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1 PerfTabGraph (org.netxms.ui.eclipse.perfview.objecttabs.internal.PerfTabGraph)1