The following example reports statistics for the designated pool.
The key points for the example include the following:
pool_query_pool_resources() gets a list of all resources in rl. Because the last argument to pool_query_pool_resources() is NULL, all resources are returned. For each resource, the name, load and size properties are read, and printed.
The call to strdup() allocates local memory and copies the string returned by get_string(). The call to get_string() returns a pointer that is freed by the next call to get_property(). If the call to strdup() is not included, subsequent references to the string(s) could cause the application to fail with a segmentation fault.
printf("pool %s\n:" pool_name); pool = pool_get_pool(conf, pool_name); rl = pool_query_pool_resources(conf, pool, &nelem, NULL); for (i = 0; i < nelem; i++) { pool_get_property(conf, pool_resource_to_elem(conf, rl[i]), "type", pval); pool_value_get_string(pval, &type); type = strdup(type); snprintf(prop_name, 32, "%s.%s", type, "name"); pool_get_property(conf, pool_resource_to_elem(conf, rl[i]), prop_name, pval); pool_value_get_string(val, &res_name); res_name = strdup(res_name); snprintf(prop_name, 32, "%s.%s", type, "load"); pool_get_property(conf, pool_resource_to_elem(conf, rl[i]), prop_name, pval); pool_value_get_uint64(val, &load); snprintf(prop_name, 32, "%s.%s", type, "size"); pool_get_property(conf, pool_resource_to_elem(conf, rl[i]), prop_name, pval); pool_value_get_uint64(val, &size); printf("resource %s: size %llu load %llu\n", res_name, size, load); free(type); free(res_name); } free(rl);