- if (strcasecmp ("Address", child->key) == 0) {
- if ((child->values_num != 1) || (child->values[0].type != OCONFIG_TYPE_STRING)){
- WARNING ("pinba plugin: `Address' needs exactly one string argument.");
- return (-1);
- }
- config_set(&pinba_address, child->values[0].value.string);
- } else if (strcasecmp ("Port", child->key) == 0) {
- if ((child->values_num != 1) || (child->values[0].type != OCONFIG_TYPE_NUMBER)){
- WARNING ("pinba plugin: `Port' needs exactly one number argument.");
- return (-1);
- }
- pinba_port=child->values[0].value.number;
- } else if (strcasecmp ("View", child->key) == 0) {
- const char *name=NULL, *host=NULL, *server=NULL, *script=NULL;
- if ((child->values_num != 1) || (child->values[0].type != OCONFIG_TYPE_STRING) || strlen(child->values[0].value.string)==0){
- WARNING ("pinba plugin: `View' needs exactly one non-empty string argument.");
- return (-1);
- }
- name = child->values[0].value.string;
- for(o=0; o<child->children_num; o++){
- oconfig_item_t *node = child->children + o;
- if (strcasecmp ("Host", node->key) == 0) {
- if ((node->values_num != 1) || (node->values[0].type != OCONFIG_TYPE_STRING) || strlen(node->values[0].value.string)==0){
- WARNING ("pinba plugin: `View->Host' needs exactly one non-empty string argument.");
- return (-1);
- }
- host = node->values[0].value.string;
- } else if (strcasecmp ("Server", node->key) == 0) {
- if ((node->values_num != 1) || (node->values[0].type != OCONFIG_TYPE_STRING) || strlen(node->values[0].value.string)==0){
- WARNING ("pinba plugin: `View->Server' needs exactly one non-empty string argument.");
- return (-1);
- }
- server = node->values[0].value.string;
- } else if (strcasecmp ("Script", node->key) == 0) {
- if ((node->values_num != 1) || (node->values[0].type != OCONFIG_TYPE_STRING) || strlen(node->values[0].value.string)==0){
- WARNING ("pinba plugin: `View->Script' needs exactly one non-empty string argument.");
- return (-1);
- }
- script = node->values[0].value.string;
- } else {
- WARNING ("pinba plugin: In `<View>' context allowed only `Host', `Server' and `Script' options but not the `%s'.", node->key);
- return (-1);
- }
- }
- /* add new statnode */
- service_statnode_add(name, host, server, script);
- } else {
- WARNING ("pinba plugin: In `<Plugin pinba>' context allowed only `Address', `Port' and `Observe' options but not the `%s'.", child->key);
- return (-1);
- }
+
+ if (strcasecmp ("Address", child->key) == 0)
+ cf_util_get_string (child, &conf_node);
+ else if (strcasecmp ("Port", child->key) == 0)
+ cf_util_get_service (child, &conf_service);
+ else if (strcasecmp ("View", child->key) == 0)
+ pinba_config_view (child);
+ else
+ WARNING ("pinba plugin: Unknown config option: %s", child->key);