projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'collectd-5.4'
[collectd.git]
/
src
/
postgresql.c
diff --git
a/src/postgresql.c
b/src/postgresql.c
index
47c9c5c
..
87a56b7
100644
(file)
--- a/
src/postgresql.c
+++ b/
src/postgresql.c
@@
-615,7
+615,7
@@
static int c_psql_read (user_data_t *ud)
c_psql_database_t *db;
int success = 0;
c_psql_database_t *db;
int success = 0;
-
in
t i;
+
size_
t i;
if ((ud == NULL) || (ud->data == NULL)) {
log_err ("c_psql_read: Invalid user data.");
if ((ud == NULL) || (ud->data == NULL)) {
log_err ("c_psql_read: Invalid user data.");
@@
-663,8
+663,7
@@
static char *values_name_to_sqlarray (const data_set_t *ds,
{
char *str_ptr;
size_t str_len;
{
char *str_ptr;
size_t str_len;
-
- int i;
+ size_t i;
str_ptr = string;
str_len = string_len;
str_ptr = string;
str_len = string_len;
@@
-702,8
+701,7
@@
static char *values_type_to_sqlarray (const data_set_t *ds,
{
char *str_ptr;
size_t str_len;
{
char *str_ptr;
size_t str_len;
-
- int i;
+ size_t i;
str_ptr = string;
str_len = string_len;
str_ptr = string;
str_len = string_len;
@@
-751,8
+749,7
@@
static char *values_to_sqlarray (const data_set_t *ds, const value_list_t *vl,
size_t str_len;
gauge_t *rates = NULL;
size_t str_len;
gauge_t *rates = NULL;
-
- int i;
+ size_t i;
str_ptr = string;
str_len = string_len;
str_ptr = string;
str_len = string_len;
@@
-772,7
+769,7
@@
static char *values_to_sqlarray (const data_set_t *ds, const value_list_t *vl,
if (ds->ds[i].type == DS_TYPE_GAUGE)
status = ssnprintf (str_ptr, str_len,
if (ds->ds[i].type == DS_TYPE_GAUGE)
status = ssnprintf (str_ptr, str_len,
- ",
%f"
, vl->values[i].gauge);
+ ",
"GAUGE_FORMAT
, vl->values[i].gauge);
else if (store_rates) {
if (rates == NULL)
rates = uc_get_rate (ds, vl);
else if (store_rates) {
if (rates == NULL)
rates = uc_get_rate (ds, vl);
@@
-829,7
+826,7
@@
static int c_psql_write (const data_set_t *ds, const value_list_t *vl,
{
c_psql_database_t *db;
{
c_psql_database_t *db;
- char time_str[
32
];
+ char time_str[
RFC3339NANO_SIZE
];
char values_name_str[1024];
char values_type_str[1024];
char values_str[1024];
char values_name_str[1024];
char values_type_str[1024];
char values_str[1024];
@@
-837,7
+834,7
@@
static int c_psql_write (const data_set_t *ds, const value_list_t *vl,
const char *params[9];
int success = 0;
const char *params[9];
int success = 0;
-
in
t i;
+
size_
t i;
if ((ud == NULL) || (ud->data == NULL)) {
log_err ("c_psql_write: Invalid user data.");
if ((ud == NULL) || (ud->data == NULL)) {
log_err ("c_psql_write: Invalid user data.");
@@
-848,8
+845,8
@@
static int c_psql_write (const data_set_t *ds, const value_list_t *vl,
assert (db->database != NULL);
assert (db->writers != NULL);
assert (db->database != NULL);
assert (db->writers != NULL);
- if (
cdtime_to_iso8601 (time_str, sizeof (time_str), vl->time) =
= 0) {
- log_err ("c_psql_write: Failed to convert time to
ISO 8601
format");
+ if (
rfc3339nano (time_str, sizeof (time_str), vl->time) !
= 0) {
+ log_err ("c_psql_write: Failed to convert time to
RFC 3339
format");
return -1;
}
return -1;
}
@@
-1045,17
+1042,19
@@
static int config_query_param_add (udb_query_t *q, oconfig_item_t *ci)
data = udb_query_get_user_data (q);
if (NULL == data) {
data = udb_query_get_user_data (q);
if (NULL == data) {
- data =
(c_psql_user_data_t *) s
malloc (sizeof (*data));
+ data = malloc (sizeof (*data));
if (NULL == data) {
log_err ("Out of memory.");
return -1;
}
memset (data, 0, sizeof (*data));
data->params = NULL;
if (NULL == data) {
log_err ("Out of memory.");
return -1;
}
memset (data, 0, sizeof (*data));
data->params = NULL;
+ data->params_num = 0;
+
+ udb_query_set_user_data (q, data);
}
}
- tmp = (c_psql_param_t *) realloc (data->params,
- (data->params_num + 1) * sizeof (c_psql_param_t));
+ tmp = realloc (data->params, (data->params_num + 1) * sizeof (*data->params));
if (NULL == tmp) {
log_err ("Out of memory.");
return -1;
if (NULL == tmp) {
log_err ("Out of memory.");
return -1;
@@
-1079,8
+1078,6
@@
static int config_query_param_add (udb_query_t *q, oconfig_item_t *ci)
}
data->params_num++;
}
data->params_num++;
- udb_query_set_user_data (q, data);
-
return (0);
} /* config_query_param_add */
return (0);
} /* config_query_param_add */
@@
-1164,7
+1161,7
@@
static int c_psql_config_writer (oconfig_item_t *ci)
writers = tmp;
writer = writers + writers_num;
writers = tmp;
writer = writers + writers_num;
-
++writers_num
;
+
memset (writer, 0, sizeof (*writer))
;
writer->name = sstrdup (ci->values[0].value.string);
writer->statement = NULL;
writer->name = sstrdup (ci->values[0].value.string);
writer->statement = NULL;
@@
-1184,10
+1181,10
@@
static int c_psql_config_writer (oconfig_item_t *ci)
if (status != 0) {
sfree (writer->statement);
sfree (writer->name);
if (status != 0) {
sfree (writer->statement);
sfree (writer->name);
- sfree (writer);
return status;
}
return status;
}
+ ++writers_num;
return 0;
} /* c_psql_config_writer */
return 0;
} /* c_psql_config_writer */
@@
-1196,7
+1193,6
@@
static int c_psql_config_database (oconfig_item_t *ci)
c_psql_database_t *db;
char cb_name[DATA_MAX_NAME_LEN];
c_psql_database_t *db;
char cb_name[DATA_MAX_NAME_LEN];
- struct timespec cb_interval = { 0, 0 };
user_data_t ud;
static _Bool have_flush = 0;
user_data_t ud;
static _Bool have_flush = 0;
@@
-1291,12
+1287,9
@@
static int c_psql_config_database (oconfig_item_t *ci)
ssnprintf (cb_name, sizeof (cb_name), "postgresql-%s", db->instance);
if (db->queries_num > 0) {
ssnprintf (cb_name, sizeof (cb_name), "postgresql-%s", db->instance);
if (db->queries_num > 0) {
- CDTIME_T_TO_TIMESPEC (db->interval, &cb_interval);
-
++db->ref_cnt;
plugin_register_complex_read ("postgresql", cb_name, c_psql_read,
++db->ref_cnt;
plugin_register_complex_read ("postgresql", cb_name, c_psql_read,
- /* interval = */ (db->interval > 0) ? &cb_interval : NULL,
- &ud);
+ /* interval = */ db->interval, &ud);
}
if (db->writers_num > 0) {
++db->ref_cnt;
}
if (db->writers_num > 0) {
++db->ref_cnt;