Browse Source

TT#101150 move start timestamp to global var

Change-Id: I03efdbf02b5fbf16616d26010cb79b0932cd4e00
pull/1373/head
Richard Fuchs 4 years ago
parent
commit
b0ebe9ba1b
3 changed files with 7 additions and 5 deletions
  1. +4
    -2
      daemon/statistics.c
  2. +2
    -2
      include/statistics.h
  3. +1
    -1
      t/test-stats.c

+ 4
- 2
daemon/statistics.c View File

@ -10,6 +10,8 @@ struct totalstats rtpe_totalstats_interval;
mutex_t rtpe_totalstats_lastinterval_lock;
struct totalstats rtpe_totalstats_lastinterval;
struct timeval rtpe_started;
mutex_t rtpe_codec_stats_lock;
GHashTable *rtpe_codec_stats;
@ -413,7 +415,7 @@ GQueue *statistics_gather_metrics(void) {
HEADER("totalstatistics", "Total statistics (does not include current running sessions):");
HEADER("{", "");
METRIC("uptime", "Uptime of rtpengine", "%llu", "%llu seconds", (long long) rtpe_now.tv_sec-rtpe_totalstats.started);
METRIC("uptime", "Uptime of rtpengine", "%llu", "%llu seconds", (long long) timeval_diff(&rtpe_now, &rtpe_started) / 1000000);
PROM("uptime_seconds", "gauge");
METRIC("managedsessions", "Total managed sessions", UINT64F, UINT64F, num_sessions);
@ -698,7 +700,7 @@ static void codec_stats_free(void *p) {
void statistics_init() {
mutex_init(&rtpe_totalstats_interval.total_calls_duration_lock);
time(&rtpe_totalstats.started);
gettimeofday(&rtpe_started, NULL);
//rtpe_totalstats_interval.managed_sess_min = 0; // already zeroed
//rtpe_totalstats_interval.managed_sess_max = 0;


+ 2
- 2
include/statistics.h View File

@ -63,8 +63,6 @@ struct global_stats_min_max {
struct totalstats {
time_t started;
mutex_t total_calls_duration_lock; /* for these two below */
struct timeval total_calls_duration_interval;
};
@ -116,6 +114,8 @@ extern struct totalstats rtpe_totalstats_interval;
extern mutex_t rtpe_totalstats_lastinterval_lock;
extern struct totalstats rtpe_totalstats_lastinterval;
extern struct timeval rtpe_started;
extern mutex_t rtpe_codec_stats_lock;
extern GHashTable *rtpe_codec_stats;


+ 1
- 1
t/test-stats.c View File

@ -69,7 +69,7 @@ int main(void) {
// fake current time
rtpe_now = (struct timeval) {150,0};
rtpe_totalstats.started = 80;
rtpe_started = (struct timeval) {80,0};
// test cmd_time_min/max/avg


Loading…
Cancel
Save