**/
#include "collectd.h"
+
#include "common.h"
#include "plugin.h"
-#include "configfile.h"
#include <netdb.h>
#include <poll.h>
static void service_process_request (Pinba__Request *request) /* {{{ */
{
- unsigned int i;
-
pthread_mutex_lock (&stat_nodes_lock);
- for (i = 0; i < stat_nodes_num; i++)
+ for (unsigned int i = 0; i < stat_nodes_num; i++)
{
if ((stat_nodes[i].host != NULL)
&& (strcmp (request->hostname, stat_nodes[i].host) != 0))
{
pinba_socket_t *s;
struct addrinfo *ai_list;
- struct addrinfo *ai_ptr;
int status;
if (node == NULL)
return (NULL);
}
- for (ai_ptr = ai_list; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next)
+ for (struct addrinfo *ai_ptr = ai_list; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next)
{
status = pb_add_socket (s, ai_ptr);
if (status != 0)
static void pinba_socket_free (pinba_socket_t *socket) /* {{{ */
{
- nfds_t i;
-
if (!socket)
return;
- for (i = 0; i < socket->fd_num; i++)
+ for (nfds_t i = 0; i < socket->fd_num; i++)
{
if (socket->fd[i].fd < 0)
continue;
while (!collector_thread_do_shutdown)
{
int status;
- nfds_t i;
if (s->fd_num < 1)
break;
return (-1);
}
- for (i = 0; i < s->fd_num; i++)
+ for (nfds_t i = 0; i < s->fd_num; i++)
{
if (s->fd[i].revents & (POLLERR | POLLHUP | POLLNVAL))
{
char *server = NULL;
char *script = NULL;
int status;
- int i;
status = cf_util_get_string (ci, &name);
if (status != 0)
return (status);
- for (i = 0; i < ci->children_num; i++)
+ for (int i = 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
static int plugin_config (oconfig_item_t *ci) /* {{{ */
{
- int i;
-
/* The lock should not be necessary in the config callback, but let's be
* sure.. */
pthread_mutex_lock (&stat_nodes_lock);
- for (i = 0; i < ci->children_num; i++)
+ for (int i = 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
static int plugin_submit (const pinba_statnode_t *res) /* {{{ */
{
- value_t value;
value_list_t vl = VALUE_LIST_INIT;
- vl.values = &value;
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "pinba", sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, res->name, sizeof (vl.plugin_instance));
- value.derive = res->req_count;
+ vl.values = &(value_t) { .derive = res->req_count };
sstrncpy (vl.type, "total_requests", sizeof (vl.type));
plugin_dispatch_values (&vl);
- value.derive = float_counter_get (&res->req_time, /* factor = */ 1000);
+ vl.values = &(value_t) { .derive = float_counter_get (&res->req_time, /* factor = */ 1000) };
sstrncpy (vl.type, "total_time_in_ms", sizeof (vl.type));
plugin_dispatch_values (&vl);
- value.derive = res->doc_size;
+ vl.values = &(value_t) { .derive = res->doc_size };
sstrncpy (vl.type, "total_bytes", sizeof (vl.type));
plugin_dispatch_values (&vl);
- value.derive = float_counter_get (&res->ru_utime, /* factor = */ 100);
+ vl.values = &(value_t) { .derive = float_counter_get (&res->ru_utime, /* factor = */ 100) };
sstrncpy (vl.type, "cpu", sizeof (vl.type));
sstrncpy (vl.type_instance, "user", sizeof (vl.type_instance));
plugin_dispatch_values (&vl);
- value.derive = float_counter_get (&res->ru_stime, /* factor = */ 100);
+ vl.values = &(value_t) { .derive = float_counter_get (&res->ru_stime, /* factor = */ 100) };
sstrncpy (vl.type, "cpu", sizeof (vl.type));
sstrncpy (vl.type_instance, "system", sizeof (vl.type_instance));
plugin_dispatch_values (&vl);
- value.gauge = res->mem_peak;
+ vl.values = &(value_t) { .gauge = res->mem_peak };
sstrncpy (vl.type, "memory", sizeof (vl.type));
sstrncpy (vl.type_instance, "peak", sizeof (vl.type_instance));
plugin_dispatch_values (&vl);