} p; /* protocol-specific stats */
};
+/* extra counters that are registered at boot by various modules */
+enum counters_type {
+ COUNTERS_FE = 0,
+ COUNTERS_BE,
+ COUNTERS_SV,
+ COUNTERS_LI,
+ COUNTERS_RSLV,
+
+ COUNTERS_OFF_END /* must always be last */
+};
+
+struct extra_counters {
+ char *data; /* heap containing counters allocated in a linear fashion */
+ size_t size; /* size of allocated data */
+ enum counters_type type; /* type of object containing the counters */
+};
+
+
+#define EXTRA_COUNTERS(name) \
+ struct extra_counters *name
+
#endif /* _HAPROXY_COUNTERS_T_H */
/*
#include <haproxy/counters-t.h>
#include <haproxy/guid-t.h>
+extern THREAD_LOCAL void *trash_counters;
+
int counters_fe_shared_prepare(struct fe_counters_shared *counters, const struct guid_node *guid, char **errmsg);
int counters_be_shared_prepare(struct be_counters_shared *counters, const struct guid_node *guid, char **errmsg);
__ret; \
})
+/* Manipulation of extra_counters, for boot-time registrable modules */
+#define EXTRA_COUNTERS_GET(counters, mod) \
+ (likely(counters) ? \
+ ((void *)((counters)->data + (mod)->counters_off[(counters)->type])) : \
+ (trash_counters))
+
+#define EXTRA_COUNTERS_REGISTER(counters, ctype, alloc_failed_label) \
+ do { \
+ typeof(*counters) _ctr; \
+ _ctr = calloc(1, sizeof(*_ctr)); \
+ if (!_ctr) \
+ goto alloc_failed_label; \
+ _ctr->type = (ctype); \
+ *(counters) = _ctr; \
+ } while (0)
+
+#define EXTRA_COUNTERS_ADD(mod, counters, new_counters, csize) \
+ do { \
+ typeof(counters) _ctr = (counters); \
+ (mod)->counters_off[_ctr->type] = _ctr->size; \
+ _ctr->size += (csize); \
+ } while (0)
+
+#define EXTRA_COUNTERS_ALLOC(counters, alloc_failed_label) \
+ do { \
+ typeof(counters) _ctr = (counters); \
+ _ctr->data = malloc((_ctr)->size); \
+ if (!_ctr->data) \
+ goto alloc_failed_label; \
+ } while (0)
+
+#define EXTRA_COUNTERS_INIT(counters, mod, init_counters, init_counters_size) \
+ do { \
+ typeof(counters) _ctr = (counters); \
+ memcpy(_ctr->data + mod->counters_off[_ctr->type], \
+ (init_counters), (init_counters_size)); \
+ } while (0)
+
+#define EXTRA_COUNTERS_FREE(counters) \
+ do { \
+ if (counters) { \
+ free((counters)->data); \
+ free(counters); \
+ } \
+ } while (0)
+
#endif /* _HAPROXY_COUNTERS_H */
#include <import/eb64tree.h>
#include <import/ebmbtree.h>
+#include <haproxy/counters.h>
#include <haproxy/chunk.h>
#include <haproxy/dynbuf.h>
#include <haproxy/ncbmbuf.h>
#include <import/ebtree-t.h>
#include <haproxy/api-t.h>
#include <haproxy/buf-t.h>
+#include <haproxy/counters-t.h>
/* Flags for applet.ctx.stats.flags */
#define STAT_F_FMT_HTML 0x00000001 /* dump the stats in HTML format */
} u;
};
-enum counters_type {
- COUNTERS_FE = 0,
- COUNTERS_BE,
- COUNTERS_SV,
- COUNTERS_LI,
- COUNTERS_RSLV,
-
- COUNTERS_OFF_END
-};
-
/* Entity used to generate statistics on an HAProxy component */
struct stats_module {
struct list list;
char clearable; /* reset on a clear counters */
};
-struct extra_counters {
- char *data; /* heap containing counters allocated in a linear fashion */
- size_t size; /* size of allocated data */
- enum counters_type type; /* type of object containing the counters */
-};
-
/* stats_domain is used in a flag as a 1 byte field */
enum stats_domain {
STATS_DOMAIN_PROXY = 0,
enum stat_state state; /* phase of output production */
};
-extern THREAD_LOCAL void *trash_counters;
-
-#define EXTRA_COUNTERS(name) \
- struct extra_counters *name
-
-#define EXTRA_COUNTERS_GET(counters, mod) \
- (likely(counters) ? \
- ((void *)((counters)->data + (mod)->counters_off[(counters)->type])) : \
- (trash_counters))
-
-#define EXTRA_COUNTERS_REGISTER(counters, ctype, alloc_failed_label) \
- do { \
- typeof(*counters) _ctr; \
- _ctr = calloc(1, sizeof(*_ctr)); \
- if (!_ctr) \
- goto alloc_failed_label; \
- _ctr->type = (ctype); \
- *(counters) = _ctr; \
- } while (0)
-
-#define EXTRA_COUNTERS_ADD(mod, counters, new_counters, csize) \
- do { \
- typeof(counters) _ctr = (counters); \
- (mod)->counters_off[_ctr->type] = _ctr->size; \
- _ctr->size += (csize); \
- } while (0)
-
-#define EXTRA_COUNTERS_ALLOC(counters, alloc_failed_label) \
- do { \
- typeof(counters) _ctr = (counters); \
- _ctr->data = malloc((_ctr)->size); \
- if (!_ctr->data) \
- goto alloc_failed_label; \
- } while (0)
-
-#define EXTRA_COUNTERS_INIT(counters, mod, init_counters, init_counters_size) \
- do { \
- typeof(counters) _ctr = (counters); \
- memcpy(_ctr->data + mod->counters_off[_ctr->type], \
- (init_counters), (init_counters_size)); \
- } while (0)
-
-#define EXTRA_COUNTERS_FREE(counters) \
- do { \
- if (counters) { \
- free((counters)->data); \
- free(counters); \
- } \
- } while (0)
-
#endif /* _HAPROXY_STATS_T_H */
#define _HAPROXY_STATS_H
#include <haproxy/api.h>
+#include <haproxy/counters.h>
#include <haproxy/listener-t.h>
#include <haproxy/stats-t.h>
#include <haproxy/tools-t.h>