RSP_getKeys

Name

RSP_getKeys -- Retrieves all keys from a given host and module.

Synopsis

int RSP_getKeys(RSP_parseData *pd, char* szHost, char* szModule, char*** pszKeys);

Description

This function connects to a History Listener or MySQL database and collects all keys that have data associated with them for the given host and module. To be sure the host and module exist on the server, check that both exist within the lists returned by RSP_getHostsAndModules. The purpose of this function is to give users a list of keys to choose from when they want to view data. The parameter pd must have been created by a call to either RSP_newParseMySQL or RSP_newParseMySQL.

The remaining parameter pszKeys is a pointer to an array into which the function will place the key list. It is up to the user to free any data allocated to store these values. The following is an example of how to use this function:

RSP_parseData* pd;
char **keys;
int i = 0;

pd = RSP_newParseRemote("127.0.0.1", 3496, 10);

RSP_getKeys(pd, "plato", "CPUInfo", &keys);

printf("Keys on server for plato-CPUInfo:\n");
i = 0;
while(keys[i] != NULL)
{
	printf("%s\n", keys[i]);
	free(keys[i++]);
}
free(keys);
				

As you can see, the end of the array is specified with NULL. Make sure to free all non-NULL array entries as well as the array itself.

Returns

This function returns 0 if no error occurred, and -1 otherwise.

Error Conditions

If an error occurs with this function, -1 is returned and rsp_error is set appropriately. Possible error values are: