static const char *def_exchange = "amq.fanout";
static pthread_t *subscriber_threads;
-static size_t subscriber_threads_num = 0;
+static size_t subscriber_threads_num;
static bool subscriber_threads_running = true;
#define CONF(c, f) (((c)->f != NULL) ? (c)->f : def_##f)
static int camqp_connect(camqp_config_t *conf) /* {{{ */
{
- static time_t last_connect_time = 0;
+ static time_t last_connect_time;
amqp_rpc_reply_t reply;
int status;
static int global_sockfd = -1;
-static int count_retries = 0;
-static int count_iterations = 0;
+static int count_retries;
+static int count_iterations;
static int net_shutdown(int *fd) {
uint16_t packet_size = 0;
static CURL *curl;
static char *ascent_buffer;
-static size_t ascent_buffer_size = 0;
-static size_t ascent_buffer_fill = 0;
+static size_t ascent_buffer_size;
+static size_t ascent_buffer_fill;
static char ascent_curl_error[CURL_ERROR_SIZE];
static const char *config_keys[] = {
static char *config_device; /**< I2C bus device */
static int config_oversample = 1; /**< averaging window */
-static double config_press_offset = 0.0; /**< pressure offset */
-static double config_temp_offset = 0.0; /**< temperature offset */
+static double config_press_offset; /**< pressure offset */
+static double config_temp_offset; /**< temperature offset */
static double config_altitude = NAN; /**< altitude */
-static int config_normalize = 0; /**< normalization method */
+static int config_normalize; /**< normalization method */
static bool configured; /**< the whole plugin config status */
static enum Sensor_type sensor_type =
Sensor_none; /**< detected/used sensor type */
-static __s32 mpl3115_oversample = 0; /**< MPL3115 CTRL1 oversample setting */
+static __s32 mpl3115_oversample; /**< MPL3115 CTRL1 oversample setting */
// BMP085 configuration
static unsigned bmp085_oversampling; /**< BMP085 oversampling (0-3) */
static int global_qtypes = 1;
static int global_server_stats = 1;
static int global_zone_maint_stats = 1;
-static int global_resolver_stats = 0;
+static int global_resolver_stats;
static int global_memory_stats = 1;
static int timeout = -1;
static cb_view_t *views;
-static size_t views_num = 0;
+static size_t views_num;
static CURL *curl;
static char *bind_buffer;
-static size_t bind_buffer_size = 0;
-static size_t bind_buffer_fill = 0;
+static size_t bind_buffer_size;
+static size_t bind_buffer_fill;
static char bind_curl_error[CURL_ERROR_SIZE];
/* Translation table for the `nsstats' values. */
};
/** Give user option to use default (long run = since daemon started) avg */
-static int long_run_latency_avg = 0;
+static int long_run_latency_avg;
/**
* Give user option to use default type for special cases -
static struct ceph_daemon **g_daemons;
/** Number of elements in g_daemons */
-static size_t g_num_daemons = 0;
+static size_t g_num_daemons;
/**
* A set of data that we build up in memory while parsing the JSON.
static bool nan_is_error_g;
static char **match_ds_g;
-static size_t match_ds_num_g = 0;
+static size_t match_ds_num_g;
/* `strdup' is an XSI extension. I don't want to pull in all of XSI just for
* that, so here's an own implementation.. It's easy enough. The GCC attributes
#define WCOREDUMP(s) 0
#endif /* ! WCOREDUMP */
-static int loop = 0;
-static int restart = 0;
+static int loop;
+static int restart;
static const char *pidfile;
-static pid_t collectd_pid = 0;
+static pid_t collectd_pid;
__attribute__((noreturn)) static void exit_usage(const char *name) {
printf("Usage: %s <options> [-- <collectd options>]\n"
static void check_respawn(void) {
time_t t = time(NULL);
- static time_t timestamp = 0;
- static int counter = 0;
+ static time_t timestamp;
+ static int counter;
if ((t - 120) < timestamp)
++counter;
Each table/chain combo that will be queried goes into this list
*/
-static int old_files = 0;
+static int old_files;
static int conntrack_config(const char *key, const char *value) {
if (strcmp(key, "OldFiles") == 0)
typedef struct cpu_state_s cpu_state_t;
static cpu_state_t *cpu_states;
-static size_t cpu_states_num = 0; /* #cpu_states allocated */
+static size_t cpu_states_num; /* #cpu_states allocated */
/* Highest CPU number in the current iteration. Used by the dispatch logic to
* determine how many CPUs there were. Reset to 0 by cpu_reset(). */
-static size_t global_cpu_num = 0;
+static size_t global_cpu_num;
static bool report_by_cpu = true;
static bool report_by_state = true;
#include "common.h"
#include "plugin.h"
-static int num_cpu = 0;
+static int num_cpu;
static int cpufreq_init(void) {
int status;
static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
static char *datadir;
-static int store_rates = 0;
-static int use_stdio = 0;
+static int store_rates;
+static int use_stdio;
static int value_list_to_string(char *buffer, int buffer_len,
const data_set_t *ds, const value_list_t *vl) {
#define COLLECTD_LOCALE "C"
#endif
-static int loop = 0;
+static int loop;
static void *do_flush(void __attribute__((unused)) * arg) {
INFO("Flushing all data.");
static int fc_init_once(void) /* {{{ */
{
- static int done = 0;
+ static int done;
target_proc_t tproc = {0};
if (done != 0)
static pthread_mutex_t read_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t read_cond = PTHREAD_COND_INITIALIZER;
static pthread_t *read_threads;
-static size_t read_threads_num = 0;
+static size_t read_threads_num;
static cdtime_t max_read_interval = DEFAULT_MAX_READ_INTERVAL;
static write_queue_t *write_queue_head;
static write_queue_t *write_queue_tail;
-static long write_queue_length = 0;
+static long write_queue_length;
static bool write_loop = true;
static pthread_mutex_t write_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t write_cond = PTHREAD_COND_INITIALIZER;
static pthread_t *write_threads;
-static size_t write_threads_num = 0;
+static size_t write_threads_num;
static pthread_key_t plugin_ctx_key;
static bool plugin_ctx_key_initialized;
-static long write_limit_high = 0;
-static long write_limit_low = 0;
+static long write_limit_high;
+static long write_limit_low;
-static derive_t stats_values_dropped = 0;
+static derive_t stats_values_dropped;
static bool record_statistics;
/*
static bool check_drop_value(void) /* {{{ */
{
- static cdtime_t last_message_time = 0;
+ static cdtime_t last_message_time;
static pthread_mutex_t last_message_lock = PTHREAD_MUTEX_INITIALIZER;
double p;
* Florian octo Forster <octo at collectd.org>
*/
-#include "common.h" /* STATIC_ARRAY_SIZE */
#include "collectd.h"
+#include "common.h" /* STATIC_ARRAY_SIZE */
#include "testing.h"
#include "utils_avltree.h"
-static int compare_total_count = 0;
+static int compare_total_count;
+
#define RESET_COUNTS() \
do { \
compare_total_count = 0; \
* Global variables
*/
#if !defined(HAVE_LEGACY_LIBDBI) || !HAVE_LEGACY_LIBDBI
-static dbi_inst dbi_instance = 0;
+static dbi_inst dbi_instance;
#endif
static udb_query_t **queries;
-static size_t queries_num = 0;
+static size_t queries_num;
static cdbi_database_t **databases;
-static size_t databases_num = 0;
+static size_t databases_num;
static int cdbi_read_database(user_data_t *ud);
static int cdbi_init(void) /* {{{ */
{
- static int did_init = 0;
+ static int did_init;
int status;
if (did_init != 0)
#define MAX_NUMDISK 1024
extern kstat_ctl_t *kc;
static kstat_t *ksp[MAX_NUMDISK];
-static int numdisk = 0;
+static int numdisk;
/* #endif HAVE_LIBKSTAT */
#elif defined(HAVE_LIBSTATGRAB)
static counter_list_t *rcode_list;
static pthread_t listen_thread;
-static int listen_thread_init = 0;
+static int listen_thread_init;
/* The `traffic' mutex if for `tr_queries' and `tr_responses' */
static pthread_mutex_t traffic_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t qtype_mutex = PTHREAD_MUTEX_INITIALIZER;
static int max_conns = MAX_CONNS;
/* state of the plugin */
-static int disabled = 0;
+static int disabled;
/* thread managing "client" connections */
static pthread_t connector = (pthread_t)0;
typedef struct value_map_s value_map_t;
static char **interfaces;
-static size_t interfaces_num = 0;
+static size_t interfaces_num;
static c_avl_tree_t *value_map;
typedef struct fc_directory_conf_s fc_directory_conf_t;
static fc_directory_conf_t **directories;
-static size_t directories_num = 0;
+static size_t directories_num;
static void fc_free_dir(fc_directory_conf_t *dir) {
sfree(dir->path);
static char *mc_receive_port;
static struct pollfd *mc_receive_sockets;
-static size_t mc_receive_sockets_num = 0;
+static size_t mc_receive_sockets_num;
static socket_entry_t *mc_send_sockets;
-static size_t mc_send_sockets_num = 0;
+static size_t mc_send_sockets_num;
static pthread_mutex_t mc_send_sockets_lock = PTHREAD_MUTEX_INITIALIZER;
-static int mc_receive_thread_loop = 0;
-static int mc_receive_thread_running = 0;
+static int mc_receive_thread_loop;
+static int mc_receive_thread_running;
static pthread_t mc_receive_thread_id;
static metric_map_t metric_map_default[] =
static size_t metric_map_len_default = STATIC_ARRAY_SIZE(metric_map_default);
static metric_map_t *metric_map;
-static size_t metric_map_len = 0;
+static size_t metric_map_len;
static c_avl_tree_t *staging_tree;
static pthread_mutex_t staging_lock = PTHREAD_MUTEX_INITIALIZER;
#define MAX_NUMIF 256
extern kstat_ctl_t *kc;
static kstat_t *ksp[MAX_NUMIF];
-static int numif = 0;
+static int numif;
static bool unique_name;
#endif /* HAVE_LIBKSTAT */
} ip_chain_t;
static ip_chain_t **chain_list;
-static int chain_num = 0;
+static int chain_num;
static int iptables_config(const char *key, const char *value) {
/* int ip_value; */
/* Configuration options for the JVM. */
static char **jvm_argv;
-static size_t jvm_argc = 0;
+static size_t jvm_argc;
/* List of class names to load */
static java_plugin_class_t *java_classes_list;
/* List of config, init, and shutdown callbacks. */
static cjni_callback_info_t *java_callbacks;
-static size_t java_callbacks_num = 0;
+static size_t java_callbacks_num;
static pthread_mutex_t java_callbacks_lock = PTHREAD_MUTEX_INITIALIZER;
static oconfig_item_t *config_block;
#ifndef HAVE_HTONLL
static uint64_t htonll(uint64_t val) /* {{{ */
{
- static int config = 0;
+ static int config;
uint32_t hi;
uint32_t lo;
static double htond(double val) /* {{{ */
{
- static int config = 0;
+ static int config;
union {
uint8_t byte[8];
static double ntohd(double val) /* {{{ */
{
- static int config = 0;
+ static int config;
union {
uint8_t byte[8];
static char *log_file;
static int print_timestamp = 1;
-static int print_severity = 0;
+static int print_severity;
static const char *config_keys[] = {"LogLevel", "File", "Timestamp",
"PrintSeverity"};
static ignorelist_t *ignorelist;
static int use_sysfs = 1;
-static int init_state = 0;
+static int init_state;
static inline int item_watched(int i) {
assert(i >= 0);
#define MAX_CORES 256
static MicDeviceOnSystem mics[MAX_MICS];
-static U32 num_mics = 0;
+static U32 num_mics;
static HANDLE mic_handle;
static int const therm_ids[] = {
typedef struct mqtt_client_conf mqtt_client_conf_t;
static mqtt_client_conf_t **subscribers;
-static size_t subscribers_num = 0;
+static size_t subscribers_num;
/*
* Functions
static struct mnl_socket *nl;
static char **iflist;
-static size_t iflist_len = 0;
+static size_t iflist_len;
static const char *config_keys[] = {"Interface", "VerboseInterface",
"QDisc", "Class",
/*
* Private variables
*/
-static int network_config_ttl = 0;
+static int network_config_ttl;
/* Ethernet - (IPv6 + UDP) = 1500 - (40 + 8) = 1452 */
static size_t network_config_packet_size = 1452;
static bool network_config_forward;
static receive_list_entry_t *receive_list_tail;
static pthread_mutex_t receive_list_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t receive_list_cond = PTHREAD_COND_INITIALIZER;
-static uint64_t receive_list_length = 0;
+static uint64_t receive_list_length;
static sockent_t *listen_sockets;
static struct pollfd *listen_sockets_pollfd;
-static size_t listen_sockets_num = 0;
+static size_t listen_sockets_num;
/* The receive and dispatch threads will run as long as `listen_loop' is set to
* zero. */
-static int listen_loop = 0;
-static int receive_thread_running = 0;
+static int listen_loop;
+static int receive_thread_running;
static pthread_t receive_thread_id;
-static int dispatch_thread_running = 0;
+static int dispatch_thread_running;
static pthread_t dispatch_thread_id;
/* Buffer in which to-be-sent network packets are constructed. */
* example). Only if neither is true, the stats_lock is acquired. The counters
* are always read without holding a lock in the hope that writing 8 bytes to
* memory is an atomic operation. */
-static derive_t stats_octets_rx = 0;
-static derive_t stats_octets_tx = 0;
-static derive_t stats_packets_rx = 0;
-static derive_t stats_packets_tx = 0;
-static derive_t stats_values_dispatched = 0;
-static derive_t stats_values_not_dispatched = 0;
-static derive_t stats_values_sent = 0;
-static derive_t stats_values_not_sent = 0;
+static derive_t stats_octets_rx;
+static derive_t stats_octets_tx;
+static derive_t stats_packets_rx;
+static derive_t stats_packets_tx;
+static derive_t stats_values_dispatched;
+static derive_t stats_values_not_dispatched;
+static derive_t stats_values_sent;
+static derive_t stats_values_not_sent;
static pthread_mutex_t stats_lock = PTHREAD_MUTEX_INITIALIZER;
/*
static int parse_part_sign_sha256(sockent_t *se, /* {{{ */
void **ret_buffer, size_t *ret_buffer_size,
int flags) {
- static int warning_has_been_printed = 0;
+ static int warning_has_been_printed;
char *buffer;
size_t buffer_size;
static int parse_part_encr_aes256(sockent_t *se, /* {{{ */
void **ret_buffer, size_t *ret_buffer_size,
int flags) {
- static int warning_has_been_printed = 0;
+ static int warning_has_been_printed;
char *buffer;
size_t buffer_size;
static int nfs_submit_nfs4_server(const char *instance, char **fields,
size_t fields_num) {
- static int suppress_warning = 0;
+ static int suppress_warning;
size_t proc4x_names_num;
switch (fields_num) {
size_t fields_num) {
size_t proc40_names_num, proc4x_names_num;
- static int suppress_warning = 0;
+ static int suppress_warning;
switch (fields_num) {
case 34:
static CURL *curl;
static char nginx_buffer[16384];
-static size_t nginx_buffer_len = 0;
+static size_t nginx_buffer_len;
static char nginx_curl_error[CURL_ERROR_SIZE];
static const char *config_keys[] = {
static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
static char **recipients;
-static int recipients_len = 0;
+static int recipients_len;
static smtp_session_t session;
static pthread_mutex_t session_lock = PTHREAD_MUTEX_INITIALIZER;
static const char *config_keys[] = {"UPS", "FORCESSL", "VERIFYPEER", "CAPATH",
"CONNECTTIMEOUT"};
static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
-static int force_ssl = 0; // Initialized to default of 0 (false)
-static int verify_peer = 0; // Initialized to default of 0 (false)
+static int force_ssl; // Initialized to default of 0 (false)
+static int verify_peer; // Initialized to default of 0 (false)
static int ssl_flags = UPSCLI_CONN_TRYSSL;
static int connect_timeout = -1;
static char *ca_path;
static int ow_family_features_num = STATIC_ARRAY_SIZE(ow_family_features);
static char *device_g;
-static cdtime_t ow_interval = 0;
+static cdtime_t ow_interval;
static bool direct_access;
static const char *config_keys[] = {"Device", "IgnoreSelected", "Sensor",
* Global variables
*/
static udb_query_t **queries;
-static size_t queries_num = 0;
+static size_t queries_num;
static o_database_t **databases;
-static size_t databases_num = 0;
+static size_t databases_num;
OCIEnv *oci_env = NULL;
OCIError *oci_error = NULL;
/* the key used to store each pthread's ithread */
static pthread_key_t perl_thr_key;
-static int perl_argc = 0;
+static int perl_argc;
static char **perl_argv;
static char base_name[DATA_MAX_NAME_LEN] = "";
*/
/* {{{ */
static pinba_statnode_t *stat_nodes;
-static unsigned int stat_nodes_num = 0;
+static unsigned int stat_nodes_num;
static pthread_mutex_t stat_nodes_lock;
static char *conf_node;
static pthread_mutex_t ping_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t ping_cond = PTHREAD_COND_INITIALIZER;
-static int ping_thread_loop = 0;
-static int ping_thread_error = 0;
+static int ping_thread_loop;
+static int ping_thread_error;
static pthread_t ping_thread_id;
static const char *config_keys[] = {"Host", "SourceAddress", "AddressFamily",
static int def_queries_num = STATIC_ARRAY_SIZE(def_queries);
static c_psql_database_t **databases;
-static size_t databases_num = 0;
+static size_t databases_num;
static udb_query_t **queries;
-static size_t queries_num = 0;
+static size_t queries_num;
static c_psql_writer_t *writers;
-static size_t writers_num = 0;
+static size_t writers_num;
static int c_psql_begin(c_psql_database_t *db) {
PGresult *r = PQexec(db->conn, "BEGIN");
} /* c_psql_config_database */
static int c_psql_config(oconfig_item_t *ci) {
- static int have_def_config = 0;
+ static int have_def_config;
if (0 == have_def_config) {
oconfig_item_t *c;
static cpy_callback_t *cpy_shutdown_callbacks;
/* Make sure to hold the GIL while modifying these. */
-static int cpy_shutdown_triggered = 0;
-static int cpy_num_callbacks = 0;
+static int cpy_shutdown_triggered;
+static int cpy_num_callbacks;
static void cpy_destroy_user_data(void *data) {
cpy_callback_t *c = data;
* is zero a default, depending on the `interval' member of the value list is
* being used. */
static char *datadir;
-static double write_rate = 0.0;
+static double write_rate;
static rrdcreate_config_t rrdcreate_config = {
/* stepsize = */ 0,
/* heartbeat = */ 0,
/* XXX: If you need to lock both, cache_lock and queue_lock, at the same time,
* ALWAYS lock `cache_lock' first! */
-static cdtime_t cache_timeout = 0;
-static cdtime_t cache_flush_timeout = 0;
-static cdtime_t random_timeout = 0;
+static cdtime_t cache_timeout;
+static cdtime_t cache_flush_timeout;
+static cdtime_t random_timeout;
static cdtime_t cache_flush_last;
static c_avl_tree_t *cache;
static pthread_mutex_t cache_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t librrd_lock = PTHREAD_MUTEX_INITIALIZER;
#endif
-static int do_shutdown = 0;
+static int do_shutdown;
#if HAVE_THREADSAFE_LIBRRD
static int srrd_update(char *filename, char *template, int argc,
} /* int rrd_shutdown */
static int rrd_init(void) {
- static int init_once = 0;
+ static int init_once;
if (init_once != 0)
return 0;
}
static int sensors_load_conf(void) {
- static int call_once = 0;
+ static int call_once;
FILE *fh = NULL;
featurelist_t *last_feature = NULL;
static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
static ignorelist_t *ignorelist;
-static int ignore_sleep_mode = 0;
-static int use_serial = 0;
+static int ignore_sleep_mode;
+static int use_serial;
static int smart_config(const char *key, const char *value) {
if (ignorelist == NULL)
* +-> csnmp_config_add_host_security_level
*/
static void call_snmp_init_once(void) {
- static int have_init = 0;
+ static int have_init;
if (have_init == 0)
init_snmp(PACKAGE_NAME);
#else
static int log_level = LOG_INFO;
#endif /* COLLECT_DEBUG */
-static int notif_severity = 0;
+static int notif_severity;
static const char *config_keys[] = {
"LogLevel", "NotifyLevel",
typedef struct ctail_config_match_s ctail_config_match_t;
static cu_tail_match_t **tail_match_list;
-static size_t tail_match_list_num = 0;
+static size_t tail_match_list_num;
static cdtime_t tail_match_list_intervals[255];
static int ctail_config_add_match_dstype(ctail_config_match_t *cm,
#define MAX_NUMTAPE 256
extern kstat_ctl_t *kc;
static kstat_t *ksp[MAX_NUMTAPE];
-static int numtape = 0;
+static int numtape;
static int tape_init(void) {
kstat_t *ksp_chain;
"FIN_WAIT2", "TIME_WAIT"};
static kvm_t *kvmd;
-static u_long inpcbtable_off = 0;
+static u_long inpcbtable_off;
struct inpcbtable *inpcbtable_ptr = NULL;
#define TCP_STATE_LISTEN 1
"AllPortsSummary"};
static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
-static int port_collect_listening = 0;
-static int port_collect_total = 0;
+static int port_collect_listening;
+static int port_collect_total;
static port_entry_t *port_list_head;
static uint32_t count_total[TCP_STATE_MAX + 1];
/* This depends on linux inet_diag_req because if this structure is missing,
* sequence_number is useless and we get a compilation warning.
*/
-static uint32_t sequence_number = 0;
+static uint32_t sequence_number;
#endif
static enum { SRC_DUNNO, SRC_NETLINK, SRC_PROC } linux_source = SRC_DUNNO;
#define DEFAULT_DEVICE "/dev/ttyUSB0"
static char *conf_device;
-static int conf_retries = 0;
+static int conf_retries;
static int fd = -1;
#include <inttypes.h>
-static int fail_count__ = 0;
-static int check_count__ = 0;
+static int fail_count__;
+static int check_count__;
#ifndef DBL_PRECISION
#define DBL_PRECISION 1e-12
"DeleteSocket"};
static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
-static int loop = 0;
+static int loop;
/* socket configuration */
static int sock_fd = -1;
} /* int us_config */
static int us_init(void) {
- static int have_init = 0;
+ static int have_init;
int status;
#if HAVE_PCAP_H
static void (*Callback)(const rfc1035_header_t *);
-static int query_count_intvl = 0;
-static int query_count_total = 0;
+static int query_count_intvl;
+static int query_count_total;
#ifdef __OpenBSD__
static struct bpf_timeval last_ts;
#else
off_t no = 0;
unsigned char c;
size_t len;
- static int loop_detect = 0;
+ static int loop_detect;
if (loop_detect > 2)
return 4; /* compression loop */
if (ns == 0)
};
/* Global variables */
-static uint64_t ovs_uid = 0;
+static uint64_t ovs_uid;
static pthread_mutex_t ovs_uid_mutex = PTHREAD_MUTEX_INITIALIZER;
/* Post an event to event thread.
} while (0)
/* Connection. */
-static virConnectPtr conn = 0;
+static virConnectPtr conn;
static char *conn_string;
static c_complain_t conn_complain = C_COMPLAIN_INIT_STATIC;
static const char *config_keys[] = {"Verbose"};
static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
-static int verbose_output = 0;
+static int verbose_output;
/* #endif KERNEL_LINUX */
#else
#error "No applicable input method."
#endif
-static int pagesize = 0;
+static int pagesize;
static int vserver_init(void) {
/* XXX Should we check for getpagesize () in configure?
cdtime_t next_random_ttl;
};
-static cdtime_t resolve_interval = 0;
-static cdtime_t resolve_jitter = 0;
+static cdtime_t resolve_interval;
+static cdtime_t resolve_jitter;
/*
* Functions