Search in sources :

Example 61 with NXCPMessage

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

the class NXCSession method getDataCollectionScripts.

/**
 * Get names of all scripts used in data collection by given node, cluster, or template object.
 *
 * @param objectId node, cluster, or template object ID
 * @return list of used library scripts
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public List<Script> getDataCollectionScripts(long objectId) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_DCI_SCRIPT_LIST);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) objectId);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_SCRIPTS);
    List<Script> scripts = new ArrayList<Script>(count);
    long fieldId = NXCPCodes.VID_SCRIPT_LIST_BASE;
    for (int i = 0; i < count; i++) {
        long id = response.getFieldAsInt64(fieldId++);
        String name = response.getFieldAsString(fieldId++);
        scripts.add(new Script(id, name, null));
    }
    return scripts;
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) ArrayList(java.util.ArrayList) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint)

Example 62 with NXCPMessage

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

the class NXCSession method setServerConfigClob.

/**
 * Set server config CLOB
 *
 * @param name The name to set
 * @param value The value to set
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void setServerConfigClob(final String name, final String value) throws IOException, NXCException {
    NXCPMessage msg = newMessage(NXCPCodes.CMD_CONFIG_SET_CLOB);
    msg.setField(NXCPCodes.VID_NAME, name);
    msg.setField(NXCPCodes.VID_VALUE, value);
    sendMessage(msg);
    waitForRCC(msg.getMessageId());
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 63 with NXCPMessage

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

the class NXCSession method saveAgentConfig.

/**
 * Saves or creates new agent's config
 *
 * @param conf contents of config
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void saveAgentConfig(ConfigContent conf) throws NXCException, IOException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_SAVE_AGENT_CONFIG);
    conf.fillMessage(msg);
    sendMessage(msg);
    waitForRCC(msg.getMessageId());
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 64 with NXCPMessage

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

the class NXCSession method getPersistentStorageList.

/**
 * Get list of all values in persistent storage
 *
 * @return Hash map wit persistent storage key, value
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public HashMap<String, String> getPersistentStorageList() throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_PERSISTENT_STORAGE);
    sendMessage(msg);
    NXCPMessage response = waitForRCC(msg.getMessageId());
    int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_PSTORAGE);
    HashMap<String, String> map = new HashMap<String, String>();
    long base = NXCPCodes.VID_PSTORAGE_LIST_BASE;
    for (int i = 0; i < count; i++) {
        map.put(response.getFieldAsString(base++), response.getFieldAsString(base++));
    }
    return map;
}
Also used : HashMap(java.util.HashMap) NXCPMessage(org.netxms.base.NXCPMessage) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint)

Example 65 with NXCPMessage

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

the class NXCSession method getSubnetAddressMap.

/**
 * Get address map for subnet. Returned array contains one entry for each IP address
 * in a subnet. Element value could be eithet ID of the node with that IP address,
 * 0 for unused addresses, and 0xFFFFFFFF for subnet and broadcast addresses.
 *
 * @param subnetId The subnet ID
 * @return Address map
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public long[] getSubnetAddressMap(long subnetId) throws NXCException, IOException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_SUBNET_ADDRESS_MAP);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) subnetId);
    sendMessage(msg);
    NXCPMessage response = waitForRCC(msg.getMessageId());
    return response.getFieldAsUInt32Array(NXCPCodes.VID_ADDRESS_MAP);
}
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