summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: edd9adb)
raw | patch | inline | side by side (parent: edd9adb)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Fri, 9 Apr 2010 18:36:48 +0000 (20:36 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Fri, 9 Apr 2010 18:36:48 +0000 (20:36 +0200) |
This way service names can be used, too.
src/pinba.c | patch | blob | history |
diff --git a/src/pinba.c b/src/pinba.c
index 1f10e31a00b3c3879b953416e39a3fabc607bfc4..489ba7cfa502c478e72f7fce2563df50b7af6752 100644 (file)
--- a/src/pinba.c
+++ b/src/pinba.c
# define PINBA_UDP_BUFFER_SIZE 65536
#endif
-#ifndef PINBA_DEFAULT_ADDRESS
-# define PINBA_DEFAULT_ADDRESS "127.0.0.1" /* FIXME */
+#ifndef PINBA_DEFAULT_NODE
+# define PINBA_DEFAULT_NODE "127.0.0.1" /* FIXME */
#endif
-#ifndef PINBA_DEFAULT_PORT
-# define PINBA_DEFAULT_PORT 12345 /* FIXME */
+#ifndef PINBA_DEFAULT_SERVICE
+# define PINBA_DEFAULT_SERVICE "12345" /* FIXME */
#endif
#ifndef PINBA_MAX_SOCKETS
static unsigned int stat_nodes_num = 0;
static pthread_mutex_t stat_nodes_lock;
-char service_status=0;
-char *service_address = PINBA_DEFAULT_ADDRESS;
-unsigned int service_port=PINBA_DEFAULT_PORT;
+static char *conf_node = NULL;
+static char *conf_service = NULL;
static _Bool collector_thread_running = 0;
static _Bool collector_thread_do_shutdown = 0;
} /* }}} int pb_add_socket */
static pinba_socket_t *pinba_socket_open (const char *node, /* {{{ */
- int listen_port)
+ const char *service)
{
pinba_socket_t *s;
struct addrinfo *ai_list;
struct addrinfo ai_hints;
int status;
- char service[NI_MAXSERV]; /* FIXME */
- snprintf (service, sizeof (service), "%i", listen_port);
-
memset (&ai_hints, 0, sizeof (ai_hints));
ai_hints.ai_flags = AI_PASSIVE;
ai_hints.ai_family = AF_UNSPEC;
ai_hints.ai_canonname = NULL;
ai_hints.ai_next = NULL;
+ if (node == NULL)
+ node = PINBA_DEFAULT_NODE;
+
+ if (service == NULL)
+ service = PINBA_DEFAULT_SERVICE;
+
ai_list = NULL;
status = getaddrinfo (node, service,
&ai_hints, &ai_list);
{
pinba_socket_t *s;
- s = pinba_socket_open (service_address, service_port);
+ s = pinba_socket_open (conf_node, conf_service);
if (s == NULL)
{
ERROR ("pinba plugin: Collector thread is exiting prematurely.");
static int plugin_config (oconfig_item_t *ci) /* {{{ */
{
unsigned int i, o;
- int pinba_port = 0;
- char *pinba_address = NULL;
-
- INFO("Pinba Configure..");
service_statnode_begin();
- /* Set default values */
- config_set(&pinba_address, PINBA_DEFAULT_ADDRESS);
- pinba_port = PINBA_DEFAULT_PORT;
-
for (i = 0; i < ci->children_num; i++) {
oconfig_item_t *child = ci->children + i;
if (strcasecmp ("Address", child->key) == 0) {
WARNING ("pinba plugin: `Address' needs exactly one string argument.");
return (-1);
}
- config_set(&pinba_address, child->values[0].value.string);
+ config_set(&conf_node, child->values[0].value.string);
} else if (strcasecmp ("Port", child->key) == 0) {
- if ((child->values_num != 1) || (child->values[0].type != OCONFIG_TYPE_NUMBER)){
- WARNING ("pinba plugin: `Port' needs exactly one number argument.");
+ if ((child->values_num != 1) || (child->values[0].type != OCONFIG_TYPE_STRING)){
+ WARNING ("pinba plugin: `Port' needs exactly one string argument.");
return (-1);
}
- pinba_port=child->values[0].value.number;
+ config_set(&conf_service, child->values[0].value.string);
} else if (strcasecmp ("View", child->key) == 0) {
const char *name=NULL, *host=NULL, *server=NULL, *script=NULL;
if ((child->values_num != 1) || (child->values[0].type != OCONFIG_TYPE_STRING) || strlen(child->values[0].value.string)==0){