static bool agg_is_regex(char const *str) /* {{{ */
{
if (str == NULL)
- return 0;
+ return false;
size_t len = strlen(str);
if (len < 3)
- return 0;
+ return false;
if ((str[0] == '/') && (str[len - 1] == '/'))
- return 1;
+ return true;
else
- return 0;
+ return false;
} /* }}} bool agg_is_regex */
static void agg_destroy(aggregation_t *agg) /* {{{ */
agg->regex_fields |= LU_GROUP_BY_TYPE_INSTANCE;
/* Sanity checking */
- bool is_valid = 1;
+ bool is_valid = true;
if (strcmp("/.*/", agg->ident.type) == 0) /* {{{ */
{
ERROR("aggregation plugin: It appears you did not specify the required "
"Type \"%s\", TypeInstance \"%s\")",
agg->ident.host, agg->ident.plugin, agg->ident.plugin_instance,
agg->ident.type, agg->ident.type_instance);
- is_valid = 0;
+ is_valid = false;
} else if (strchr(agg->ident.type, '/') != NULL) {
ERROR("aggregation plugin: The \"Type\" may not contain the '/' "
"character. Especially, it may not be a regex. The current "
"value is \"%s\".",
agg->ident.type);
- is_valid = 0;
+ is_valid = false;
} /* }}} */
/* Check that there is at least one regex field without a grouping. {{{ */
"Type \"%s\", TypeInstance \"%s\")",
agg->ident.host, agg->ident.plugin, agg->ident.plugin_instance,
agg->ident.type, agg->ident.type_instance);
- is_valid = 0;
+ is_valid = false;
} /* }}} */
/* Check that all grouping fields are regular expressions. {{{ */
"Type \"%s\", TypeInstance \"%s\")",
agg->ident.host, agg->ident.plugin, agg->ident.plugin_instance,
agg->ident.type, agg->ident.type_instance);
- is_valid = 0;
+ is_valid = false;
} /* }}} */
if (!agg->calc_num && !agg->calc_sum && !agg->calc_average /* {{{ */
"Type \"%s\", TypeInstance \"%s\")",
agg->ident.host, agg->ident.plugin, agg->ident.plugin_instance,
agg->ident.type, agg->ident.type_instance);
- is_valid = 0;
+ is_valid = false;
} /* }}} */
if (!is_valid) { /* {{{ */
static int agg_write(data_set_t const *ds, value_list_t const *vl, /* {{{ */
__attribute__((unused)) user_data_t *user_data) {
- bool created_by_aggregation = 0;
+ bool created_by_aggregation = false;
/* Ignore values that were created by the aggregation plugin to avoid weird
* effects. */
(void)meta_data_get_boolean(vl->meta, "aggregation:created",
r = amqp_get_rpc_reply(conf->connection);
if (r.reply_type == AMQP_RESPONSE_NORMAL)
- return 0;
+ return false;
- return 1;
+ return true;
} /* }}} bool camqp_is_error */
static char *camqp_strerror(camqp_config_t *conf, /* {{{ */
/* publish only */
conf->delivery_mode = CAMQP_DM_VOLATILE;
- conf->store_rates = 0;
+ conf->store_rates = false;
conf->graphite_flags = 0;
/* publish & graphite only */
conf->prefix = NULL;
/* subscribe only */
conf->exchange_type = NULL;
conf->queue = NULL;
- conf->queue_durable = 0;
- conf->queue_auto_delete = 1;
+ conf->queue_durable = false;
+ conf->queue_auto_delete = true;
/* general */
conf->connection = NULL;
pthread_mutex_init(&conf->lock, /* attr = */ NULL);
oconfig_item_t *child = ci->children + i;
if (strcasecmp("Publish", child->key) == 0)
- camqp_config_connection(child, /* publish = */ 1);
+ camqp_config_connection(child, /* publish = */ true);
else if (strcasecmp("Subscribe", child->key) == 0)
- camqp_config_connection(child, /* publish = */ 0);
+ camqp_config_connection(child, /* publish = */ false);
else
WARNING("amqp plugin: Ignoring unknown config option \"%s\".",
child->key);
"first %i iterations. Will close the socket "
"in future iterations.",
count_retries, count_iterations);
- conf_persistent_conn = 0;
+ conf_persistent_conn = false;
}
while ((n = net_recv(&global_sockfd, recvline, sizeof(recvline) - 1)) > 0) {
}
static int apcups_config(oconfig_item_t *ci) {
- bool persistent_conn_set = 0;
+ bool persistent_conn_set = false;
for (int i = 0; i < ci->children_num; i++) {
oconfig_item_t *child = ci->children + i;
cf_util_get_boolean(child, &conf_report_seconds);
else if (strcasecmp(child->key, "PersistentConnection") == 0) {
cf_util_get_boolean(child, &conf_persistent_conn);
- persistent_conn_set = 1;
+ persistent_conn_set = true;
} else
ERROR("apcups plugin: Unknown config option \"%s\".", child->key);
}
"Apcupsd NIS socket timeout is %.3f seconds, "
"PersistentConnection disabled by default.",
interval, APCUPS_SERVER_TIMEOUT);
- conf_persistent_conn = 0;
+ conf_persistent_conn = false;
}
}
config_oversample - 1);
usleep(20000);
}
- avg_initialized = 1;
+ avg_initialized = true;
}
result = MPL115_read_averaged(&pressure, &temperature);
return -1;
}
- configured = 1;
+ configured = true;
return 0;
}
char const *plugin_instance;
char buffer[32];
gauge_t v = NAN;
- bool discharging = 0;
+ bool discharging = false;
int status;
/* Ignore non-battery directories, such as AC power. */
(void)sysfs_file_to_buffer(dir, power_supply, "status", buffer,
sizeof(buffer));
if (strcasecmp("Discharging", buffer) == 0)
- discharging = 1;
+ discharging = true;
/* FIXME: This is a dirty hack for backwards compatibility: The battery
* plugin, for a very long time, has had the plugin_instance
gauge_t capacity_charged = NAN;
gauge_t capacity_full = NAN;
gauge_t capacity_design = NAN;
- bool charging = 0;
- bool is_current = 0;
+ bool charging = false;
+ bool is_current = false;
char const *plugin_instance;
char filename[PATH_MAX];
if ((strcmp(fields[0], "charging") == 0) &&
(strcmp(fields[1], "state:") == 0)) {
if (strcmp(fields[2], "charging") == 0)
- charging = 1;
+ charging = true;
else
- charging = 0;
+ charging = false;
continue;
}
strtogauge(fields[2], &power);
if ((numfields >= 4) && (strcmp("mA", fields[3]) == 0))
- is_current = 1;
+ is_current = true;
} else if ((strcmp(fields[0], "remaining") == 0) &&
(strcmp(fields[1], "capacity:") == 0))
strtogauge(fields[2], &capacity_charged);
size_t src_len;
char *ptr = buffer;
size_t ptr_size = buffer_size;
- bool append_plus = 0;
- bool append_minus = 0;
+ bool append_plus = false;
+ bool append_minus = false;
if ((buffer == NULL) || (buffer_size <= strlen("Minus")) || (src == NULL))
return EINVAL;
/* Remove trailing "+" and "-". */
if (src_copy[src_len - 1] == '+') {
- append_plus = 1;
+ append_plus = true;
src_len--;
src_copy[src_len] = 0;
} else if (src_copy[src_len - 1] == '-') {
- append_minus = 1;
+ append_minus = true;
src_len--;
src_copy[src_len] = 0;
}
size_t offset;
if (suffix_len > str_len)
- return 0;
+ return false;
offset = str_len - suffix_len;
if (strcmp(str + offset, suffix) == 0)
- return 1;
+ return true;
- return 0;
+ return false;
}
static void cut_suffix(char *buffer, size_t buffer_size, char const *str,
snprintf(status, sizeof(status),
"unexpected call: test_handler(\"%s\") = \"%s\"", key, val);
- ok = 0;
+ ok = false;
for (i = 0; i < t->cases_num; i++) {
if (strcmp(key, t->cases[i].key) != 0)
snprintf(status, sizeof(status),
"test_handler(\"%s\") = \"%s\", want \"%s\"", key, val,
t->cases[i].value);
- ok = 0;
+ ok = false;
break;
}
snprintf(status, sizeof(status), "test_handler(\"%s\") = \"%s\"", key, val);
- ok = 1;
+ ok = true;
break;
}
static int cgroups_read(void) {
cu_mount_t *mnt_list = NULL;
- bool cgroup_found = 0;
+ bool cgroup_found = false;
if (cu_mount_getlist(&mnt_list) == NULL) {
ERROR("cgroups plugin: cu_mount_getlist failed.");
walk_directory(mnt_ptr->dir, read_cpuacct_root,
/* user_data = */ NULL,
/* include_hidden = */ 0);
- cgroup_found = 1;
+ cgroup_found = true;
/* It doesn't make sense to check other cpuacct mount-points
* (if any), they contain the same data. */
break;
break;
}
case 'm':
- nan_is_error_g = 1;
+ nan_is_error_g = true;
break;
default:
usage(argv[0]);
static void signal_handler(int signal) /* {{{ */
{
- loop = 0;
+ loop = false;
} /* }}} void signal_handler */
#if HAVE_CLOCK_GETTIME
static int cpu_config(char const *key, char const *value) /* {{{ */
{
if (strcasecmp(key, "ReportByCpu") == 0)
- report_by_cpu = IS_TRUE(value) ? 1 : 0;
+ report_by_cpu = IS_TRUE(value);
else if (strcasecmp(key, "ValuesPercentage") == 0)
- report_percent = IS_TRUE(value) ? 1 : 0;
+ report_percent = IS_TRUE(value);
else if (strcasecmp(key, "ReportByState") == 0)
- report_by_state = IS_TRUE(value) ? 1 : 0;
+ report_by_state = IS_TRUE(value);
else if (strcasecmp(key, "ReportNumCpu") == 0)
- report_num_cpu = IS_TRUE(value) ? 1 : 0;
+ report_num_cpu = IS_TRUE(value);
else if (strcasecmp(key, "ReportGuestState") == 0)
- report_guest = IS_TRUE(value) ? 1 : 0;
+ report_guest = IS_TRUE(value);
else if (strcasecmp(key, "SubtractGuestState") == 0)
- subtract_guest = IS_TRUE(value) ? 1 : 0;
+ subtract_guest = IS_TRUE(value);
else
return -1;
}
if (!isnan(this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].rate))
- this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].has_value = 1;
+ this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].has_value = true;
RATE_ADD(sum_by_state[COLLECTD_CPU_STATE_ACTIVE],
this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].rate);
static void cpu_reset(void) /* {{{ */
{
for (size_t i = 0; i < cpu_states_num; i++)
- cpu_states[i].has_value = 0;
+ cpu_states[i].has_value = false;
global_cpu_num = 0;
} /* }}} void cpu_reset */
return status;
s->rate = rate;
- s->has_value = 1;
+ s->has_value = true;
return 0;
} /* }}} int cpu_stage */
page->url = NULL;
page->user = NULL;
page->pass = NULL;
- page->digest = 0;
- page->verify_peer = 1;
- page->verify_host = 1;
- page->response_time = 0;
- page->response_code = 0;
+ page->digest = false;
+ page->verify_peer = true;
+ page->verify_host = true;
+ page->response_time = false;
+ page->response_code = false;
page->timeout = -1;
page->stats = NULL;
return CJ_CB_ABORT;
}
db->depth++;
- db->state[db->depth].in_array = 1;
+ db->state[db->depth].in_array = true;
db->state[db->depth].index = 0;
cj_load_key(db, "0");
static int cj_cb_end_array(void *ctx) {
cj_t *db = (cj_t *)ctx;
- db->state[db->depth].in_array = 0;
+ db->state[db->depth].in_array = false;
return cj_cb_end(ctx);
}
switch (c) {
case 'B':
- config->create_basedir = 0;
+ config->create_basedir = false;
break;
case 'C':
config->configfile = optarg;
break;
case 't':
- config->test_config = 1;
+ config->test_config = true;
break;
case 'T':
- config->test_readall = 1;
+ config->test_readall = true;
global_option_set("ReadThreads", "-1", 1);
#if COLLECT_DAEMON
- config->daemonize = 0;
+ config->daemonize = false;
#endif /* COLLECT_DAEMON */
break;
#if COLLECT_DAEMON
global_option_set("PIDFile", optarg, 1);
break;
case 'f':
- config->daemonize = 0;
+ config->daemonize = false;
break;
#endif /* COLLECT_DAEMON */
case 'h':
int exit_status = 0;
struct cmdline_config config = {
- .daemonize = 1, .create_basedir = 1, .configfile = CONFIGFILE,
+ .daemonize = true, .create_basedir = true, .configfile = CONFIGFILE,
};
read_cmdline(argc, argv, &config);
static int dispatch_loadplugin(oconfig_item_t *ci) {
const char *name;
- bool global = 0;
+ bool global = false;
plugin_ctx_t ctx = {0};
plugin_ctx_t old_ctx;
int ret_val;
ctx.interval = cf_get_default_interval();
old_ctx = plugin_set_ctx(ctx);
- status = plugin_load(name, /* flags = */ 0);
+ status = plugin_load(name, /* flags = */ false);
/* reset to the "global" context */
plugin_set_ctx(old_ctx);
switch (ci->values[0].type) {
case OCONFIG_TYPE_BOOLEAN:
- *ret_bool = ci->values[0].value.boolean ? 1 : 0;
+ *ret_bool = ci->values[0].value.boolean ? true : false;
break;
case OCONFIG_TYPE_STRING:
WARNING("cf_util_get_boolean: Using string value `%s' for boolean option "
ci->values[0].value.string, ci->key);
if (IS_TRUE(ci->values[0].value.string))
- *ret_bool = 1;
+ *ret_bool = true;
else if (IS_FALSE(ci->values[0].value.string))
- *ret_bool = 0;
+ *ret_bool = false;
else {
ERROR("cf_util_get_boolean: Cannot parse string value `%s' of the `%s' "
"option as a boolean value.",
int cf_util_get_flag(const oconfig_item_t *ci, /* {{{ */
unsigned int *ret_value, unsigned int flag) {
int status;
- bool b;
if (ret_value == NULL)
return EINVAL;
- b = 0;
+ bool b = false;
status = cf_util_get_boolean(ci, &b);
if (status != 0)
return status;
INFO("collectd: Stopping %" PRIsz " write threads.", write_threads_num);
pthread_mutex_lock(&write_lock);
- write_loop = 0;
+ write_loop = false;
DEBUG("plugin: stop_write_threads: Signalling `write_cond'");
pthread_cond_broadcast(&write_cond);
pthread_mutex_unlock(&write_lock);
*/
if ((strcasecmp("perl", plugin_name) == 0) ||
(strcasecmp("python", plugin_name) == 0))
- global = 1;
+ global = true;
/* `cpu' should not match `cpufreq'. To solve this we add `.so' to the
* type when matching the filename */
uc_init();
if (IS_TRUE(global_option_get("CollectInternalStats"))) {
- record_statistics = 1;
+ record_statistics = true;
plugin_register_read("collectd", plugin_update_internal_statistics);
}
int status;
static c_complain_t no_write_complaint = C_COMPLAIN_INIT_STATIC;
- bool free_meta_data = 0;
+ bool free_meta_data = false;
assert(vl != NULL);
* this case matches and targets may add some and the calling function
* may not expect (and therefore free) that data. */
if (vl->meta == NULL)
- free_meta_data = 1;
+ free_meta_data = true;
if (list_write == NULL)
c_complain_once(LOG_WARNING, &no_write_complaint,
} else
fc_default_action(ds, vl);
- if ((free_meta_data != 0) && (vl->meta != NULL)) {
+ if ((free_meta_data == true) && (vl->meta != NULL)) {
meta_data_destroy(vl->meta);
vl->meta = NULL;
}
int status;
if (write_limit_high == 0)
- return 0;
+ return false;
p = get_drop_probability();
if (p == 0.0)
- return 0;
+ return false;
status = pthread_mutex_trylock(&last_message_lock);
if (status == 0) {
}
if (p == 1.0)
- return 1;
+ return true;
q = cdrand_d();
if (q > p)
- return 1;
+ return true;
else
- return 0;
+ return false;
} /* }}} bool check_drop_value */
int plugin_dispatch_values(value_list_t const *vl) {
void plugin_init_ctx(void) {
pthread_key_create(&plugin_ctx_key, plugin_ctx_destructor);
- plugin_ctx_key_initialized = 1;
+ plugin_ctx_key_initialized = true;
} /* void plugin_init_ctx */
plugin_ctx_t plugin_get_ctx(void) {
* plugin_dispatch_multivalue
*
* SYNOPSIS
- * plugin_dispatch_multivalue (vl, 1, DS_TYPE_GAUGE,
+ * plugin_dispatch_multivalue (vl, true, DS_TYPE_GAUGE,
* "free", 42.0,
* "used", 58.0,
* NULL);
va_start(ap, format);
if (vcomplain(level, c, format, ap))
- c->complained_once = 1;
+ c->complained_once = true;
va_end(ap);
} /* c_complain */
va_start(ap, format);
if (vcomplain(level, c, format, ap))
- c->complained_once = 1;
+ c->complained_once = true;
va_end(ap);
} /* c_complain_once */
return;
c->interval = 0;
- c->complained_once = 0;
+ c->complained_once = false;
va_start(ap, format);
vsnprintf(message, sizeof(message), format, ap);
do { \
(c)->last = 0; \
(c)->interval = 0; \
- (c)->complained_once = 0; \
+ (c)->complained_once = false; \
} while (0)
/*
seed[1] = (unsigned short)(t >> 16);
seed[2] = (unsigned short)(t >> 32);
- have_seed = 1;
+ have_seed = true;
}
double cdrand_d(void) {
} else {
assert(ci->values[1].type == OCONFIG_TYPE_NUMBER);
option->value.numeric = (int)(ci->values[1].value.number + .5);
- option->is_numeric = 1;
+ option->is_numeric = true;
}
db->driver_options_num++;
return 0;
} else if (strcasecmp(key, "ReportByDevice") == 0) {
if (IS_TRUE(value))
- by_device = 1;
+ by_device = true;
return 0;
} else if (strcasecmp(key, "ReportInodes") == 0) {
if (IS_TRUE(value))
- report_inodes = 1;
+ report_inodes = true;
else
- report_inodes = 0;
+ report_inodes = false;
return 0;
} else if (strcasecmp(key, "ValuesAbsolute") == 0) {
if (IS_TRUE(value))
- values_absolute = 1;
+ values_absolute = true;
else
- values_absolute = 0;
+ values_absolute = false;
return 0;
} else if (strcasecmp(key, "ValuesPercentage") == 0) {
if (IS_TRUE(value))
- values_percentage = 1;
+ values_percentage = true;
else
- values_percentage = 0;
+ values_percentage = false;
return 0;
}
ignorelist_set_invert(ignorelist, invert);
} else if (strcasecmp("UseBSDName", key) == 0) {
#if HAVE_IOKIT_IOKITLIB_H
- use_bsd_name = IS_TRUE(value) ? 1 : 0;
+ use_bsd_name = IS_TRUE(value);
#else
WARNING("disk plugin: The \"UseBSDName\" option is only supported "
"on Mach / Mac OS X and will be ignored.");
ds->write_time = write_time;
if (read_merged || write_merged)
- ds->has_merged = 1;
+ ds->has_merged = true;
if (in_progress)
- ds->has_in_progress = 1;
+ ds->has_in_progress = true;
if (io_time)
- ds->has_io_time = 1;
+ ds->has_io_time = true;
} /* if (is_disk) */
/* Link Status */
ec->config.link_status.enabled = 1;
ec->config.link_status.enabled_port_mask = ~0;
- ec->config.link_status.send_updated = 1;
- ec->config.link_status.notify = 0;
+ ec->config.link_status.send_updated = true;
+ ec->config.link_status.notify = false;
for (int i = 0; i < RTE_MAX_ETHPORTS; i++) {
ec->config.link_status.port_name[i][0] = 0;
/* Keep Alive */
ec->config.keep_alive.enabled = 1;
- ec->config.keep_alive.send_updated = 1;
- ec->config.keep_alive.notify = 0;
+ ec->config.keep_alive.send_updated = true;
+ ec->config.keep_alive.notify = false;
/* by default enable 128 cores */
memset(&ec->config.keep_alive.lcore_mask, 1,
sizeof(ec->config.keep_alive.lcore_mask));
if (strcasecmp(key, "ValuesAbsolute") == 0) {
if (IS_TRUE(value)) {
- values_absolute = 1;
+ values_absolute = true;
} else {
- values_absolute = 0;
+ values_absolute = false;
}
ret = 0;
} else if (strcasecmp(key, "ValuesPercentage") == 0) {
if (IS_TRUE(value)) {
- values_percentage = 1;
+ values_percentage = true;
} else {
- values_percentage = 0;
+ values_percentage = false;
}
ret = 0;
}
pkcp.cert_chain = read_file(cert);
} else if (!strcasecmp("VerifyPeer", child->key)) {
- bool verify = 0;
+ bool verify = false;
if (cf_util_get_boolean(child, &verify)) {
return -1;
}
if (g_values_pages) {
sstrncpy(vl.type, "vmpage_number", sizeof(vl.type));
- plugin_dispatch_multivalue(&vl, /* store_percentage = */ 0, DS_TYPE_GAUGE,
- "free", free, "used", used, NULL);
+ plugin_dispatch_multivalue(&vl, /* store_percentage = */ false,
+ DS_TYPE_GAUGE, "free", free, "used", used, NULL);
}
if (g_values_bytes) {
gauge_t page_size = (gauge_t)(1024 * info->page_size_kb);
sstrncpy(vl.type, "memory", sizeof(vl.type));
- plugin_dispatch_multivalue(&vl, /* store_percentage = */ 0, DS_TYPE_GAUGE,
- "free", free * page_size, "used",
+ plugin_dispatch_multivalue(&vl, /* store_percentage = */ false,
+ DS_TYPE_GAUGE, "free", free * page_size, "used",
used * page_size, NULL);
}
if (g_values_percent) {
sstrncpy(vl.type, "percent", sizeof(vl.type));
- plugin_dispatch_multivalue(&vl, /* store_percentage = */ 1, DS_TYPE_GAUGE,
- "free", free, "used", used, NULL);
+ plugin_dispatch_multivalue(&vl, /* store_percentage = */ true,
+ DS_TYPE_GAUGE, "free", free, "used", used, NULL);
}
}
else if (strcasecmp(key, "UniqueName") == 0) {
#ifdef HAVE_LIBKSTAT
if (IS_TRUE(value))
- unique_name = 1;
+ unique_name = true;
#else
WARNING("interface plugin: the \"UniqueName\" option is only valid on "
"Solaris.");
plugin_dispatch_notification(&n);
}
- st->connected = 0;
+ st->connected = false;
return;
}
plugin_dispatch_notification(&n);
}
- st->connected = 1;
+ st->connected = true;
int status = ipmi_domain_add_entity_update_handler(
domain, domain_entity_update_handler, /* user data = */ st);
int status = c_ipmi_thread_init(st);
if (status != 0) {
ERROR("ipmi plugin: c_ipmi_thread_init failed.");
- st->active = 0;
+ st->active = false;
return (void *)-1;
}
- while (st->active != 0) {
+ while (st->active) {
struct timeval tv = {1, 0};
os_handler->perform_one_op(os_handler, &tv);
}
static int c_ipmi_read(user_data_t *user_data) {
c_ipmi_instance_t *st = user_data->data;
- if (st->active == 0) {
+ if (st->active == false) {
INFO("ipmi plugin: c_ipmi_read: I'm not active, returning false.");
return -1;
}
- if (st->connected == 0)
+ if (st->connected == false)
return 0;
sensor_list_read_all(st);
}
st->init_in_progress = cycles;
- st->active = 1;
+ st->active = true;
status = plugin_thread_create(&st->thread_id, /* attr = */ NULL,
c_ipmi_thread_main,
/* user data = */ (void *)st, "ipmi");
if (status != 0) {
- st->active = 0;
+ st->active = false;
st->thread_id = (pthread_t){0};
plugin_unregister_read(callback_name);
c_ipmi_instance_t *next = st->next;
st->next = NULL;
- st->active = 0;
+ st->active = false;
if (!pthread_equal(st->thread_id, (pthread_t){0})) {
pthread_join(st->thread_id, NULL);
if (!need_init)
return result;
- need_init = 0;
+ need_init = false;
#if HAVE_GCRYPT_H
#if GCRYPT_VERSION_NUMBER < 0x010600
if (gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread))
- return 0;
+ return false;
#endif
if (!gcry_check_version(GCRYPT_VERSION))
- return 0;
+ return false;
if (!gcry_control(GCRYCTL_INIT_SECMEM, 32768, 0))
- return 0;
+ return false;
gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
- result = 1;
- return 1;
+ result = true;
+ return true;
#else
- return 0;
+ return false;
#endif
} /* }}} bool have_gcrypt */
static int load_config(const char *key, const char *value) {
if (strcasecmp(key, "ReportRelative") == 0)
#ifdef _SC_NPROCESSORS_ONLN
- report_relative_load = IS_TRUE(value) ? 1 : 0;
+ report_relative_load = IS_TRUE(value);
#else
WARNING("load plugin: The \"ReportRelative\" configuration "
"is not available, because I can't determine the "
static void log_logstash_print(yajl_gen g, int severity,
cdtime_t timestamp_time) {
FILE *fh;
- bool do_close = 0;
+ bool do_close = false;
struct tm timestamp_tm;
char timestamp_str[64];
const unsigned char *buf;
fh = stderr;
} else if (strcasecmp(log_file, "stdout") == 0) {
fh = stdout;
- do_close = 0;
+ do_close = false;
} else if (strcasecmp(log_file, "stderr") == 0) {
fh = stderr;
- do_close = 0;
+ do_close = false;
} else {
fh = fopen(log_file, "a");
- do_close = 1;
+ do_close = true;
}
if (fh == NULL) {
static void logfile_print(const char *msg, int severity,
cdtime_t timestamp_time) {
FILE *fh;
- bool do_close = 0;
+ bool do_close = false;
char timestamp_str[64];
char level_str[16] = "";
fh = stdout;
else {
fh = fopen(log_file, "a");
- do_close = 1;
+ do_close = true;
}
if (fh == NULL) {
static int lpar_config(const char *key, const char *value) {
if (strcasecmp("CpuPoolStats", key) == 0) {
if (IS_TRUE(value))
- pool_stats = 1;
+ pool_stats = true;
else
- pool_stats = 0;
+ pool_stats = false;
} else if (strcasecmp("ReportBySerial", key) == 0) {
if (IS_TRUE(value))
- report_by_serial = 1;
+ report_by_serial = true;
else
- report_by_serial = 0;
+ report_by_serial = false;
} else {
return -1;
}
#if PERFSTAT_SUPPORTS_DONATION
if (!lparstats_old.type.b.shared_enabled &&
lparstats_old.type.b.donate_enabled) {
- donate_flag = 1;
+ donate_flag = true;
}
#endif
if (pool_stats && !lparstats_old.type.b.pool_util_authority) {
WARNING("lpar plugin: This partition does not have pool authority. "
"Disabling CPU pool statistics collection.");
- pool_stats = 0;
+ pool_stats = false;
}
return 0;
return -ENOMEM;
}
- m->invert = 0;
+ m->invert = false;
status = 0;
for (int i = 0; i < ci->children_num; i++) {
static int socket_receive(socket_adapter_t *self, FILE **p_file);
static mcelog_config_t g_mcelog_config = {
- .logfile = "/var/log/mcelog", .persist = 0,
+ .logfile = "/var/log/mcelog", .persist = false,
};
static socket_adapter_t socket_adapter = {
int status = 0;
/* Disable automatic generation of default instance in the init callback. */
- memcached_have_instances = 1;
+ memcached_have_instances = true;
memcached_t *st = calloc(1, sizeof(*st));
if (st == NULL) {
int status = memcached_add_read_callback(st);
if (status == 0)
- memcached_have_instances = 1;
+ memcached_have_instances = true;
return status;
} /* int memcached_init */
#define MEMORY_SUBMIT(...) \
do { \
if (values_absolute) \
- plugin_dispatch_multivalue(vl, 0, DS_TYPE_GAUGE, __VA_ARGS__, NULL); \
+ plugin_dispatch_multivalue(vl, false, DS_TYPE_GAUGE, __VA_ARGS__, NULL); \
if (values_percentage) \
- plugin_dispatch_multivalue(vl, 1, DS_TYPE_GAUGE, __VA_ARGS__, NULL); \
+ plugin_dispatch_multivalue(vl, true, DS_TYPE_GAUGE, __VA_ARGS__, NULL); \
} while (0)
static int memory_read_internal(value_list_t *vl) {
char *fields[8];
int numfields;
- bool detailed_slab_info = 0;
+ bool detailed_slab_info = false;
gauge_t mem_total = 0;
gauge_t mem_used = 0;
val = &mem_slab_total;
else if (strncasecmp(buffer, "SReclaimable:", 13) == 0) {
val = &mem_slab_reclaimable;
- detailed_slab_info = 1;
+ detailed_slab_info = true;
} else if (strncasecmp(buffer, "SUnreclaim:", 11) == 0) {
val = &mem_slab_unreclaimable;
- detailed_slab_info = 1;
+ detailed_slab_info = true;
} else
continue;
return status;
}
- host->is_connected = 1;
+ host->is_connected = true;
return 0;
} /* }}} int mb_init_connection */
/* #endif LEGACY_LIBMODBUS */
if (status != 0) {
ERROR("Modbus plugin: mb_init_connection (%s/%s) failed. ", host->host,
host->node);
- host->is_connected = 0;
+ host->is_connected = false;
host->connection = NULL;
return -1;
}
if (conf->connected)
(void)mosquitto_disconnect(conf->mosq);
- conf->connected = 0;
+ conf->connected = false;
(void)mosquitto_destroy(conf->mosq);
sfree(conf->host);
return -1;
}
- conf->connected = 1;
+ conf->connected = true;
c_release(LOG_INFO, &conf->complaint_cantpublish,
"mqtt plugin: successfully reconnected to broker \"%s:%d\"",
}
}
- conf->connected = 1;
+ conf->connected = true;
return 0;
} /* mqtt_connect */
/* max_packets = */ 100);
#endif
if (status == MOSQ_ERR_CONN_LOST) {
- conf->connected = 0;
+ conf->connected = false;
continue;
} else if (status != MOSQ_ERR_SUCCESS) {
ERROR("mqtt plugin: mosquitto_loop failed: %s",
mosquitto_strerror(status));
mosquitto_destroy(conf->mosq);
conf->mosq = NULL;
- conf->connected = 0;
+ conf->connected = false;
continue;
}
/* Mark our connection "down" regardless of the error as a safety
* measure; we will try to reconnect the next time we have to publish a
* message */
- conf->connected = 0;
+ conf->connected = false;
mosquitto_disconnect(conf->mosq);
pthread_mutex_unlock(&conf->lock);
ERROR("mqtt plugin: calloc failed.");
return -1;
}
- conf->publish = 1;
+ conf->publish = true;
conf->name = NULL;
status = cf_util_get_string(ci, &conf->name);
conf->client_id = NULL;
conf->qos = 0;
conf->topic_prefix = strdup(MQTT_DEFAULT_TOPIC_PREFIX);
- conf->store_rates = 1;
+ conf->store_rates = true;
status = pthread_mutex_init(&conf->lock, NULL);
if (status != 0) {
ERROR("mqtt plugin: calloc failed.");
return -1;
}
- conf->publish = 0;
+ conf->publish = false;
conf->name = NULL;
status = cf_util_get_string(ci, &conf->name);
conf->client_id = NULL;
conf->qos = 2;
conf->topic = strdup(MQTT_DEFAULT_TOPIC);
- conf->clean_session = 1;
+ conf->clean_session = true;
status = pthread_mutex_init(&conf->lock, NULL);
if (status != 0) {
db->timeout = 0;
/* trigger a notification, if it's not running */
- db->slave_io_running = 1;
- db->slave_sql_running = 1;
+ db->slave_io_running = true;
+ db->slave_sql_running = true;
status = cf_util_get_string(ci, &db->instance);
if (status != 0) {
WARNING("mysql plugin: Lost connection to instance \"%s\": %s",
db->instance, mysql_error(db->con));
}
- db->is_connected = 0;
+ db->is_connected = false;
/* Close the old connection before initializing a new one. */
if (db->con != NULL) {
mysql_get_host_info(db->con), (cipher != NULL) ? cipher : "<none>",
mysql_get_server_info(db->con), mysql_get_proto_info(db->con));
- db->is_connected = 1;
+ db->is_connected = true;
return db->con;
} /* static MYSQL *getconnection (mysql_database_t *db) */
snprintf(n.message, sizeof(n.message),
"slave I/O thread not started or not connected to master");
plugin_dispatch_notification(&n);
- db->slave_io_running = 0;
+ db->slave_io_running = false;
} else if (((io != NULL) && (strcasecmp(io, "yes") == 0)) &&
(!db->slave_io_running)) {
n.severity = NOTIF_OKAY;
snprintf(n.message, sizeof(n.message),
"slave I/O thread started and connected to master");
plugin_dispatch_notification(&n);
- db->slave_io_running = 1;
+ db->slave_io_running = true;
}
if (((sql == NULL) || (strcasecmp(sql, "yes") != 0)) &&
n.severity = NOTIF_WARNING;
snprintf(n.message, sizeof(n.message), "slave SQL thread not started");
plugin_dispatch_notification(&n);
- db->slave_sql_running = 0;
+ db->slave_sql_running = false;
} else if (((sql != NULL) && (strcasecmp(sql, "yes") == 0)) &&
(!db->slave_sql_running)) {
n.severity = NOTIF_OKAY;
snprintf(n.message, sizeof(n.message), "slave SQL thread started");
plugin_dispatch_notification(&n);
- db->slave_sql_running = 1;
+ db->slave_sql_running = true;
}
}
static int cna_config_host(host_config_t *host, /* {{{ */
const oconfig_item_t *ci) {
oconfig_item_t *item;
- bool is_vfiler = 0;
+ bool is_vfiler = false;
int status;
if (!strcasecmp(ci->key, "VFiler"))
- is_vfiler = 1;
+ is_vfiler = true;
if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
WARNING("netapp plugin: \"%s\" needs exactly one string argument. Ignoring "
const char *tc_type;
char tc_inst[DATA_MAX_NAME_LEN];
- bool stats_submitted = 0;
+ bool stats_submitted = false;
if (nlh->nlmsg_type == RTM_NEWQDISC)
tc_type = "qdisc";
if (q_stats.bs != NULL || q_stats.qs != NULL) {
char type_instance[DATA_MAX_NAME_LEN];
- stats_submitted = 1;
+ stats_submitted = true;
snprintf(type_instance, sizeof(type_instance), "%s-%s", tc_type, tc_inst);
struct sockent_client *client;
struct addrinfo *ai_list;
int status;
- bool reconnect = 0;
+ bool reconnect = false;
cdtime_t now;
if ((se == NULL) || (se->type != SOCKENT_TYPE_CLIENT))
"next_resolve_reconnect = %lf",
CDTIME_T_TO_DOUBLE(client->resolve_interval),
CDTIME_T_TO_DOUBLE(client->next_resolve_reconnect));
- reconnect = 1;
+ reconnect = true;
}
if (client->fd >= 0 && !reconnect) /* already connected and not stale*/
* nothing more to do (for now, that is). */
if (have_init)
return 0;
- have_init = 1;
+ have_init = true;
if (network_config_stats)
plugin_register_read("network", network_stats_read);
sstrncpy(ntpd_port, value, sizeof(ntpd_port));
} else if (strcasecmp(key, "ReverseLookups") == 0) {
if (IS_TRUE(value))
- do_reverse_lookups = 1;
+ do_reverse_lookups = true;
else
- do_reverse_lookups = 0;
+ do_reverse_lookups = false;
} else if (strcasecmp(key, "IncludeUnitID") == 0) {
if (IS_TRUE(value))
- include_unit_id = 1;
+ include_unit_id = true;
else
- include_unit_id = 0;
+ include_unit_id = false;
} else {
return -1;
}
direct_list_element_free(element);
return 1;
}
- regex_direct_initialized = 1;
+ regex_direct_initialized = true;
DEBUG("onewire plugin: Compiled regex!!");
}
}
} else {
DEBUG("onewire plugin: %s is a direct access", value);
- direct_access = 1;
+ direct_access = true;
}
} else if (strcasecmp(key, "IgnoreSelected") == 0) {
ignorelist_set_invert(sensor_list, 1);
if (st->cacert != NULL)
ldap_set_option(st->ld, LDAP_OPT_X_TLS_CACERTFILE, st->cacert);
- if (st->verifyhost == 0) {
+ if (st->verifyhost == false) {
int never = LDAP_OPT_X_TLS_NEVER;
ldap_set_option(st->ld, LDAP_OPT_X_TLS_REQUIRE_CERT, &never);
}
- if (st->starttls != 0) {
+ if (st->starttls) {
rc = ldap_start_tls_s(st->ld, NULL, NULL);
if (rc != LDAP_SUCCESS) {
ERROR("openldap plugin: Failed to start tls on %s: %s", st->url,
return status;
}
- st->starttls = 0;
+ st->starttls = false;
st->timeout = (long)CDTIME_T_TO_TIME_T(plugin_get_interval());
- st->verifyhost = 1;
+ st->verifyhost = true;
st->version = LDAP_VERSION3;
for (int i = 0; i < ci->children_num; i++) {
char *fields[10];
const int max_fields = STATIC_ARRAY_SIZE(fields);
long long sum_users = 0;
- bool found_header = 0;
+ bool found_header = false;
/* read the file until the "ROUTING TABLE" line is found (no more info after)
*/
break;
if (strcmp(buffer, V1HEADER) == 0) {
- found_header = 1;
+ found_header = true;
continue;
}
/* skip the first lines until the client list section is found */
- if (found_header == 0)
+ if (found_header == false)
/* we can't start reading data until this string is found */
continue;
if (ferror(fh))
return -1;
- if (found_header == 0) {
+ if (found_header == false) {
NOTICE("openvpn plugin: Unknown file format in instance %s, please "
"report this as bug. Make sure to include "
"your status file, so the plugin can "
const int max_fields = STATIC_ARRAY_SIZE(fields);
long long sum_users = 0;
- bool found_header = 0;
+ bool found_header = false;
int idx_cname = 0;
int idx_bytes_recv = 0;
int idx_bytes_sent = 0;
int fields_num = openvpn_strsplit(buffer, fields, max_fields);
/* Try to find section header */
- if (found_header == 0) {
+ if (found_header == false) {
if (fields_num < 2)
continue;
if (strcmp(fields[0], "HEADER") != 0)
/* Data row has 1 field ("HEADER") less than header row */
columns = fields_num - 1;
- found_header = 1;
+ found_header = true;
continue;
}
if (ferror(fh))
return -1;
- if (found_header == 0) {
+ if (found_header == false) {
NOTICE("openvpn plugin: Unknown file format in instance %s, please "
"report this as bug. Make sure to include "
"your status file, so the plugin can "
(strcasecmp("Compression", key) == 0)) /* old, deprecated name */
{
if (IS_FALSE(value))
- collect_compression = 0;
+ collect_compression = false;
else
- collect_compression = 1;
+ collect_compression = true;
} /* if (strcasecmp ("CollectCompression", key) == 0) */
else if (strcasecmp("ImprovedNamingSchema", key) == 0) {
if (IS_TRUE(value)) {
DEBUG("openvpn plugin: using the new naming schema");
- new_naming_schema = 1;
+ new_naming_schema = true;
} else {
- new_naming_schema = 0;
+ new_naming_schema = false;
}
} /* if (strcasecmp ("ImprovedNamingSchema", key) == 0) */
else if (strcasecmp("CollectUserCount", key) == 0) {
if (IS_TRUE(value))
- collect_user_count = 1;
+ collect_user_count = true;
else
- collect_user_count = 0;
+ collect_user_count = false;
} /* if (strcasecmp("CollectUserCount", key) == 0) */
else if (strcasecmp("CollectIndividualUsers", key) == 0) {
if (IS_FALSE(value))
- collect_individual_users = 0;
+ collect_individual_users = false;
else
- collect_individual_users = 1;
+ collect_individual_users = true;
} /* if (strcasecmp("CollectIndividualUsers", key) == 0) */
else {
return -1;
*/
static ovs_events_ctx_t ovs_events_ctx = {
.mutex = PTHREAD_MUTEX_INITIALIZER,
- .config = {.send_notification = 1, /* send notification by default */
+ .config = {.send_notification = true, /* send notification by default */
.ovs_db_node = "localhost", /* use default OVS DB node */
.ovs_db_serv = "6640"} /* use default OVS DB service */
};
* in allocated memory. Returns negative value in case of error.
*/
static int ovs_events_plugin_config(oconfig_item_t *ci) {
- bool dispatch_values = 0;
+ bool dispatch_values = false;
for (int i = 0; i < ci->children_num; i++) {
oconfig_item_t *child = ci->children + i;
if (strcasecmp("SendNotification", child->key) == 0) {
return;
}
}
- OVS_EVENTS_CTX_LOCK { ovs_events_ctx.is_db_available = 1; }
+ OVS_EVENTS_CTX_LOCK { ovs_events_ctx.is_db_available = true; }
DEBUG(OVS_EVENTS_PLUGIN ": OVS DB connection has been initialized");
}
if (ovs_events_ctx.config.send_notification)
ovs_events_dispatch_terminate_notification(msg);
WARNING(OVS_EVENTS_PLUGIN ": %s", msg);
- OVS_EVENTS_CTX_LOCK { ovs_events_ctx.is_db_available = 0; }
+ OVS_EVENTS_CTX_LOCK { ovs_events_ctx.is_db_available = false; }
}
/* Read OVS DB interface link status callback */
static int ovs_events_plugin_read(__attribute__((unused)) user_data_t *u) {
- bool is_connected = 0;
+ bool is_connected = false;
OVS_EVENTS_CTX_LOCK { is_connected = ovs_events_ctx.is_db_available; }
if (is_connected)
if (ovs_db_send_request(ovs_events_ctx.ovs_db, "transact",
return 0;
old_running = t->running;
- t->running = 1;
+ t->running = true;
if (t->shutdown) {
t->running = old_running;
/* Mark as running to avoid deadlock:
c_ithread_destroy -> log_debug -> perl_log()
*/
- ithread->running = 1;
+ ithread->running = true;
log_debug("Shutting down Perl interpreter %p...", aTHX);
#if COLLECT_DEBUG
}
t->pthread = pthread_self();
- t->running = 0;
- t->shutdown = 0;
+ t->running = false;
+ t->shutdown = false;
perl_threads->tail = t;
pthread_setspecific(perl_thr_key, (const void *)t);
* the thread as this will free the memory */
t = t->prev;
- thr->shutdown = 1;
+ thr->shutdown = true;
if (thr->running) {
/* Give some time to thread to exit from Perl interpreter */
WARNING("perl shutdown: Thread is running inside Perl. Waiting.");
for (int i = 0; i < PFRES_MAX; i++)
pf_submit("pf_counters", pf_reasons[i], state.counters[i],
- /* is gauge = */ 0);
+ /* is gauge = */ false);
for (int i = 0; i < LCNT_MAX; i++)
pf_submit("pf_limits", pf_lcounters[i], state.lcounters[i],
- /* is gauge = */ 0);
+ /* is gauge = */ false);
for (int i = 0; i < FCNT_MAX; i++)
pf_submit("pf_state", pf_fcounters[i], state.fcounters[i],
- /* is gauge = */ 0);
+ /* is gauge = */ false);
for (int i = 0; i < SCNT_MAX; i++)
pf_submit("pf_source", pf_scounters[i], state.scounters[i],
- /* is gauge = */ 0);
+ /* is gauge = */ false);
pf_submit("pf_states", "current", (uint32_t)state.states,
- /* is gauge = */ 1);
+ /* is gauge = */ true);
return 0;
} /* int pf_read */
receive_loop();
memset(&collector_thread_id, 0, sizeof(collector_thread_id));
- collector_thread_running = 0;
+ collector_thread_running = false;
pthread_exit(NULL);
return NULL;
} /* }}} void *collector_thread */
ERROR("pinba plugin: pthread_create(3) failed: %s", STRERRNO);
return -1;
}
- collector_thread_running = 1;
+ collector_thread_running = true;
return 0;
} /* }}} */
int status;
DEBUG("pinba plugin: Shutting down collector thread.");
- collector_thread_do_shutdown = 1;
+ collector_thread_do_shutdown = true;
status = pthread_join(collector_thread_id, /* retval = */ NULL);
if (status != 0) {
ERROR("pinba plugin: pthread_join(3) failed: %s", STRERROR(status));
}
- collector_thread_running = 0;
- collector_thread_do_shutdown = 0;
+ collector_thread_running = false;
+ collector_thread_do_shutdown = false;
} /* if (collector_thread_running) */
return 0;
pthread_mutex_lock(&ping_lock);
while (ping_thread_loop > 0) {
- bool send_successful = 0;
+ bool send_successful = false;
if (gettimeofday(&tv_begin, NULL) < 0) {
ERROR("ping plugin: gettimeofday failed: %s", STRERRNO);
ping_get_error(pingobj));
} else {
c_release(LOG_NOTICE, &complaint, "ping plugin: ping_send succeeded.");
- send_successful = 1;
+ send_successful = true;
}
pthread_mutex_lock(&ping_lock);
} /* c_psql_connect */
static int c_psql_check_connection(c_psql_database_t *db) {
- bool init = 0;
+ bool init = false;
if (!db->conn) {
- init = 1;
+ init = true;
/* trigger c_release() */
if (0 == db->conn_complaint.interval)
} /* c_psql_flush */
static int c_psql_shutdown(void) {
- bool had_flush = 0;
+ bool had_flush = false;
plugin_unregister_read_group("postgresql");
if (!had_flush) {
plugin_unregister_flush("postgresql");
- had_flush = 1;
+ had_flush = true;
}
plugin_unregister_flush(cb_name);
writer->name = sstrdup(ci->values[0].value.string);
writer->statement = NULL;
- writer->store_rates = 1;
+ writer->store_rates = true;
for (int i = 0; i < ci->children_num; ++i) {
oconfig_item_t *c = ci->children + i;
if (!have_flush) {
/* flush all */
plugin_register_flush("postgresql", c_psql_flush, /* user data = */ NULL);
- have_flush = 1;
+ have_flush = true;
}
/* flush this connection only */
#endif
static void ps_fill_details(const procstat_t *ps, process_entry_t *entry) {
- if (entry->has_io == 0) {
+ if (entry->has_io == false) {
ps_read_io(entry);
- entry->has_io = 1;
+ entry->has_io = true;
}
if (ps->report_ctx_switch) {
- if (entry->has_cswitch == 0) {
+ if (entry->has_cswitch == false) {
ps_read_tasks_status(entry);
- entry->has_cswitch = 1;
+ entry->has_cswitch = true;
}
}
if (ps->report_maps_num) {
int num_maps;
- if (entry->has_maps == 0 && (num_maps = ps_count_maps(entry->id)) > 0) {
+ if (entry->has_maps == false && (num_maps = ps_count_maps(entry->id)) > 0) {
entry->num_maps = num_maps;
}
- entry->has_maps = 1;
+ entry->has_maps = true;
}
if (ps->report_fd_num) {
int num_fd;
- if (entry->has_fd == 0 && (num_fd = ps_count_fd(entry->id)) > 0) {
+ if (entry->has_fd == false && (num_fd = ps_count_fd(entry->id)) > 0) {
entry->num_fd = num_fd;
}
- entry->has_fd = 1;
+ entry->has_fd = true;
}
#if HAVE_LIBTASKSTATS
if (ps->report_delay && !entry->has_delay) {
if (ps_delay(entry) == 0) {
- entry->has_delay = 1;
+ entry->has_delay = true;
}
}
#endif
read_fork_rate();
#endif /* KERNEL_SOLARIS */
- want_init = 0;
+ want_init = false;
return 0;
} /* int ps_read */
static int rc_read(void) {
int status;
rrdc_stats_t *head;
- bool retried = 0;
+ bool retried = false;
value_list_t vl = VALUE_LIST_INIT;
vl.values = &(value_t){.gauge = NAN};
break;
if (!retried) {
- retried = 1;
+ retried = true;
if (try_reconnect() == 0)
continue;
/* else: report the error and fail */
char values[512];
char *values_array[2];
int status;
- bool retried = 0;
+ bool retried = false;
if (daemon_address == NULL) {
ERROR("rrdcached plugin: daemon_address == NULL.");
break;
if (!retried) {
- retried = 1;
+ retried = true;
if (try_reconnect() == 0)
continue;
/* else: report the error and fail */
__attribute__((unused)) user_data_t *ud) {
char filename[PATH_MAX + 1];
int status;
- bool retried = 0;
+ bool retried = false;
if (identifier == NULL)
return EINVAL;
break;
if (!retried) {
- retried = 1;
+ retried = true;
if (try_reconnect() == 0)
continue;
/* else: report the error and fail */
}
#if (SENSORS_API_VERSION >= 0x400) && (SENSORS_API_VERSION < 0x500)
else if (strcasecmp(key, "UseLabels") == 0) {
- use_labels = IS_TRUE(value) ? 1 : 0;
+ use_labels = IS_TRUE(value);
}
#endif
else {
while (fgets(buffer, sizeof(buffer), fh) != NULL) {
derive_t rx = 0;
derive_t tx = 0;
- bool have_rx = 0, have_tx = 0;
+ bool have_rx = false;
+ bool have_tx = false;
size_t len;
char *fields[16];
if (strncmp(fields[i], "tx:", 3) == 0) {
if (strtoderive(fields[i] + 3, &tx) == 0)
- have_tx = 1;
+ have_tx = true;
} else if (strncmp(fields[i], "rx:", 3) == 0) {
if (strtoderive(fields[i] + 3, &rx) == 0)
- have_rx = 1;
+ have_rx = true;
}
}
DEBUG("snmp plugin: dd = { name = %s, type = %s, is_table = %s, values_len = "
"%" PRIsz " }",
- dd->name, dd->type, (dd->is_table != 0) ? "true" : "false",
- dd->values_len);
+ dd->name, dd->type, (dd->is_table) ? "true" : "false", dd->values_len);
if (data_head == NULL)
data_head = dd;
return status;
}
}
- network_thread_running = 1;
+ network_thread_running = true;
pthread_mutex_unlock(&metrics_lock);
void *value;
if (network_thread_running) {
- network_thread_shutdown = 1;
+ network_thread_shutdown = true;
pthread_kill(network_thread, SIGTERM);
pthread_join(network_thread, /* retval = */ NULL);
}
- network_thread_running = 0;
+ network_thread_running = false;
pthread_mutex_lock(&metrics_lock);
sstrncpy(vl.type, "swap", sizeof(vl.type));
if (values_absolute)
- plugin_dispatch_multivalue(&vl, 0, DS_TYPE_GAUGE, "used", used, "free",
+ plugin_dispatch_multivalue(&vl, false, DS_TYPE_GAUGE, "used", used, "free",
free, other_name, other_value, NULL);
if (values_percentage)
- plugin_dispatch_multivalue(&vl, 1, DS_TYPE_GAUGE, "used", used, "free",
+ plugin_dispatch_multivalue(&vl, true, DS_TYPE_GAUGE, "used", used, "free",
free, other_name, other_value, NULL);
} /* }}} void swap_submit_usage */
FILE *fh;
char buffer[1024];
- bool old_kernel = 0;
+ bool old_kernel = false;
uint8_t have_data = 0;
derive_t swap_in = 0;
WARNING("swap: fopen: %s", STRERRNO);
return -1;
} else
- old_kernel = 1;
+ old_kernel = true;
}
while (fgets(buffer, sizeof(buffer), fh) != NULL) {
return -1;
}
- /* If the "separate" option was specified (report_by_device == 1), all
+ /* If the "separate" option was specified (report_by_device == true) all
* values have already been dispatched from within the loop. */
if (!report_by_device)
swap_submit_usage(NULL, total - avail, avail, NULL, NAN);
static bool tcsv_check_index(ssize_t index, size_t fields_num,
char const *name) {
if (index < 0)
- return 1;
+ return true;
else if (((size_t)index) < fields_num)
- return 1;
+ return true;
ERROR("tail_csv plugin: Metric \"%s\": Request for index %zd when "
"only %" PRIsz " fields are available.",
name, index, fields_num);
- return 0;
+ return false;
}
static int tcsv_read_buffer(instance_definition_t *id, char *buffer,
DEBUG("target_replace plugin: tr_action_invoke: -- buffer = %s;", buffer);
} /* for (act = act_head; act != NULL; act = act->next) */
- if ((may_be_empty == 0) && (buffer[0] == 0)) {
+ if ((may_be_empty == false) && (buffer[0] == 0)) {
WARNING("Target `replace': Replacement resulted in an empty string, "
"which is not allowed for this buffer (`host' or `plugin').");
return 0;
if ((strcasecmp("Host", child->key) == 0) ||
(strcasecmp("Hostname", child->key) == 0))
status = tr_config_add_action(&data->host, child,
- /* may be empty = */ 0);
+ /* may be empty = */ false);
else if (strcasecmp("Plugin", child->key) == 0)
status = tr_config_add_action(&data->plugin, child,
- /* may be empty = */ 0);
+ /* may be empty = */ false);
else if (strcasecmp("PluginInstance", child->key) == 0)
status = tr_config_add_action(&data->plugin_instance, child,
- /* may be empty = */ 1);
+ /* may be empty = */ true);
#if 0
else if (strcasecmp ("Type", child->key) == 0)
status = tr_config_add_action (&data->type, child,
#endif
else if (strcasecmp("TypeInstance", child->key) == 0)
status = tr_config_add_action(&data->type_instance, child,
- /* may be empty = */ 1);
+ /* may be empty = */ true);
else if (strcasecmp("MetaData", child->key) == 0)
status = tr_config_add_meta_action(&data->meta, child,
- /* should delete = */ 0);
+ /* should delete = */ false);
else if (strcasecmp("DeleteMetaData", child->key) == 0)
status = tr_config_add_meta_action(&data->meta, child,
- /* should delete = */ 1);
+ /* should delete = */ true);
else {
ERROR("Target `replace': The `%s' configuration option is not understood "
"and will be ignored.",
#define HANDLE_FIELD(f, e) \
if (data->f != NULL) \
tr_action_invoke(data->f, vl->f, sizeof(vl->f), e)
- HANDLE_FIELD(host, 0);
- HANDLE_FIELD(plugin, 0);
- HANDLE_FIELD(plugin_instance, 1);
- /* HANDLE_FIELD (type, 0); */
- HANDLE_FIELD(type_instance, 1);
+ HANDLE_FIELD(host, false);
+ HANDLE_FIELD(plugin, false);
+ HANDLE_FIELD(plugin_instance, true);
+ /* HANDLE_FIELD (type, false); */
+ HANDLE_FIELD(type_instance, true);
return FC_TARGET_CONTINUE;
} /* }}} int tr_invoke */
return FC_TARGET_STOP;
if (strcmp("hits", vl->type_instance) == 0)
- is_hits = 1;
+ is_hits = true;
else if (strcmp("misses", vl->type_instance) == 0)
- is_hits = 0;
+ is_hits = false;
else
return FC_TARGET_STOP;
const char *name,
void __attribute__((unused)) * user_data) {
char filename[PATH_MAX];
- bool success = 0;
+ bool success = false;
value_t value;
if (device_list && ignorelist_match(device_list, name))
if (parse_value_file(filename, &value, DS_TYPE_GAUGE) == 0) {
value.gauge /= 1000.0;
thermal_submit(name, TEMP, value);
- success = 1;
+ success = true;
}
snprintf(filename, sizeof(filename), "%s/%s/cur_state", dirname_sysfs, name);
if (parse_value_file(filename, &value, DS_TYPE_GAUGE) == 0) {
thermal_submit(name, COOLING_DEV, value);
- success = 1;
+ success = true;
}
return success ? 0 : -1;
if (IS_TRUE(value))
ignorelist_set_invert(device_list, 0);
} else if (strcasecmp(key, "ForceUseProcfs") == 0) {
- force_procfs = 0;
+ force_procfs = false;
if (IS_TRUE(value))
- force_procfs = 1;
+ force_procfs = true;
} else {
return -1;
}
/*
* Open a MSR device for reading
* Can change the scheduling affinity of the current process if multiple_read is
- * 1
+ * true
*/
static int __attribute__((warn_unused_result))
open_msr(unsigned int cpu, bool multiple_read) {
"the entire interval. Fix this by running "
"Linux-2.6.30 or later.");
- aperf_mperf_unstable = 1;
+ aperf_mperf_unstable = true;
}
}
switch (model) {
/* Atom (partial) */
case 0x27:
- do_smi = 0;
+ do_smi = false;
do_core_cstate = 0;
do_pkg_cstate = (1 << 2) | (1 << 4) | (1 << 6);
break;
/* Silvermont */
case 0x37: /* BYT */
case 0x4D: /* AVN */
- do_smi = 1;
+ do_smi = true;
do_core_cstate = (1 << 1) | (1 << 6);
do_pkg_cstate = (1 << 6);
break;
Forest */
case 0x1F: /* Core i7 and i5 Processor - Nehalem */
case 0x2E: /* Nehalem-EX Xeon - Beckton */
- do_smi = 1;
+ do_smi = true;
do_core_cstate = (1 << 3) | (1 << 6);
do_pkg_cstate = (1 << 3) | (1 << 6) | (1 << 7);
break;
case 0x25: /* Westmere Client - Clarkdale, Arrandale */
case 0x2C: /* Westmere EP - Gulftown */
case 0x2F: /* Westmere-EX Xeon - Eagleton */
- do_smi = 1;
+ do_smi = true;
do_core_cstate = (1 << 3) | (1 << 6);
do_pkg_cstate = (1 << 3) | (1 << 6) | (1 << 7);
break;
/* Sandy Bridge */
case 0x2A: /* SNB */
case 0x2D: /* SNB Xeon */
- do_smi = 1;
+ do_smi = true;
do_core_cstate = (1 << 3) | (1 << 6) | (1 << 7);
do_pkg_cstate = (1 << 2) | (1 << 3) | (1 << 6) | (1 << 7);
break;
/* Ivy Bridge */
case 0x3A: /* IVB */
case 0x3E: /* IVB Xeon */
- do_smi = 1;
+ do_smi = true;
do_core_cstate = (1 << 3) | (1 << 6) | (1 << 7);
do_pkg_cstate = (1 << 2) | (1 << 3) | (1 << 6) | (1 << 7);
break;
case 0x3C: /* HSW */
case 0x3F: /* HSW */
case 0x46: /* HSW */
- do_smi = 1;
+ do_smi = true;
do_core_cstate = (1 << 3) | (1 << 6) | (1 << 7);
do_pkg_cstate = (1 << 2) | (1 << 3) | (1 << 6) | (1 << 7);
break;
case 0x45: /* HSW */
- do_smi = 1;
+ do_smi = true;
do_core_cstate = (1 << 3) | (1 << 6) | (1 << 7);
do_pkg_cstate = (1 << 2) | (1 << 3) | (1 << 6) | (1 << 7) | (1 << 8) |
(1 << 9) | (1 << 10);
break;
- /* Broadwel */
+ /* Broadwell */
case 0x4F: /* BDW */
case 0x56: /* BDX-DE */
- do_smi = 1;
+ do_smi = true;
do_core_cstate = (1 << 3) | (1 << 6) | (1 << 7);
do_pkg_cstate = (1 << 2) | (1 << 3) | (1 << 6) | (1 << 7);
break;
case 0x3D: /* BDW */
- do_smi = 1;
+ do_smi = true;
do_core_cstate = (1 << 3) | (1 << 6) | (1 << 7);
do_pkg_cstate = (1 << 2) | (1 << 3) | (1 << 6) | (1 << 7) | (1 << 8) |
(1 << 9) | (1 << 10);
break;
default:
- do_smi = 0;
+ do_smi = false;
do_core_cstate = 0;
do_pkg_cstate = 0;
break;
if (ret < 0)
goto err;
else if ((unsigned int)ret == i)
- cpu->first_core_in_package = 1;
+ cpu->first_core_in_package = true;
ret = get_threads_on_core(i);
if (ret < 0)
if (ret < 0)
goto err;
else if ((unsigned int)ret == i)
- cpu->first_thread_in_core = 1;
+ cpu->first_thread_in_core = true;
DEBUG("turbostat plugin: cpu %d pkg %d core %d\n", i, cpu->package_id,
cpu->core_id);
}
static void free_all_buffers(void) {
- allocated = 0;
- initialized = 0;
+ allocated = false;
+ initialized = false;
CPU_FREE(cpu_present_set);
cpu_present_set = NULL;
DO_OR_GOTO_ERR(for_all_cpus(set_temperature_target, EVEN_COUNTERS));
DO_OR_GOTO_ERR(for_all_cpus(set_temperature_target, ODD_COUNTERS));
- allocated = 1;
+ allocated = true;
return 0;
err:
free_all_buffers();
if ((ret = for_all_cpus(get_counters, EVEN_COUNTERS)) < 0)
goto out;
time_even = cdtime();
- is_even = 1;
- initialized = 1;
+ is_even = true;
+ initialized = true;
ret = 0;
goto out;
}
if ((ret = for_all_cpus(get_counters, ODD_COUNTERS)) < 0)
goto out;
time_odd = cdtime();
- is_even = 0;
+ is_even = false;
time_delta = time_odd - time_even;
if ((ret = for_all_cpus_delta(ODD_COUNTERS, EVEN_COUNTERS)) < 0)
goto out;
if ((ret = for_all_cpus(get_counters, EVEN_COUNTERS)) < 0)
goto out;
time_even = cdtime();
- is_even = 1;
+ is_even = true;
time_delta = time_even - time_odd;
if ((ret = for_all_cpus_delta(EVEN_COUNTERS, ODD_COUNTERS)) < 0)
goto out;
return -1;
}
config_core_cstate = (unsigned int)tmp_val;
- apply_config_core_cstate = 1;
+ apply_config_core_cstate = true;
} else if (strcasecmp("PackageCstates", key) == 0) {
tmp_val = strtoul(value, &end, 0);
if (*end != '\0' || tmp_val > UINT_MAX) {
return -1;
}
config_pkg_cstate = (unsigned int)tmp_val;
- apply_config_pkg_cstate = 1;
+ apply_config_pkg_cstate = true;
} else if (strcasecmp("SystemManagementInterrupt", key) == 0) {
config_smi = IS_TRUE(value);
- apply_config_smi = 1;
+ apply_config_smi = true;
} else if (strcasecmp("DigitalTemperatureSensor", key) == 0) {
config_dts = IS_TRUE(value);
- apply_config_dts = 1;
+ apply_config_dts = true;
} else if (strcasecmp("PackageThermalManagement", key) == 0) {
config_ptm = IS_TRUE(value);
- apply_config_ptm = 1;
+ apply_config_ptm = true;
} else if (strcasecmp("LogicalCoreNames", key) == 0) {
config_lcn = IS_TRUE(value);
} else if (strcasecmp("RunningAveragePowerLimit", key) == 0) {
return -1;
}
config_rapl = (unsigned int)tmp_val;
- apply_config_rapl = 1;
+ apply_config_rapl = true;
} else if (strcasecmp("TCCActivationTemp", key) == 0) {
tmp_val = strtoul(value, &end, 0);
if (*end != '\0' || tmp_val > UINT_MAX) {
sock_perms = (int)strtol(val, NULL, 8);
} else if (strcasecmp(key, "DeleteSocket") == 0) {
if (IS_TRUE(val))
- delete_socket = 1;
+ delete_socket = true;
else
- delete_socket = 0;
+ delete_socket = false;
} else {
return -1;
}
escape_string(buffer_ident, sizeof(buffer_ident));
status = format_values(buffer_values, sizeof(buffer_values), ds, vl,
- /* store rates = */ 0);
+ /* store rates = */ false);
if (status != 0)
return status;
escape_string(buffer_values, sizeof(buffer_values));
if (postfix == NULL)
postfix = "";
- bool preserve_separator = (flags & GRAPHITE_PRESERVE_SEPARATOR) ? 1 : 0;
+ bool preserve_separator = (flags & GRAPHITE_PRESERVE_SEPARATOR);
gr_copy_escape_part(n_host, vl->host, sizeof(n_host), escape_char,
preserve_separator);
if (meta_data_get_double(meta, key, &value) == 0)
BUFFER_ADD(",\"%s\":%f", key, value);
} else if (type == MD_TYPE_BOOLEAN) {
- bool value = 0;
+ bool value = false;
if (meta_data_get_boolean(meta, key, &value) == 0)
BUFFER_ADD(",\"%s\":%s", key, value ? "true" : "false");
}
if (match->is_regex) {
/* Short cut popular catch-all regex. */
if (strcmp(".*", match->str) == 0)
- return 1;
+ return true;
int status = regexec(&match->regex, str,
/* nmatch = */ 0, /* pmatch = */ NULL,
/* flags = */ 0);
if (status == 0)
- return 1;
+ return true;
else
- return 0;
+ return false;
} else if (strcmp(match->str, str) == 0)
- return 1;
+ return true;
else
- return 0;
+ return false;
} /* }}} bool lu_part_matches */
static int lu_copy_ident_to_match_part(part_match_t *match_part, /* {{{ */
if ((len < 3) || (ident_part[0] != '/') || (ident_part[len - 1] != '/')) {
sstrncpy(match_part->str, ident_part, sizeof(match_part->str));
- match_part->is_regex = 0;
+ match_part->is_regex = false;
return 0;
}
match_part->str, errbuf);
return EINVAL;
}
- match_part->is_regex = 1;
+ match_part->is_regex = true;
return 0;
} /* }}} int lu_copy_ident_to_match_part */
do { \
if (user_class_list->entry.match.field.is_regex) { \
regfree(&user_class_list->entry.match.field.regex); \
- user_class_list->entry.match.field.is_regex = 0; \
+ user_class_list->entry.match.field.is_regex = false; \
} \
} while (0)
by_type_entry_t *by_type = NULL;
user_class_list_t *user_class_obj;
- by_type = lu_search_by_type(obj, ident->type, /* allocate = */ 1);
+ by_type = lu_search_by_type(obj, ident->type, /* allocate = */ true);
if (by_type == NULL)
return -1;
if ((obj == NULL) || (ds == NULL) || (vl == NULL))
return -EINVAL;
- by_type = lu_search_by_type(obj, vl->type, /* allocate = */ 0);
+ by_type = lu_search_by_type(obj, vl->type, /* allocate = */ false);
if (by_type == NULL)
return 0;
strncpy(obj->type, vl->type, sizeof(obj->type));
strncpy(obj->type_instance, vl->type_instance, sizeof(obj->type_instance));
- have_new_obj = 1;
+ have_new_obj = true;
return (void *)obj;
}
ds = &ds_test;
expect_new_obj = expect_new;
- have_new_obj = 0;
+ have_new_obj = false;
status = lookup_search(obj, ds, &vl);
return status;
if (conf == NULL)
return EINVAL;
- conf->collect_backend = 1;
- conf->collect_cache = 1;
- conf->collect_connections = 1;
+ conf->collect_backend = true;
+ conf->collect_cache = true;
+ conf->collect_connections = true;
#ifdef HAVE_VARNISH_V3
- conf->collect_dirdns = 0;
+ conf->collect_dirdns = false;
#endif
- conf->collect_esi = 0;
- conf->collect_fetch = 0;
- conf->collect_hcb = 0;
- conf->collect_objects = 0;
+ conf->collect_esi = false;
+ conf->collect_fetch = false;
+ conf->collect_hcb = false;
+ conf->collect_objects = false;
#if HAVE_VARNISH_V2
- conf->collect_purge = 0;
+ conf->collect_purge = false;
#else
- conf->collect_ban = 0;
+ conf->collect_ban = false;
#endif
- conf->collect_session = 0;
- conf->collect_shm = 1;
+ conf->collect_session = false;
+ conf->collect_shm = true;
#if HAVE_VARNISH_V2
- conf->collect_sm = 0;
+ conf->collect_sm = false;
#endif
#if HAVE_VARNISH_V2 || HAVE_VARNISH_V4 || HAVE_VARNISH_V5
- conf->collect_sma = 0;
+ conf->collect_sma = false;
#endif
- conf->collect_sms = 0;
- conf->collect_struct = 0;
- conf->collect_totals = 0;
+ conf->collect_sms = false;
+ conf->collect_struct = false;
+ conf->collect_totals = false;
#if HAVE_VARNISH_V3 || HAVE_VARNISH_V4 || HAVE_VARNISH_V5
- conf->collect_uptime = 0;
+ conf->collect_uptime = false;
#endif
- conf->collect_vcl = 0;
- conf->collect_workers = 0;
+ conf->collect_vcl = false;
+ conf->collect_workers = false;
#if HAVE_VARNISH_V4 || HAVE_VARNISH_V5
- conf->collect_vsm = 0;
- conf->collect_lck = 0;
- conf->collect_mempool = 0;
- conf->collect_mgt = 0;
- conf->collect_smf = 0;
- conf->collect_vbe = 0;
- conf->collect_mse = 0;
+ conf->collect_vsm = false;
+ conf->collect_lck = false;
+ conf->collect_mempool = false;
+ conf->collect_mgt = false;
+ conf->collect_smf = false;
+ conf->collect_vbe = false;
+ conf->collect_mse = false;
#endif
return 0;
.data = conf, .free_func = varnish_config_free,
});
- have_instance = 1;
+ have_instance = true;
return 0;
} /* }}} int varnish_config_instance */
};
/* BlockDeviceFormatBasename */
-bool blockdevice_format_basename = 0;
+static bool blockdevice_format_basename;
static enum bd_field blockdevice_format = target;
static enum if_field interface_format = if_name;
unsigned char *cpu_maps, int cpu_map_len) {
for (int cpu = 0; cpu < max_cpus; ++cpu) {
char type_instance[DATA_MAX_NAME_LEN];
- bool is_set = VIR_CPU_USABLE(cpu_maps, cpu_map_len, vcpu, cpu) ? 1 : 0;
+ bool is_set = VIR_CPU_USABLE(cpu_maps, cpu_map_len, vcpu, cpu);
snprintf(type_instance, sizeof(type_instance), "vcpu_%d-cpu_%d", vcpu, cpu);
submit(dom, "cpu_affinity", type_instance, &(value_t){.gauge = is_set}, 1);
#endif
#ifndef WG_DEFAULT_LOG_SEND_ERRORS
-#define WG_DEFAULT_LOG_SEND_ERRORS 1
+#define WG_DEFAULT_LOG_SEND_ERRORS true
#endif
#ifndef WG_DEFAULT_ESCAPE
close(cb->sock_fd);
cb->sock_fd = -1;
cb->last_reconnect_time = now;
- cb->reconnect_interval_reached = 1;
+ cb->reconnect_interval_reached = true;
INFO("write_graphite plugin: Connection closed after %.3f seconds.",
CDTIME_T_TO_DOUBLE(now - cb->last_reconnect_time));
if (!cb->reconnect_interval_reached || (cb->send_buf_free == 0))
wg_reset_buffer(cb);
else
- cb->reconnect_interval_reached = 0;
+ cb->reconnect_interval_reached = false;
return 0;
}
cb->protocol = strdup(WG_DEFAULT_PROTOCOL);
cb->last_reconnect_time = cdtime();
cb->reconnect_interval = 0;
- cb->reconnect_interval_reached = 0;
+ cb->reconnect_interval_reached = false;
cb->log_send_errors = WG_DEFAULT_LOG_SEND_ERRORS;
cb->prefix = NULL;
cb->postfix = NULL;
ERROR("write_http plugin: calloc failed.");
return -1;
}
- cb->verify_peer = 1;
- cb->verify_host = 1;
+ cb->verify_peer = true;
+ cb->verify_host = true;
cb->format = WH_FORMAT_COMMAND;
cb->sslversion = CURL_SSLVERSION_DEFAULT;
cb->low_speed_limit = 0;
cb->timeout = 0;
- cb->log_http_error = 0;
+ cb->log_http_error = false;
cb->headers = NULL;
- cb->send_metrics = 1;
- cb->send_notifications = 0;
+ cb->send_metrics = true;
+ cb->send_notifications = false;
cb->data_ttl = 0;
cb->metrics_prefix = strdup(WRITE_HTTP_DEFAULT_PREFIX);
}
tctx->escape_char = '.';
- tctx->store_rates = 1;
+ tctx->store_rates = true;
tctx->format = KAFKA_FORMAT_JSON;
tctx->key = NULL;
static int wl_config(oconfig_item_t *ci) /* {{{ */
{
- bool format_seen = 0;
+ bool format_seen = false;
for (int i = 0; i < ci->children_num; i++) {
oconfig_item_t *child = ci->children + i;
if (format_seen) {
WARNING("write_log plugin: Redefining option `%s'.", child->key);
}
- format_seen = 1;
+ format_seen = true;
if (strcasecmp("Graphite", str) == 0)
wl_format = WL_FORMAT_GRAPHITE;
"authentication string.");
mongoc_client_destroy(node->client);
node->client = NULL;
- node->connected = 0;
+ node->connected = false;
return -1;
}
ERROR("write_mongodb plugin: Authenticating to [%s]:%d for database "
"\"%s\" as user \"%s\" failed.",
node->host, node->port, node->db, node->user);
- node->connected = 0;
+ node->connected = false;
sfree(uri);
return -1;
}
"authentication string.");
mongoc_client_destroy(node->client);
node->client = NULL;
- node->connected = 0;
+ node->connected = false;
return -1;
}
if (!node->client) {
ERROR("write_mongodb plugin: Connecting to [%s]:%d failed.", node->host,
node->port);
- node->connected = 0;
+ node->connected = false;
sfree(uri);
return -1;
}
ERROR("write_mongodb plugin: error creating/getting database");
mongoc_client_destroy(node->client);
node->client = NULL;
- node->connected = 0;
+ node->connected = false;
return -1;
}
- node->connected = 1;
+ node->connected = true;
return 0;
} /* }}} int wm_initialize */
mongoc_client_destroy(node->client);
node->database = NULL;
node->client = NULL;
- node->connected = 0;
+ node->connected = false;
pthread_mutex_unlock(&node->lock);
bson_destroy(bson_record);
return -1;
mongoc_client_destroy(node->client);
node->database = NULL;
node->client = NULL;
- node->connected = 0;
+ node->connected = false;
pthread_mutex_unlock(&node->lock);
bson_destroy(bson_record);
mongoc_collection_destroy(collection);
mongoc_client_destroy(node->client);
node->database = NULL;
node->client = NULL;
- node->connected = 0;
+ node->connected = false;
sfree(node->host);
sfree(node);
return ENOMEM;
}
node->port = MONGOC_DEFAULT_PORT;
- node->store_rates = 1;
+ node->store_rates = true;
pthread_mutex_init(&node->lock, /* attr = */ NULL);
status = cf_util_get_string_buffer(ci, node->name, sizeof(node->name));
for (size_t i = 0; i < ds->ds_num; i++) {
Io__Prometheus__Client__MetricFamily *fam =
- metric_family_get(ds, vl, i, /* allocate = */ 1);
+ metric_family_get(ds, vl, i, /* allocate = */ true);
if (fam == NULL)
continue;
for (size_t i = 0; i < ds->ds_num; i++) {
Io__Prometheus__Client__MetricFamily *fam =
- metric_family_get(ds, vl, i, /* allocate = */ 0);
+ metric_family_get(ds, vl, i, /* allocate = */ false);
if (fam == NULL)
continue;
node->database = 0;
node->max_set_size = -1;
node->max_set_duration = -1;
- node->store_rates = 1;
+ node->store_rates = true;
pthread_mutex_init(&node->lock, /* attr = */ NULL);
status = cf_util_get_string_buffer(ci, node->name, sizeof(node->name));
host->reference_count = 1;
host->node = NULL;
host->port = 0;
- host->notifications = 1;
- host->check_thresholds = 0;
- host->store_rates = 1;
- host->always_append_ds = 0;
- host->batch_mode = 1;
+ host->notifications = true;
+ host->check_thresholds = false;
+ host->store_rates = true;
+ host->always_append_ds = false;
+ host->batch_mode = true;
host->batch_max = RIEMANN_BATCH_MAX; /* typical MSS */
host->batch_init = cdtime();
host->batch_timeout = 0;
host->reference_count = 1;
host->node = NULL;
host->service = NULL;
- host->notifications = 0;
- host->metrics = 0;
- host->store_rates = 1;
- host->always_append_ds = 0;
+ host->notifications = false;
+ host->metrics = false;
+ host->store_rates = true;
+ host->always_append_ds = false;
host->metric_handlers.nb_strs = 0;
host->metric_handlers.strs = NULL;
host->notification_handlers.nb_strs = 0;
return -1;
}
- if ((host->notification_handlers.nb_strs > 0) && (host->notifications == 0)) {
+ if ((host->notification_handlers.nb_strs > 0) &&
+ (host->notifications == false)) {
WARNING("write_sensu plugin: NotificationHandler given so forcing "
"notifications to be enabled");
host->notifications = 1;
}
- if ((host->metric_handlers.nb_strs > 0) && (host->metrics == 0)) {
+ if ((host->metric_handlers.nb_strs > 0) && (host->metrics == false)) {
WARNING("write_sensu plugin: MetricHandler given so forcing metrics to be "
"enabled");
- host->metrics = 1;
+ host->metrics = true;
}
if (!(host->notifications || host->metrics)) {