Search in sources :

Example 1 with ThresholdViolationSummary

use of org.netxms.client.datacollection.ThresholdViolationSummary in project netxms by netxms.

the class NXCSession method getThresholdSummary.

/**
 * Get threshold violation summary for all nodes under given parent object. Parent object could
 * be container, subnet, zone, entire network, or infrastructure service root.
 *
 * @param objectId parent object ID
 * @return list of threshold violation summary objects for all nodes below given root
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public List<ThresholdViolationSummary> getThresholdSummary(final long objectId) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_THRESHOLD_SUMMARY);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) objectId);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    List<ThresholdViolationSummary> list = new ArrayList<ThresholdViolationSummary>();
    long varId = NXCPCodes.VID_THRESHOLD_BASE;
    while (response.getFieldAsInt64(varId) != 0) {
        final ThresholdViolationSummary t = new ThresholdViolationSummary(response, varId);
        list.add(t);
        varId += 50 * t.getDciList().size() + 2;
    }
    return list;
}
Also used : ThresholdViolationSummary(org.netxms.client.datacollection.ThresholdViolationSummary) NXCPMessage(org.netxms.base.NXCPMessage) ArrayList(java.util.ArrayList)

Example 2 with ThresholdViolationSummary

use of org.netxms.client.datacollection.ThresholdViolationSummary in project netxms by netxms.

the class DataCollectionTest method testGetThresholdSummary.

public void testGetThresholdSummary() throws Exception {
    final NXCSession session = connect();
    session.syncObjects();
    final List<ThresholdViolationSummary> list = session.getThresholdSummary(1);
    for (ThresholdViolationSummary s : list) {
        DataCollectionTarget target = (DataCollectionTarget) session.findObjectById(s.getNodeId(), DataCollectionTarget.class);
        System.out.println("* " + target.getObjectName());
        if (s.getDciList().size() > 0) {
            for (DciValue v : s.getDciList()) {
                System.out.println("   + " + v.getDescription());
            }
        } else {
            System.out.println("   --- no threshold violations");
        }
    }
    session.disconnect();
}
Also used : ThresholdViolationSummary(org.netxms.client.datacollection.ThresholdViolationSummary) DataCollectionTarget(org.netxms.client.objects.DataCollectionTarget) DciValue(org.netxms.client.datacollection.DciValue)

Example 3 with ThresholdViolationSummary

use of org.netxms.client.datacollection.ThresholdViolationSummary in project netxms by netxms.

the class ThresholdSummaryWidget method refresh.

/**
 * Refresh widget
 */
public void refresh() {
    if (visibilityValidator != null && !visibilityValidator.isVisible())
        return;
    if (object == null) {
        viewer.setInput(new ArrayList<ThresholdViolationSummary>(0));
        return;
    }
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    final long rootId = object.getObjectId();
    ConsoleJob job = new ConsoleJob(Messages.get().ThresholdSummaryWidget_JobTitle, viewPart, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final List<ThresholdViolationSummary> data = session.getThresholdSummary(rootId);
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    if (isDisposed() || (object == null) || (rootId != object.getObjectId()))
                        return;
                    viewer.setInput(data);
                    viewer.expandAll();
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().ThresholdSummaryWidget_JobError;
        }
    };
    job.setUser(false);
    job.start();
}
Also used : ThresholdViolationSummary(org.netxms.client.datacollection.ThresholdViolationSummary) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Aggregations

ThresholdViolationSummary (org.netxms.client.datacollection.ThresholdViolationSummary)3 ArrayList (java.util.ArrayList)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NXCPMessage (org.netxms.base.NXCPMessage)1 NXCSession (org.netxms.client.NXCSession)1 DciValue (org.netxms.client.datacollection.DciValue)1 DataCollectionTarget (org.netxms.client.objects.DataCollectionTarget)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1