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());
}
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);
}
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);
}
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());
}
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());
}
Aggregations