diff --git a/daemon/call.c b/daemon/call.c index d1cad5641..0f35839c1 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -64,16 +64,8 @@ struct xmlrpc_helper { }; -struct global_stats_gauge rtpe_stats_gauge; -struct global_stats_gauge_min_max rtpe_stats_gauge_cumulative; -struct global_stats_gauge_min_max rtpe_stats_gauge_graphite_min_max; -struct global_stats_gauge_min_max rtpe_stats_gauge_graphite_min_max_interval; - -struct global_stats_counter rtpe_stats; // total, cumulative, master static struct global_stats_counter rtpe_stats_intv; // copied out once per timer run -struct global_stats_counter rtpe_stats_rate; // per-second, calculated once per timer run -struct global_stats_min_max rtpe_stats_graphite_min_max; -struct global_stats_min_max rtpe_stats_graphite_min_max_interval; + rwlock_t rtpe_callhash_lock; GHashTable *rtpe_callhash; diff --git a/daemon/graphite.c b/daemon/graphite.c index 450ee8fe3..cece811cf 100644 --- a/daemon/graphite.c +++ b/daemon/graphite.c @@ -36,6 +36,14 @@ static struct timeval graphite_interval_tv; struct global_stats_counter rtpe_stats_graphite_diff; // per-interval increases static struct global_stats_counter rtpe_stats_graphite_intv; // copied out when graphite stats run + +struct global_stats_gauge_min_max rtpe_stats_gauge_graphite_min_max; +struct global_stats_gauge_min_max rtpe_stats_gauge_graphite_min_max_interval; + +struct global_stats_min_max rtpe_stats_graphite_min_max; +struct global_stats_min_max rtpe_stats_graphite_min_max_interval; + + void set_graphite_interval_tv(struct timeval *tv) { graphite_interval_tv = *tv; } diff --git a/daemon/statistics.c b/daemon/statistics.c index 1860ecfda..4b8891bdf 100644 --- a/daemon/statistics.c +++ b/daemon/statistics.c @@ -14,6 +14,13 @@ mutex_t rtpe_codec_stats_lock; GHashTable *rtpe_codec_stats; +struct global_stats_gauge rtpe_stats_gauge; +struct global_stats_gauge_min_max rtpe_stats_gauge_cumulative; + +struct global_stats_counter rtpe_stats; // total, cumulative, master +struct global_stats_counter rtpe_stats_rate; // per-second, calculated once per timer run + + // op can be CMC_INCREMENT or CMC_DECREMENT // check not to multiple decrement or increment void statistics_update_ip46_inc_dec(struct call* c, int op) { diff --git a/include/call.h b/include/call.h index 6ef3d7866..424438f12 100644 --- a/include/call.h +++ b/include/call.h @@ -685,33 +685,6 @@ extern rwlock_t rtpe_callhash_lock; extern GHashTable *rtpe_callhash; extern struct call_iterator_list rtpe_call_iterators[NUM_CALL_ITERATORS]; -extern struct global_stats_gauge rtpe_stats_gauge; -extern struct global_stats_gauge_min_max rtpe_stats_gauge_cumulative; // lifetime min/max/average/sums -extern struct global_stats_gauge_min_max rtpe_stats_gauge_graphite_min_max; -extern struct global_stats_gauge_min_max rtpe_stats_gauge_graphite_min_max_interval; - -#define RTPE_GAUGE_SET(field, num) \ - do { \ - atomic64_set(&rtpe_stats_gauge.field, num); \ - RTPE_GAUGE_SET_MIN_MAX(field, rtpe_stats_gauge_cumulative, num); \ - RTPE_GAUGE_SET_MIN_MAX(field, rtpe_stats_gauge_graphite_min_max, num); \ - } while (0) -#define RTPE_GAUGE_ADD(field, num) \ - do { \ - uint64_t __old = atomic64_add(&rtpe_stats_gauge.field, num); \ - RTPE_GAUGE_SET_MIN_MAX(field, rtpe_stats_gauge_graphite_min_max, __old + num); \ - } while (0) -#define RTPE_GAUGE_INC(field) RTPE_GAUGE_ADD(field, 1) -#define RTPE_GAUGE_DEC(field) RTPE_GAUGE_ADD(field, -1) - -extern struct global_stats_counter rtpe_stats; // total, cumulative, master -extern struct global_stats_counter rtpe_stats_rate; // per-second, calculated once per timer run -extern struct global_stats_counter rtpe_stats_graphite_diff; // per-interval increases -extern struct global_stats_min_max rtpe_stats_graphite_min_max; // running min/max -extern struct global_stats_min_max rtpe_stats_graphite_min_max_interval; // updated once per graphite run - -#define RTPE_STATS_ADD(field, num) atomic64_add(&rtpe_stats.field, num) -#define RTPE_STATS_INC(field) RTPE_STATS_ADD(field, 1) int call_init(void); diff --git a/include/graphite.h b/include/graphite.h index 74556c079..295eae9f0 100644 --- a/include/graphite.h +++ b/include/graphite.h @@ -18,6 +18,10 @@ enum connection_state { extern struct timeval rtpe_latest_graphite_interval_start; +extern struct global_stats_gauge_min_max rtpe_stats_gauge_graphite_min_max; +extern struct global_stats_gauge_min_max rtpe_stats_gauge_graphite_min_max_interval; + + void set_prefix(char* prefix); void free_prefix(void); void graphite_loop(void *d); diff --git a/include/statistics.h b/include/statistics.h index 05d8f7c3f..eb5017376 100644 --- a/include/statistics.h +++ b/include/statistics.h @@ -22,6 +22,7 @@ struct stream_stats { #include "control_ng.h" +#include "graphite.h" // "gauge" style stats @@ -113,6 +114,35 @@ extern struct timeval rtpe_started; extern mutex_t rtpe_codec_stats_lock; extern GHashTable *rtpe_codec_stats; + +extern struct global_stats_gauge rtpe_stats_gauge; +extern struct global_stats_gauge_min_max rtpe_stats_gauge_cumulative; // lifetime min/max/average/sums + +#define RTPE_GAUGE_SET(field, num) \ + do { \ + atomic64_set(&rtpe_stats_gauge.field, num); \ + RTPE_GAUGE_SET_MIN_MAX(field, rtpe_stats_gauge_cumulative, num); \ + RTPE_GAUGE_SET_MIN_MAX(field, rtpe_stats_gauge_graphite_min_max, num); \ + } while (0) +#define RTPE_GAUGE_ADD(field, num) \ + do { \ + uint64_t __old = atomic64_add(&rtpe_stats_gauge.field, num); \ + RTPE_GAUGE_SET_MIN_MAX(field, rtpe_stats_gauge_graphite_min_max, __old + num); \ + } while (0) +#define RTPE_GAUGE_INC(field) RTPE_GAUGE_ADD(field, 1) +#define RTPE_GAUGE_DEC(field) RTPE_GAUGE_ADD(field, -1) + +extern struct global_stats_counter rtpe_stats; // total, cumulative, master +extern struct global_stats_counter rtpe_stats_rate; // per-second, calculated once per timer run +extern struct global_stats_counter rtpe_stats_graphite_diff; // per-interval increases +extern struct global_stats_min_max rtpe_stats_graphite_min_max; // running min/max +extern struct global_stats_min_max rtpe_stats_graphite_min_max_interval; // updated once per graphite run + +#define RTPE_STATS_ADD(field, num) atomic64_add(&rtpe_stats.field, num) +#define RTPE_STATS_INC(field) RTPE_STATS_ADD(field, 1) + + + void statistics_update_oneway(struct call *); void statistics_update_ip46_inc_dec(struct call *, int op); void statistics_update_foreignown_dec(struct call *);