Search in sources :

Example 96 with NXCPMessage

use of org.netxms.base.NXCPMessage in project netxms by netxms.

the class NXCSession method getLastValues.

/**
 * Get last DCI values for given node
 *
 * @param nodeId                ID of the node to get DCI values for
 * @param objectTooltipOnly     if set to true, only DCIs with DCF_SHOW_ON_OBJECT_TOOLTIP flag set are returned
 * @param overviewOnly          if set to true, only DCIs with DCF_SHOW_IN_OBJECT_OVERVIEW flag set are returned
 * @param includeNoValueObjects if set to true, objects with no value (like instance discovery DCIs) will be returned as well
 * @return List of DCI values
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public DciValue[] getLastValues(final long nodeId, boolean objectTooltipOnly, boolean overviewOnly, boolean includeNoValueObjects) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_LAST_VALUES);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) nodeId);
    msg.setField(NXCPCodes.VID_OBJECT_TOOLTIP_ONLY, objectTooltipOnly);
    msg.setField(NXCPCodes.VID_OVERVIEW_ONLY, overviewOnly);
    msg.setField(NXCPCodes.VID_INCLUDE_NOVALUE_OBJECTS, includeNoValueObjects);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_ITEMS);
    DciValue[] list = new DciValue[count];
    long base = NXCPCodes.VID_DCI_VALUES_BASE;
    for (int i = 0; i < count; i++, base += 50) {
        list[i] = DciValue.createFromMessage(nodeId, response, base);
    }
    return list;
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) DciValue(org.netxms.client.datacollection.DciValue) SimpleDciValue(org.netxms.client.datacollection.SimpleDciValue) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint)

Example 97 with NXCPMessage

use of org.netxms.base.NXCPMessage in project netxms by netxms.

the class NXCSession method syncObjects.

/**
 * Synchronizes NetXMS objects between server and client. After successful
 * sync, subscribe client to object change notifications.
 *
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public synchronized void syncObjects() throws IOException, NXCException {
    syncObjects.acquireUninterruptibly();
    NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_OBJECTS);
    msg.setFieldInt16(NXCPCodes.VID_SYNC_COMMENTS, 1);
    sendMessage(msg);
    waitForRCC(msg.getMessageId());
    waitForSync(syncObjects, commandTimeout * 10);
    objectsSynchronized = true;
    sendNotification(new SessionNotification(SessionNotification.OBJECT_SYNC_COMPLETED));
    subscribe(CHANNEL_OBJECTS);
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 98 with NXCPMessage

use of org.netxms.base.NXCPMessage in project netxms by netxms.

the class NXCSession method terminateAlarm.

/**
 * Terminate alarm by helpdesk reference.
 *
 * @param helpdeskReference  Identifier of alarm to be resolved.
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void terminateAlarm(final String helpdeskReference) throws IOException, NXCException {
    NXCPMessage msg = newMessage(NXCPCodes.CMD_TERMINATE_ALARM);
    msg.setField(NXCPCodes.VID_HELPDESK_REF, helpdeskReference);
    sendMessage(msg);
    waitForRCC(msg.getMessageId());
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 99 with NXCPMessage

use of org.netxms.base.NXCPMessage in project netxms by netxms.

the class NXCSession method bindAgentTunnel.

/**
 * Bind agent tunnel to node
 *
 * @param tunnelId tunnel ID
 * @param nodeId node ID
 * @throws IOException if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void bindAgentTunnel(int tunnelId, long nodeId) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_BIND_AGENT_TUNNEL);
    msg.setFieldInt32(NXCPCodes.VID_TUNNEL_ID, tunnelId);
    msg.setFieldInt32(NXCPCodes.VID_NODE_ID, (int) nodeId);
    sendMessage(msg);
    waitForRCC(msg.getMessageId());
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 100 with NXCPMessage

use of org.netxms.base.NXCPMessage in project netxms by netxms.

the class NXCSession method modifyScript.

/**
 * Modify script. If scriptId is 0, new script will be created in library.
 *
 * @param scriptId script ID
 * @param name script name
 * @param source script source code
 * @return script ID (newly assigned if new script was created)
 * @throws IOException if socket or file I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public long modifyScript(long scriptId, String name, String source) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_UPDATE_SCRIPT);
    msg.setFieldInt32(NXCPCodes.VID_SCRIPT_ID, (int) scriptId);
    msg.setField(NXCPCodes.VID_NAME, name);
    msg.setField(NXCPCodes.VID_SCRIPT_CODE, source);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    return response.getFieldAsInt64(NXCPCodes.VID_SCRIPT_ID);
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Aggregations

NXCPMessage (org.netxms.base.NXCPMessage)274 ConnectionPoint (org.netxms.client.topology.ConnectionPoint)69 AccessPoint (org.netxms.client.objects.AccessPoint)66 ArrayList (java.util.ArrayList)44 IOException (java.io.IOException)8 HashMap (java.util.HashMap)7 DciSummaryTable (org.netxms.client.datacollection.DciSummaryTable)7 MappingTable (org.netxms.client.mt.MappingTable)7 NXCPException (org.netxms.base.NXCPException)5 UnknownHostException (java.net.UnknownHostException)3 GeneralSecurityException (java.security.GeneralSecurityException)3 CertificateEncodingException (java.security.cert.CertificateEncodingException)3 UUID (java.util.UUID)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 MessageProcessingResult (com.radensolutions.reporting.service.MessageProcessingResult)2 FileInputStream (java.io.FileInputStream)2 Socket (java.net.Socket)2 SignatureException (java.security.SignatureException)2 Date (java.util.Date)2 List (java.util.List)2