Search in sources :

Example 11 with NXCPMessage

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

the class NXCSession method getAddressList.

/**
 * Get address list.
 *
 * @param listId list identifier (defined in NXCSession as ADDRESS_LIST_xxx)
 * @return address list
 * @throws IOException  if socket or file I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public List<InetAddressListElement> getAddressList(int listId) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_ADDR_LIST);
    msg.setFieldInt32(NXCPCodes.VID_ADDR_LIST_TYPE, listId);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_RECORDS);
    final List<InetAddressListElement> list = new ArrayList<InetAddressListElement>(count);
    long varId = NXCPCodes.VID_ADDR_LIST_BASE;
    for (int i = 0; i < count; i++) {
        list.add(new InetAddressListElement(response, varId));
        varId += 10;
    }
    return list;
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) ArrayList(java.util.ArrayList) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint)

Example 12 with NXCPMessage

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

the class NXCSession method pushDciData.

/**
 * Push data to server.
 *
 * @param data push data
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void pushDciData(DciPushData[] data) throws IOException, NXCException {
    NXCPMessage msg = newMessage(NXCPCodes.CMD_PUSH_DCI_DATA);
    msg.setFieldInt32(NXCPCodes.VID_NUM_ITEMS, data.length);
    long varId = NXCPCodes.VID_PUSH_DCI_DATA_BASE;
    for (DciPushData d : data) {
        msg.setFieldInt32(varId++, (int) d.nodeId);
        if (d.nodeId == 0)
            msg.setField(varId++, d.nodeName);
        msg.setFieldInt32(varId++, (int) d.dciId);
        if (d.dciId == 0)
            msg.setField(varId++, d.dciName);
        msg.setField(varId++, d.value);
    }
    sendMessage(msg);
    waitForRCC(msg.getMessageId());
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) DciPushData(org.netxms.client.datacollection.DciPushData)

Example 13 with NXCPMessage

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

the class NXCSession method testTransformationScript.

/**
 * Test DCI transformation script.
 *
 * @param nodeId     ID of the node object to test script on
 * @param script     script source code
 * @param inputValue input value for the script
 * @return test execution results
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public TransformationTestResult testTransformationScript(long nodeId, String script, String inputValue) throws IOException, NXCException {
    NXCPMessage msg = newMessage(NXCPCodes.CMD_TEST_DCI_TRANSFORMATION);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) nodeId);
    msg.setField(NXCPCodes.VID_SCRIPT, script);
    msg.setField(NXCPCodes.VID_VALUE, inputValue);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    TransformationTestResult r = new TransformationTestResult();
    r.success = response.getFieldAsBoolean(NXCPCodes.VID_EXECUTION_STATUS);
    r.result = response.getFieldAsString(NXCPCodes.VID_EXECUTION_RESULT);
    return r;
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) TransformationTestResult(org.netxms.client.datacollection.TransformationTestResult)

Example 14 with NXCPMessage

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

the class NXCSession method resetServerComponent.

/**
 * Reset server's internal component (defined by SERVER_COMPONENT_xxx)
 *
 * @param component component id
 * @throws IOException  if socket or file I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void resetServerComponent(int component) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_RESET_COMPONENT);
    msg.setFieldInt32(NXCPCodes.VID_COMPONENT_ID, component);
    sendMessage(msg);
    waitForRCC(msg.getMessageId());
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 15 with NXCPMessage

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

the class NXCSession method listReportResults.

/**
 * List report results
 *
 * @param reportId The report UUID
 * @return List of ReportResult objects
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public List<ReportResult> listReportResults(UUID reportId) throws NXCException, IOException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_RS_LIST_RESULTS);
    msg.setField(NXCPCodes.VID_REPORT_DEFINITION, reportId);
    sendMessage(msg);
    NXCPMessage response = waitForRCC(msg.getMessageId());
    List<ReportResult> results = new ArrayList<ReportResult>();
    int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_ITEMS);
    long base = NXCPCodes.VID_ROW_DATA_BASE;
    for (int i = 0; i < count; i++, base += 10) {
        ReportResult result = ReportResult.createFromMessage(response, base);
        results.add(result);
    }
    return results;
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) ArrayList(java.util.ArrayList) ReportResult(org.netxms.client.reporting.ReportResult) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint)

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