From: Daniel Hilst Date: Thu, 3 Jan 2013 20:09:03 +0000 (-0200) Subject: Add Hostname option to dbi plugin. Use cdbi_config_set_string and fix udb_query_prepa... X-Git-Tag: collectd-5.3.0~61 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=6cad34d7a1ad82f1321edbd2edd44e7f3d7a3795;p=collectd.git Add Hostname option to dbi plugin. Use cdbi_config_set_string and fix udb_query_prepare_result argument --- diff --git a/src/dbi.c b/src/dbi.c index b3bdd130..7067a2d4 100644 --- a/src/dbi.c +++ b/src/dbi.c @@ -48,7 +48,7 @@ struct cdbi_database_s /* {{{ */ char *select_db; char *driver; - char *hostname; + char *hostname; cdbi_driver_option_t *driver_options; size_t driver_options_num; @@ -299,8 +299,7 @@ static int cdbi_config_add_database (oconfig_item_t *ci) /* {{{ */ status = udb_query_pick_from_list (child, queries, queries_num, &db->queries, &db->queries_num); else if (strcasecmp ("Hostname", child->key) == 0) - db->hostname = strdup(child->key); - + status = cdbi_config_set_string(&db->hostname, child); else { WARNING ("dbi plugin: Option `%s' not allowed here.", child->key); @@ -558,7 +557,7 @@ static int cdbi_read_database_query (cdbi_database_t *db, /* {{{ */ sstrncpy (column_names[i], column_name, DATA_MAX_NAME_LEN); } /* }}} for (i = 0; i < column_num; i++) */ - udb_query_prepare_result (q, prep_area, hostname_g, + udb_query_prepare_result (q, prep_area, (db->hostname ? db->hostname : hostname_g), /* plugin = */ "dbi", db->name, column_names, column_num, /* interval = */ 0);