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