typedef struct {
char *name;
char *statement;
- _Bool store_rates;
+ bool store_rates;
} c_psql_writer_t;
typedef struct {
C_PSQL_PAR_APPEND(buf, buf_len, "sslmode", db->sslmode);
C_PSQL_PAR_APPEND(buf, buf_len, "krbsrvname", db->krbsrvname);
C_PSQL_PAR_APPEND(buf, buf_len, "service", db->service);
+ C_PSQL_PAR_APPEND(buf, buf_len, "application_name", "collectd_postgresql");
db->conn = PQconnectdb(conninfo);
db->proto_version = PQprotocolVersion(db->conn);
} /* c_psql_connect */
static int c_psql_check_connection(c_psql_database_t *db) {
- _Bool init = 0;
+ bool init = 0;
if (!db->conn) {
init = 1;
status = udb_query_prepare_result(
q, prep_area, host,
- (db->plugin_name != NULL) ? db->plugin_name : "postgresql",
- db->instance, column_names, (size_t)column_num, db->interval);
+ (db->plugin_name != NULL) ? db->plugin_name : "postgresql", db->instance,
+ column_names, (size_t)column_num, db->interval);
if (0 != status) {
log_err("udb_query_prepare_result failed with status %i.", status);
} /* values_name_to_sqlarray */
static char *values_type_to_sqlarray(const data_set_t *ds, char *string,
- size_t string_len, _Bool store_rates) {
+ size_t string_len, bool store_rates) {
char *str_ptr;
size_t str_len;
static char *values_to_sqlarray(const data_set_t *ds, const value_list_t *vl,
char *string, size_t string_len,
- _Bool store_rates) {
+ bool store_rates) {
char *str_ptr;
size_t str_len;
status = snprintf(str_ptr, str_len, ",%lf", rates[i]);
} else if (ds->ds[i].type == DS_TYPE_COUNTER)
- status = snprintf(str_ptr, str_len, ",%llu", vl->values[i].counter);
+ status = snprintf(str_ptr, str_len, ",%" PRIu64,
+ (uint64_t)vl->values[i].counter);
else if (ds->ds[i].type == DS_TYPE_DERIVE)
status = snprintf(str_ptr, str_len, ",%" PRIi64, vl->values[i].derive);
else if (ds->ds[i].type == DS_TYPE_ABSOLUTE)
} /* c_psql_flush */
static int c_psql_shutdown(void) {
- _Bool had_flush = 0;
+ bool had_flush = 0;
plugin_unregister_read_group("postgresql");
c_psql_database_t *db;
char cb_name[DATA_MAX_NAME_LEN];
- static _Bool have_flush = 0;
+ static bool have_flush;
if ((1 != ci->values_num) || (OCONFIG_TYPE_STRING != ci->values[0].type)) {
log_err("<Database> expects a single string argument.");
cf_util_get_string(c, &db->password);
else if (0 == strcasecmp(c->key, "Instance"))
cf_util_get_string(c, &db->instance);
- else if (0 == strcasecmp (c->key, "Plugin"))
- cf_util_get_string (c, &db->plugin_name);
+ else if (0 == strcasecmp(c->key, "Plugin"))
+ cf_util_get_string(c, &db->plugin_name);
else if (0 == strcasecmp(c->key, "SSLMode"))
cf_util_get_string(c, &db->sslmode);
else if (0 == strcasecmp(c->key, "KRBSrvName"))