Search in sources :

Example 46 with NXCPMessage

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

the class NXCSession method importConfiguration.

/**
 * Import server configuration (events, traps, thresholds) from XML
 *
 * @param config Configuration in XML format
 * @param flags  Import flags
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void importConfiguration(String config, int flags) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_IMPORT_CONFIGURATION);
    msg.setField(NXCPCodes.VID_NXMP_CONTENT, config);
    msg.setFieldInt32(NXCPCodes.VID_FLAGS, flags);
    sendMessage(msg);
    waitForRCC(msg.getMessageId());
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 47 with NXCPMessage

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

the class NXCSession method getPublicServerVariable.

/**
 * Get server public configuration variable
 *
 * @param name configuration variable name
 * @return value of requested configuration variable
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public String getPublicServerVariable(String name) throws IOException, NXCException {
    NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_PUBLIC_CONFIG_VAR);
    msg.setField(NXCPCodes.VID_NAME, name);
    sendMessage(msg);
    NXCPMessage response = waitForRCC(msg.getMessageId());
    return response.getFieldAsString(NXCPCodes.VID_VALUE);
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 48 with NXCPMessage

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

the class NXCSession method queryParameter.

/**
 * Query parameter immediately. This call will cause server to do actual call
 * to managed node and will return current value for given parameter. Result
 * is not cached.
 *
 * @param nodeId node object ID
 * @param origin parameter's origin (NetXMS agent, SNMP, etc.)
 * @param name   parameter's name
 * @return current parameter's value
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public String queryParameter(long nodeId, int origin, String name) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_QUERY_PARAMETER);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) nodeId);
    msg.setFieldInt16(NXCPCodes.VID_DCI_SOURCE_TYPE, origin);
    msg.setField(NXCPCodes.VID_NAME, name);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    return response.getFieldAsString(NXCPCodes.VID_VALUE);
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 49 with NXCPMessage

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

the class NXCSession method changeObjecToolDisableStatuss.

/**
 * Delete object tool.
 *
 * @param toolId Object tool ID
 * @param enable true if object tool should be enabled, false if disabled
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void changeObjecToolDisableStatuss(long toolId, boolean enable) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_CHANGE_OBJECT_TOOL_STATUS);
    msg.setFieldInt32(NXCPCodes.VID_TOOL_ID, (int) toolId);
    msg.setFieldInt32(NXCPCodes.VID_STATE, enable ? 1 : 0);
    sendMessage(msg);
    waitForRCC(msg.getMessageId());
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 50 with NXCPMessage

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

the class NXCSession method updateSnmpCommunities.

/**
 * Update list of well-known SNMP community strings on server. Existing list
 * will be replaced by given one.
 *
 * @param map New 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 void updateSnmpCommunities(final Map<Integer, List<String>> map) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_UPDATE_COMMUNITY_LIST);
    long stringBase = NXCPCodes.VID_COMMUNITY_STRING_LIST_BASE, zoneBase = NXCPCodes.VID_COMMUNITY_STRING_ZONE_LIST_BASE;
    for (Integer i : map.keySet()) {
        for (String s : map.get(i)) {
            msg.setField(stringBase++, s);
            msg.setFieldInt32(zoneBase++, i);
        }
    }
    msg.setFieldInt32(NXCPCodes.VID_NUM_STRINGS, (int) (stringBase - NXCPCodes.VID_COMMUNITY_STRING_LIST_BASE));
    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