Search in sources :

Example 1 with NXCPMessage

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

the class NXCSession method getSupportedTables.

/**
 * Get list of tables supported by agent running on given node.
 *
 * @param nodeId Node ID
 * @return List of tables supported by agent
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public List<AgentTable> getSupportedTables(long nodeId) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_PARAMETER_LIST);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) nodeId);
    // Indicates request for table list
    msg.setFieldInt16(NXCPCodes.VID_FLAGS, 0x02);
    msg.setFieldInt16(NXCPCodes.VID_DCI_SOURCE_TYPE, DataCollectionObject.AGENT);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_TABLES);
    List<AgentTable> list = new ArrayList<AgentTable>(count);
    long baseId = NXCPCodes.VID_TABLE_LIST_BASE;
    for (int i = 0; i < count; i++) {
        list.add(new AgentTable(response, baseId));
        baseId += response.getFieldAsInt64(baseId);
    }
    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 2 with NXCPMessage

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

the class NXCSession method deleteImage.

/**
 * Delete an image
 *
 * @param image The image to delete
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void deleteImage(LibraryImage image) throws IOException, NXCException {
    if (image.isProtected()) {
        throw new NXCException(RCC.INVALID_REQUEST);
    }
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_DELETE_IMAGE);
    image.fillMessage(msg);
    sendMessage(msg);
    waitForRCC(msg.getMessageId());
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 3 with NXCPMessage

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

the class NXCSession method findConnectionPoint.

/**
 * Find connection point (either directly connected or most close known
 * interface on a switch) for given MAC address. Will return null if
 * connection point information cannot be found.
 *
 * @param macAddr MAC address
 * @return connection point information or null
 * @throws IOException  if socket or file I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public ConnectionPoint findConnectionPoint(MacAddress macAddr) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_FIND_MAC_LOCATION);
    msg.setField(NXCPCodes.VID_MAC_ADDR, macAddr.getValue());
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    return response.isFieldPresent(NXCPCodes.VID_CONNECTION_TYPE) ? new ConnectionPoint(response) : null;
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) ConnectionPoint(org.netxms.client.topology.ConnectionPoint)

Example 4 with NXCPMessage

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

the class NXCSession method createSnmpTrapConfiguration.

/**
 * Create new trap configuration record.
 *
 * @return ID of new record
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public long createSnmpTrapConfiguration() throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_CREATE_TRAP);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    return response.getFieldAsInt64(NXCPCodes.VID_TRAP_ID);
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 5 with NXCPMessage

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

the class NXCSession method findConnectionPoint.

/**
 * Find connection point (either directly connected or most close known
 * interface on a switch) for given node or interface object. Will return
 * null if connection point information cannot be found.
 *
 * @param objectId Node or interface object ID
 * @return connection point information or null
 * @throws IOException  if socket or file I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public ConnectionPoint findConnectionPoint(long objectId) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_FIND_NODE_CONNECTION);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) objectId);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    return response.isFieldPresent(NXCPCodes.VID_CONNECTION_TYPE) ? new ConnectionPoint(response) : null;
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) ConnectionPoint(org.netxms.client.topology.ConnectionPoint)

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