Search in sources :

Example 6 with NXCPMessage

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

the class NXCSession method setAttributeForCurrentUser.

/**
 * Set custom attribute for currently logged in user. Server will allow to change
 * only attributes whose name starts with dot.
 *
 * @param name Attribute's name
 * @param value New attribute's value
 * @throws IOException if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void setAttributeForCurrentUser(final String name, final String value) throws IOException, NXCException {
    NXCPMessage msg = newMessage(NXCPCodes.CMD_SET_CURRENT_USER_ATTR);
    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 7 with NXCPMessage

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

the class NXCSession method listMappingTables.

/**
 * Get list of all configured mapping tables.
 *
 * @return List of MappingTableDescriptor objects
 * @throws IOException if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public List<MappingTableDescriptor> listMappingTables() throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_LIST_MAPPING_TABLES);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_ELEMENTS);
    final List<MappingTableDescriptor> list = new ArrayList<MappingTableDescriptor>(count);
    long varId = NXCPCodes.VID_ELEMENT_LIST_BASE;
    for (int i = 0; i < count; i++) {
        list.add(new MappingTableDescriptor(response, varId));
        varId += 10;
    }
    return list;
}
Also used : MappingTableDescriptor(org.netxms.client.mt.MappingTableDescriptor) NXCPMessage(org.netxms.base.NXCPMessage) ArrayList(java.util.ArrayList) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint)

Example 8 with NXCPMessage

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

the class NXCSession method getServerVariables.

/**
 * Get server configuration variables
 *
 * @return The server variables
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public Map<String, ServerVariable> getServerVariables() throws IOException, NXCException {
    NXCPMessage request = newMessage(NXCPCodes.CMD_GET_CONFIG_VARLIST);
    sendMessage(request);
    final NXCPMessage response = waitForRCC(request.getMessageId());
    int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_VARIABLES);
    final HashMap<String, ServerVariable> varList = new HashMap<String, ServerVariable>(count);
    long id = NXCPCodes.VID_VARLIST_BASE;
    for (int i = 0; i < count; i++, id += 10) {
        ServerVariable v = new ServerVariable(response, id);
        varList.put(v.getName(), v);
    }
    count = response.getFieldAsInt32(NXCPCodes.VID_NUM_VALUES);
    for (int i = 0; i < count; i++) {
        ServerVariable var = varList.get(response.getFieldAsString(id++));
        if (var != null)
            var.addPossibleValue(response, id);
        id += 2;
    }
    return varList;
}
Also used : HashMap(java.util.HashMap) NXCPMessage(org.netxms.base.NXCPMessage) ServerVariable(org.netxms.client.server.ServerVariable) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint)

Example 9 with NXCPMessage

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

the class NXCSession method wakeupNode.

/**
 * Wakeup node by sending wake-on-LAN magic packet. Either node ID or
 * interface ID may be given. If node ID is given, system will send wakeup
 * packets to all active interfaces with IP address.
 *
 * @param objectId node or interface ID
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void wakeupNode(final long objectId) throws IOException, NXCException {
    NXCPMessage msg = newMessage(NXCPCodes.CMD_WAKEUP_NODE);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) objectId);
    sendMessage(msg);
    waitForRCC(msg.getMessageId());
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 10 with NXCPMessage

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

the class NXCSession method deleteAlarmCategory.

/**
 * Delete alarm category in DB
 * @param id of alarm category
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void deleteAlarmCategory(long id) throws IOException, NXCException {
    NXCPMessage msg = newMessage(NXCPCodes.CMD_DELETE_ALARM_CATEGORY);
    msg.setFieldInt32(NXCPCodes.VID_CATEGORY_ID, (int) id);
    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