projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
contrib/docker: add LD_PRELOAD wrapper to fopen/open/opendir syscalls
[collectd.git]
/
src
/
pinba.c
diff --git
a/src/pinba.c
b/src/pinba.c
index
833fa1b
..
5571ff2
100644
(file)
--- a/
src/pinba.c
+++ b/
src/pinba.c
@@
-24,9
+24,9
@@
**/
#include "collectd.h"
**/
#include "collectd.h"
+
#include "common.h"
#include "plugin.h"
#include "common.h"
#include "plugin.h"
-#include "configfile.h"
#include <netdb.h>
#include <poll.h>
#include <netdb.h>
#include <poll.h>
@@
-251,11
+251,9
@@
static void service_statnode_process (pinba_statnode_t *node, /* {{{ */
static void service_process_request (Pinba__Request *request) /* {{{ */
{
static void service_process_request (Pinba__Request *request) /* {{{ */
{
- unsigned int i;
-
pthread_mutex_lock (&stat_nodes_lock);
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))
{
if ((stat_nodes[i].host != NULL)
&& (strcmp (request->hostname, stat_nodes[i].host) != 0))
@@
-351,24
+349,20
@@
static pinba_socket_t *pinba_socket_open (const char *node, /* {{{ */
{
pinba_socket_t *s;
struct addrinfo *ai_list;
{
pinba_socket_t *s;
struct addrinfo *ai_list;
- struct addrinfo *ai_ptr;
- struct addrinfo ai_hints = { 0 };
int status;
int status;
- ai_hints.ai_flags = AI_PASSIVE;
- ai_hints.ai_family = AF_UNSPEC;
- ai_hints.ai_socktype = SOCK_DGRAM;
- ai_hints.ai_addr = NULL;
- ai_hints.ai_canonname = NULL;
- ai_hints.ai_next = NULL;
-
if (node == NULL)
node = PINBA_DEFAULT_NODE;
if (service == NULL)
service = PINBA_DEFAULT_SERVICE;
if (node == NULL)
node = PINBA_DEFAULT_NODE;
if (service == NULL)
service = PINBA_DEFAULT_SERVICE;
- ai_list = NULL;
+ struct addrinfo ai_hints = {
+ .ai_family = AF_UNSPEC,
+ .ai_flags = AI_PASSIVE,
+ .ai_socktype = SOCK_DGRAM
+ };
+
status = getaddrinfo (node, service,
&ai_hints, &ai_list);
if (status != 0)
status = getaddrinfo (node, service,
&ai_hints, &ai_list);
if (status != 0)
@@
-387,7
+381,7
@@
static pinba_socket_t *pinba_socket_open (const char *node, /* {{{ */
return (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)
{
status = pb_add_socket (s, ai_ptr);
if (status != 0)
@@
-408,12
+402,10
@@
static pinba_socket_t *pinba_socket_open (const char *node, /* {{{ */
static void pinba_socket_free (pinba_socket_t *socket) /* {{{ */
{
static void pinba_socket_free (pinba_socket_t *socket) /* {{{ */
{
- nfds_t i;
-
if (!socket)
return;
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;
{
if (socket->fd[i].fd < 0)
continue;
@@
-504,7
+496,6
@@
static int receive_loop (void) /* {{{ */
while (!collector_thread_do_shutdown)
{
int status;
while (!collector_thread_do_shutdown)
{
int status;
- nfds_t i;
if (s->fd_num < 1)
break;
if (s->fd_num < 1)
break;
@@
-527,7
+518,7
@@
static int receive_loop (void) /* {{{ */
return (-1);
}
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))
{
{
if (s->fd[i].revents & (POLLERR | POLLHUP | POLLNVAL))
{
@@
-567,13
+558,12
@@
static int pinba_config_view (const oconfig_item_t *ci) /* {{{ */
char *server = NULL;
char *script = NULL;
int status;
char *server = NULL;
char *script = NULL;
int status;
- int i;
status = cf_util_get_string (ci, &name);
if (status != 0)
return (status);
status = cf_util_get_string (ci, &name);
if (status != 0)
return (status);
- for (i = 0; i < ci->children_num; i++)
+ for (i
nt i
= 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
{
oconfig_item_t *child = ci->children + i;
@@
-606,13
+596,11
@@
static int pinba_config_view (const oconfig_item_t *ci) /* {{{ */
static int plugin_config (oconfig_item_t *ci) /* {{{ */
{
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);
/* 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 (i
nt i
= 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
{
oconfig_item_t *child = ci->children + i;
@@
-689,38
+677,35
@@
static int plugin_shutdown (void) /* {{{ */
static int plugin_submit (const pinba_statnode_t *res) /* {{{ */
{
static int plugin_submit (const pinba_statnode_t *res) /* {{{ */
{
- value_t value;
value_list_t vl = VALUE_LIST_INIT;
value_list_t vl = VALUE_LIST_INIT;
- vl.values = &value;
vl.values_len = 1;
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));
sstrncpy (vl.plugin, "pinba", sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, res->name, sizeof (vl.plugin_instance));
- v
alue.derive = res->req_count
;
+ v
l.values = &(value_t) { .derive = res->req_count }
;
sstrncpy (vl.type, "total_requests", sizeof (vl.type));
plugin_dispatch_values (&vl);
sstrncpy (vl.type, "total_requests", sizeof (vl.type));
plugin_dispatch_values (&vl);
- v
alue.derive = float_counter_get (&res->req_time, /* factor = */ 1000)
;
+ v
l.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);
sstrncpy (vl.type, "total_time_in_ms", sizeof (vl.type));
plugin_dispatch_values (&vl);
- v
alue.derive = res->doc_size
;
+ v
l.values = &(value_t) { .derive = res->doc_size }
;
sstrncpy (vl.type, "total_bytes", sizeof (vl.type));
plugin_dispatch_values (&vl);
sstrncpy (vl.type, "total_bytes", sizeof (vl.type));
plugin_dispatch_values (&vl);
- v
alue.derive = float_counter_get (&res->ru_utime, /* factor = */ 100)
;
+ v
l.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);
sstrncpy (vl.type, "cpu", sizeof (vl.type));
sstrncpy (vl.type_instance, "user", sizeof (vl.type_instance));
plugin_dispatch_values (&vl);
- v
alue.derive = float_counter_get (&res->ru_stime, /* factor = */ 100)
;
+ v
l.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);
sstrncpy (vl.type, "cpu", sizeof (vl.type));
sstrncpy (vl.type_instance, "system", sizeof (vl.type_instance));
plugin_dispatch_values (&vl);
- v
alue.gauge = res->mem_peak
;
+ v
l.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);
sstrncpy (vl.type, "memory", sizeof (vl.type));
sstrncpy (vl.type_instance, "peak", sizeof (vl.type_instance));
plugin_dispatch_values (&vl);