Search in sources :

Example 16 with NXCPMessage

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

the class NXCSession method renameAgentFile.

/**
 * Rename agent's file
 *
 * @param nodeId node id
 * @param oldName old file path
 * @param newFileName new file path
 * @param overwrite should the file in destination be overwritten
 * @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 renameAgentFile(long nodeId, String oldName, String newFileName, boolean overwrite) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_FILEMGR_RENAME_FILE);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) nodeId);
    msg.setField(NXCPCodes.VID_FILE_NAME, oldName);
    msg.setField(NXCPCodes.VID_NEW_FILE_NAME, newFileName);
    msg.setField(NXCPCodes.VID_OVERWRITE, overwrite);
    sendMessage(msg);
    waitForRCC(msg.getMessageId());
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 17 with NXCPMessage

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

the class NXCSession method getSnmpCommunities.

/**
 * Get list of well-known SNMP communities configured on server.
 *
 * @return map of SNMP community strings
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public Map<Integer, List<String>> getSnmpCommunities() throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_COMMUNITY_LIST);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_STRINGS);
    long stringBase = NXCPCodes.VID_COMMUNITY_STRING_LIST_BASE, zoneBase = NXCPCodes.VID_COMMUNITY_STRING_ZONE_LIST_BASE;
    Map<Integer, List<String>> map = new HashMap<Integer, List<String>>(count);
    List<String> stringList = new ArrayList<String>();
    int zoneId = 0;
    for (int i = 0; i < count; i++) {
        if (i != 0 && zoneId != response.getFieldAsInt32(zoneBase)) {
            map.put(zoneId, stringList);
            stringList = new ArrayList<String>();
        }
        stringList.add(response.getFieldAsString(stringBase++));
        zoneId = response.getFieldAsInt32(zoneBase++);
    }
    if (count > 0)
        map.put(zoneId, stringList);
    return map;
}
Also used : HashMap(java.util.HashMap) NXCPMessage(org.netxms.base.NXCPMessage) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint)

Example 18 with NXCPMessage

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

the class NXCSession method modifyObjectTool.

/**
 * Modify object tool.
 *
 * @param tool Object tool
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void modifyObjectTool(ObjectToolDetails tool) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_UPDATE_OBJECT_TOOL);
    tool.fillMessage(msg);
    sendMessage(msg);
    waitForRCC(msg.getMessageId());
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 19 with NXCPMessage

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

the class NXCSession method createAction.

/**
 * Create new server action.
 *
 * @param name action name
 * @return ID assigned to new action
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public long createAction(final String name) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_CREATE_ACTION);
    msg.setField(NXCPCodes.VID_ACTION_NAME, name);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    return response.getFieldAsInt64(NXCPCodes.VID_ACTION_ID);
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 20 with NXCPMessage

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

the class NXCSession method modifyRepository.

/**
 * Modify repository.
 *
 * @param r The repository
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void modifyRepository(Repository r) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_MODIFY_REPOSITORY);
    r.fillMessage(msg);
    sendMessage(msg);
    waitForRCC(msg.getMessageId());
}
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