Search in sources :

Example 1 with DataCollectionTarget

use of org.netxms.client.objects.DataCollectionTarget in project netxms by netxms.

the class LastValues method init.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.ViewPart#init(org.eclipse.ui.IViewSite)
	 */
@Override
public void init(IViewSite site) throws PartInitException {
    super.init(site);
    settings = Activator.getDefault().getDialogSettings();
    initShowFilter = safeCast(settings.get("LastValuesView"), settings.getBoolean("LastValuesView"), initShowFilter);
    session = (NXCSession) ConsoleSharedData.getSession();
    AbstractObject obj = session.findObjectById(Long.parseLong(site.getSecondaryId()));
    dcTarget = ((obj != null) && (obj instanceof DataCollectionTarget)) ? (DataCollectionTarget) obj : null;
    setPartName(Messages.get().LastValues_PartNamePrefix + ((dcTarget != null) ? dcTarget.getObjectName() : Messages.get().LastValues_Error));
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) DataCollectionTarget(org.netxms.client.objects.DataCollectionTarget)

Example 2 with DataCollectionTarget

use of org.netxms.client.objects.DataCollectionTarget in project netxms by netxms.

the class LastValues method createClientArea.

/* (non-Javadoc)
    * @see org.netxms.ui.eclipse.objectview.objecttabs.elements.OverviewPageElement#createClientArea(org.eclipse.swt.widgets.Composite)
    */
@Override
protected Control createClientArea(Composite parent) {
    viewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.HIDE_SELECTION | SWT.H_SCROLL | SWT.MULTI);
    setupTable();
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new OverviewDciLabelProvider());
    viewer.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            return ((DciValue) e1).getDescription().compareToIgnoreCase(((DciValue) e2).getDescription());
        }
    });
    viewer.setInput(((DataCollectionTarget) getObject()).getOverviewDciData().toArray());
    viewer.getTable().getColumn(0).pack();
    viewer.getTable().getColumn(1).pack();
    createPopupMenu();
    refreshController.setInterval(30);
    refresh();
    return viewer.getTable();
}
Also used : OverviewDciLabelProvider(org.netxms.ui.eclipse.objectview.objecttabs.helpers.OverviewDciLabelProvider) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) DataCollectionTarget(org.netxms.client.objects.DataCollectionTarget) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) DciValue(org.netxms.client.datacollection.DciValue) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) AbstractObject(org.netxms.client.objects.AbstractObject) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 3 with DataCollectionTarget

use of org.netxms.client.objects.DataCollectionTarget 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 4 with DataCollectionTarget

use of org.netxms.client.objects.DataCollectionTarget in project netxms by netxms.

the class HistoricalData method get.

/* (non-Javadoc)
    * @see org.netxms.websvc.handlers.AbstractHandler#get(java.lang.String)
    */
@Override
protected Object get(String id, Map<String, String> query) throws Exception {
    NXCSession session = getSession();
    AbstractObject obj = getObject();
    long dciId = 0;
    try {
        dciId = Long.parseLong(id);
    } catch (NumberFormatException e) {
        dciId = session.dciNameToId(obj.getObjectId(), id);
    }
    if (obj == null || dciId == 0 || !(obj instanceof DataCollectionTarget))
        throw new NXCException(RCC.INVALID_OBJECT_ID);
    String timeFrom = query.get("from");
    String timeTo = query.get("to");
    String timeInteval = query.get("timeInterval");
    String itemCount = query.get("itemCount");
    DciData data = null;
    if (timeFrom != null || timeTo != null) {
        data = session.getCollectedData(obj.getObjectId(), dciId, new Date(parseLong(timeFrom, 0) * 1000), new Date(parseLong(timeTo, System.currentTimeMillis() / 1000) * 1000), parseInt(itemCount, 0), false);
    } else if (timeInteval != null) {
        Date now = new Date();
        long from = now.getTime() - parseLong(timeInteval, 0) * 1000;
        data = session.getCollectedData(obj.getObjectId(), dciId, new Date(from), new Date(), parseInt(itemCount, 0), false);
    } else if (itemCount != null) {
        data = session.getCollectedData(obj.getObjectId(), dciId, null, null, parseInt(itemCount, 0), false);
    } else {
        Date now = new Date();
        // one hour
        long from = now.getTime() - 3600000;
        data = session.getCollectedData(obj.getObjectId(), dciId, new Date(from), now, parseInt(itemCount, 0), false);
    }
    return new ResponseContainer("values", data);
}
Also used : NXCSession(org.netxms.client.NXCSession) AbstractObject(org.netxms.client.objects.AbstractObject) DataCollectionTarget(org.netxms.client.objects.DataCollectionTarget) DciData(org.netxms.client.datacollection.DciData) ResponseContainer(org.netxms.websvc.json.ResponseContainer) NXCException(org.netxms.client.NXCException) Date(java.util.Date)

Example 5 with DataCollectionTarget

use of org.netxms.client.objects.DataCollectionTarget in project netxms by netxms.

the class DataCollectionEditor method init.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.ViewPart#init(org.eclipse.ui.IViewSite)
	 */
@Override
public void init(IViewSite site) throws PartInitException {
    super.init(site);
    session = (NXCSession) ConsoleSharedData.getSession();
    AbstractObject obj = session.findObjectById(Long.parseLong(site.getSecondaryId()));
    settings = Activator.getDefault().getDialogSettings();
    object = ((obj != null) && ((obj instanceof DataCollectionTarget) || (obj instanceof Template))) ? obj : null;
    setPartName(Messages.get().DataCollectionEditor_PartNamePrefix + ((object != null) ? object.getObjectName() : Messages.get().DataCollectionEditor_Error));
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) DataCollectionTarget(org.netxms.client.objects.DataCollectionTarget) Template(org.netxms.client.objects.Template)

Aggregations

DataCollectionTarget (org.netxms.client.objects.DataCollectionTarget)6 AbstractObject (org.netxms.client.objects.AbstractObject)4 DciValue (org.netxms.client.datacollection.DciValue)3 Date (java.util.Date)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)1 CLabel (org.eclipse.swt.custom.CLabel)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 NXCException (org.netxms.client.NXCException)1 NXCSession (org.netxms.client.NXCSession)1 DciData (org.netxms.client.datacollection.DciData)1 ThresholdViolationSummary (org.netxms.client.datacollection.ThresholdViolationSummary)1 AbstractNode (org.netxms.client.objects.AbstractNode)1 Template (org.netxms.client.objects.Template)1 OverviewDciLabelProvider (org.netxms.ui.eclipse.objectview.objecttabs.helpers.OverviewDciLabelProvider)1 ResponseContainer (org.netxms.websvc.json.ResponseContainer)1