You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

2198 lines
48 KiB

#include <stdlib.h>
#include <stdio.h>
#include "graphite.h"
#include "statistics.h"
#include "poller.h"
#include "control_ng.h"
#include "call_interfaces.h"
#include "ssllib.h"
int _log_facility_rtcp;
int _log_facility_cdr;
int _log_facility_dtmf;
struct rtpengine_config rtpe_config = {
.dtls_rsa_key_size = 2048,
};
struct rtpengine_config initial_rtpe_config;
struct poller *rtpe_poller;
struct poller_map *rtpe_poller_map;
GString *dtmf_logs;
static void __assert_g_string_eq(GString *a, const char *b, unsigned int line) {
if (strcmp(a->str, b) == 0) {
g_string_free(a, TRUE);
return;
}
printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX test failed at line %u\n", line);
printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX received >>>>> <%s>\n", a->str);
printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX doesn't match expected <<<<< <%s>\n", b);
const char *A = a->str;
while (*A == *b) {
A++;
b++;
}
printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX difference in received at: ... <%s>\n", A);
printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX difference in expected at: ... <%s>\n", b);
abort();
}
#define assert_g_string_eq(a, b) __assert_g_string_eq(a, b, __LINE__)
static void __assert_metrics_eq(GQueue *q, const char *b, unsigned int line) {
GString *a = g_string_new("");
for (GList *l = q->head; l; l = l->next) {
struct stats_metric *m = l->data;
#define APP_S(x) if (m->x) do { g_string_append(a, m->x); g_string_append_c(a, '\n'); } while (0)
APP_S(descr);
APP_S(label);
APP_S(value_long);
APP_S(value_short);
APP_S(prom_label);
}
__assert_g_string_eq(a, b, line);
statistics_free_metrics(&q);
}
#define assert_metrics_eq(a, b) __assert_metrics_eq(a, b, __LINE__)
int main(void) {
rtpe_common_config_ptr = &rtpe_config.common;
rtpe_ssl_init();
rtpe_poller = poller_new();
call_init();
statistics_init();
call_interfaces_init();
control_ng_init();
dtls_init();
// fake current time
rtpe_now = (struct timeval) {150,0};
rtpe_totalstats.started = 80;
// test cmd_time_min/max/avg
GString *graph_str = print_graphite_data(&rtpe_totalstats_lastinterval);
assert_g_string_eq(graph_str,
"offer_time_min 0.000000 150\n"
"offer_time_max 0.000000 150\n"
"offer_time_avg 0.000000 150\n"
"answer_time_min 0.000000 150\n"
"answer_time_max 0.000000 150\n"
"answer_time_avg 0.000000 150\n"
"delete_time_min 0.000000 150\n"
"delete_time_max 0.000000 150\n"
"delete_time_avg 0.000000 150\n"
"call_dur 0.000000 150\n"
"average_call_dur 0.000000 150\n"
"forced_term_sess 0 150\n"
"managed_sess 0 150\n"
"managed_sess_min 0 150\n"
"managed_sess_max 0 150\n"
"current_sessions_total 0 150\n"
"current_sessions_own 0 150\n"
"current_sessions_foreign 0 150\n"
"current_transcoded_media 0 150\n"
"current_sessions_ipv4 0 150\n"
"current_sessions_ipv6 0 150\n"
"current_sessions_mixed 0 150\n"
"nopacket_relayed_sess 0 150\n"
"oneway_stream_sess 0 150\n"
"regular_term_sess 0 150\n"
"relayed_errors 0 150\n"
"relayed_packets 0 150\n"
"silent_timeout_sess 0 150\n"
"final_timeout_sess 0 150\n"
"offer_timeout_sess 0 150\n"
"timeout_sess 0 150\n"
"reject_sess 0 150\n"
"offers_ps_min 0 150\n"
"offers_ps_max 0 150\n"
"offers_ps_avg 0 150\n"
"answers_ps_min 0 150\n"
"answers_ps_max 0 150\n"
"answers_ps_avg 0 150\n"
"deletes_ps_min 0 150\n"
"deletes_ps_max 0 150\n"
"deletes_ps_avg 0 150\n");
GQueue *stats = statistics_gather_metrics();
assert_metrics_eq(stats,
"\n"
"{\n"
"Statistics over currently running sessions:\n"
"currentstatistics\n"
"\n"
"{\n"
"Owned sessions\n"
"sessionsown\n"
"0\n"
"0\n"
"type=\"own\"\n"
"Foreign sessions\n"
"sessionsforeign\n"
"0\n"
"0\n"
"type=\"foreign\"\n"
"Total sessions\n"
"sessionstotal\n"
"0\n"
"0\n"
"Transcoded media\n"
"transcodedmedia\n"
"0\n"
"0\n"
"Packets per second\n"
"packetrate\n"
"0\n"
"0\n"
"Bytes per second\n"
"byterate\n"
"0\n"
"0\n"
"Errors per second\n"
"errorrate\n"
"0\n"
"0\n"
"\n"
"}\n"
"Total statistics (does not include current running sessions):\n"
"totalstatistics\n"
"\n"
"{\n"
"Uptime of rtpengine\n"
"uptime\n"
"70 seconds\n"
"70\n"
"Total managed sessions\n"
"managedsessions\n"
"0\n"
"0\n"
"Total rejected sessions\n"
"rejectedsessions\n"
"0\n"
"0\n"
"reason=\"rejected\"\n"
"Total timed-out sessions via TIMEOUT\n"
"timeoutsessions\n"
"0\n"
"0\n"
"reason=\"timeout\"\n"
"Total timed-out sessions via SILENT_TIMEOUT\n"
"silenttimeoutsessions\n"
"0\n"
"0\n"
"reason=\"silent_timeout\"\n"
"Total timed-out sessions via FINAL_TIMEOUT\n"
"finaltimeoutsessions\n"
"0\n"
"0\n"
"reason=\"final_timeout\"\n"
"Total timed-out sessions via OFFER_TIMEOUT\n"
"offertimeoutsessions\n"
"0\n"
"0\n"
"reason=\"offer_timeout\"\n"
"Total regular terminated sessions\n"
"regularterminatedsessions\n"
"0\n"
"0\n"
"reason=\"terminated\"\n"
"Total forced terminated sessions\n"
"forcedterminatedsessions\n"
"0\n"
"0\n"
"reason=\"force_terminated\"\n"
"Total relayed packets\n"
"relayedpackets\n"
"0\n"
"0\n"
"Total relayed packet errors\n"
"relayedpacketerrors\n"
"0\n"
"0\n"
"Total relayed bytes\n"
"relayedbytes\n"
"0\n"
"0\n"
"Total number of streams with no relayed packets\n"
"zerowaystreams\n"
"0\n"
"0\n"
"Total number of 1-way streams\n"
"onewaystreams\n"
"0\n"
"0\n"
"Average call duration\n"
"avgcallduration\n"
"0.000000\n"
"0.000000\n"
"\n"
"\n"
"}\n"
"Graphite interval statistics (last reported values to graphite):\n"
"intervalstatistics\n"
"{\n"
"Total calls duration\n"
"totalcallsduration\n"
"0.000000\n"
"0.000000\n"
"\n"
"Min managed sessions\n"
"minmanagedsessions\n"
"0\n"
"0\n"
"Max managed sessions\n"
"maxmanagedsessions\n"
"0\n"
"0\n"
"Min/Max/Avg offer processing delay\n"
"0.000000/0.000000/0.000000 sec\n"
"minofferdelay\n"
"0.000000\n"
"maxofferdelay\n"
"0.000000\n"
"avgofferdelay\n"
"0.000000\n"
"Min/Max/Avg answer processing delay\n"
"0.000000/0.000000/0.000000 sec\n"
"minanswerdelay\n"
"0.000000\n"
"maxanswerdelay\n"
"0.000000\n"
"avganswerdelay\n"
"0.000000\n"
"Min/Max/Avg delete processing delay\n"
"0.000000/0.000000/0.000000 sec\n"
"mindeletedelay\n"
"0.000000\n"
"maxdeletedelay\n"
"0.000000\n"
"avgdeletedelay\n"
"0.000000\n"
"Min/Max/Avg offer requests per second\n"
"0/0/0 per sec\n"
"minofferrequestrate\n"
"0\n"
"maxofferrequestrate\n"
"0\n"
"avgofferrequestrate\n"
"0\n"
"Min/Max/Avg answer requests per second\n"
"0/0/0 per sec\n"
"minanswerrequestrate\n"
"0\n"
"maxanswerrequestrate\n"
"0\n"
"avganswerrequestrate\n"
"0\n"
"Min/Max/Avg delete requests per second\n"
"0/0/0 per sec\n"
"mindeleterequestrate\n"
"0\n"
"maxdeleterequestrate\n"
"0\n"
"avgdeleterequestrate\n"
"0\n"
"\n"
"\n"
"}\n"
"Control statistics:\n"
"controlstatistics\n"
"\n"
"{\n"
"proxies\n"
"[\n"
" Proxy | Ping | Offer | Answer | Delete | Query | List | StartRec | StopRec | StartFwd | StopFwd | BlkDTMF | UnblkDTMF | BlkMedia | UnblkMedia | PlayMedia | StopMedia | PlayDTMF | Stats | SlnMedia | UnslnMedia | Pub | SubReq | SubAns | Unsub \n"
"\n"
"]\n"
"totalpingcount\n"
"0\n"
"totaloffercount\n"
"0\n"
"totalanswercount\n"
"0\n"
"totaldeletecount\n"
"0\n"
"totalquerycount\n"
"0\n"
"totallistcount\n"
"0\n"
"totalstartreccount\n"
"0\n"
"totalstopreccount\n"
"0\n"
"totalstartfwdcount\n"
"0\n"
"totalstopfwdcount\n"
"0\n"
"totalblkdtmfcount\n"
"0\n"
"totalunblkdtmfcount\n"
"0\n"
"totalblkmediacount\n"
"0\n"
"totalunblkmediacount\n"
"0\n"
"totalplaymediacount\n"
"0\n"
"totalstopmediacount\n"
"0\n"
"totalplaydtmfcount\n"
"0\n"
"totalstatscount\n"
"0\n"
"totalslnmediacount\n"
"0\n"
"totalunslnmediacount\n"
"0\n"
"totalpubcount\n"
"0\n"
"totalsubreqcount\n"
"0\n"
"totalsubanscount\n"
"0\n"
"totalunsubcount\n"
"0\n"
"\n"
"}\n"
"interfaces\n"
"[\n"
"]\n"
"transcoders\n"
"\n"
"[\n"
"\n"
"]\n"
"}\n");
RTPE_STATS_INC(offers);
RTPE_GAUGE_SET(offer_time, 2500000);
RTPE_STATS_INC(offers);
RTPE_GAUGE_SET(offer_time, 3200000);
graph_str = print_graphite_data(&rtpe_totalstats_lastinterval);
assert_g_string_eq(graph_str,
"offer_time_min 2.500000 150\n"
"offer_time_max 3.200000 150\n"
"offer_time_avg 2.850000 150\n"
"answer_time_min 0.000000 150\n"
"answer_time_max 0.000000 150\n"
"answer_time_avg 0.000000 150\n"
"delete_time_min 0.000000 150\n"
"delete_time_max 0.000000 150\n"
"delete_time_avg 0.000000 150\n"
"call_dur 0.000000 150\n"
"average_call_dur 0.000000 150\n"
"forced_term_sess 0 150\n"
"managed_sess 0 150\n"
"managed_sess_min 0 150\n"
"managed_sess_max 0 150\n"
"current_sessions_total 0 150\n"
"current_sessions_own 0 150\n"
"current_sessions_foreign 0 150\n"
"current_transcoded_media 0 150\n"
"current_sessions_ipv4 0 150\n"
"current_sessions_ipv6 0 150\n"
"current_sessions_mixed 0 150\n"
"nopacket_relayed_sess 0 150\n"
"oneway_stream_sess 0 150\n"
"regular_term_sess 0 150\n"
"relayed_errors 0 150\n"
"relayed_packets 0 150\n"
"silent_timeout_sess 0 150\n"
"final_timeout_sess 0 150\n"
"offer_timeout_sess 0 150\n"
"timeout_sess 0 150\n"
"reject_sess 0 150\n"
"offers_ps_min 0 150\n"
"offers_ps_max 0 150\n"
"offers_ps_avg 0 150\n"
"answers_ps_min 0 150\n"
"answers_ps_max 0 150\n"
"answers_ps_avg 0 150\n"
"deletes_ps_min 0 150\n"
"deletes_ps_max 0 150\n"
"deletes_ps_avg 0 150\n");
stats = statistics_gather_metrics();
assert_metrics_eq(stats,
"\n"
"{\n"
"Statistics over currently running sessions:\n"
"currentstatistics\n"
"\n"
"{\n"
"Owned sessions\n"
"sessionsown\n"
"0\n"
"0\n"
"type=\"own\"\n"
"Foreign sessions\n"
"sessionsforeign\n"
"0\n"
"0\n"
"type=\"foreign\"\n"
"Total sessions\n"
"sessionstotal\n"
"0\n"
"0\n"
"Transcoded media\n"
"transcodedmedia\n"
"0\n"
"0\n"
"Packets per second\n"
"packetrate\n"
"0\n"
"0\n"
"Bytes per second\n"
"byterate\n"
"0\n"
"0\n"
"Errors per second\n"
"errorrate\n"
"0\n"
"0\n"
"\n"
"}\n"
"Total statistics (does not include current running sessions):\n"
"totalstatistics\n"
"\n"
"{\n"
"Uptime of rtpengine\n"
"uptime\n"
"70 seconds\n"
"70\n"
"Total managed sessions\n"
"managedsessions\n"
"0\n"
"0\n"
"Total rejected sessions\n"
"rejectedsessions\n"
"0\n"
"0\n"
"reason=\"rejected\"\n"
"Total timed-out sessions via TIMEOUT\n"
"timeoutsessions\n"
"0\n"
"0\n"
"reason=\"timeout\"\n"
"Total timed-out sessions via SILENT_TIMEOUT\n"
"silenttimeoutsessions\n"
"0\n"
"0\n"
"reason=\"silent_timeout\"\n"
"Total timed-out sessions via FINAL_TIMEOUT\n"
"finaltimeoutsessions\n"
"0\n"
"0\n"
"reason=\"final_timeout\"\n"
"Total timed-out sessions via OFFER_TIMEOUT\n"
"offertimeoutsessions\n"
"0\n"
"0\n"
"reason=\"offer_timeout\"\n"
"Total regular terminated sessions\n"
"regularterminatedsessions\n"
"0\n"
"0\n"
"reason=\"terminated\"\n"
"Total forced terminated sessions\n"
"forcedterminatedsessions\n"
"0\n"
"0\n"
"reason=\"force_terminated\"\n"
"Total relayed packets\n"
"relayedpackets\n"
"0\n"
"0\n"
"Total relayed packet errors\n"
"relayedpacketerrors\n"
"0\n"
"0\n"
"Total relayed bytes\n"
"relayedbytes\n"
"0\n"
"0\n"
"Total number of streams with no relayed packets\n"
"zerowaystreams\n"
"0\n"
"0\n"
"Total number of 1-way streams\n"
"onewaystreams\n"
"0\n"
"0\n"
"Average call duration\n"
"avgcallduration\n"
"0.000000\n"
"0.000000\n"
"\n"
"\n"
"}\n"
"Graphite interval statistics (last reported values to graphite):\n"
"intervalstatistics\n"
"{\n"
"Total calls duration\n"
"totalcallsduration\n"
"0.000000\n"
"0.000000\n"
"\n"
"Min managed sessions\n"
"minmanagedsessions\n"
"0\n"
"0\n"
"Max managed sessions\n"
"maxmanagedsessions\n"
"0\n"
"0\n"
"Min/Max/Avg offer processing delay\n"
"2.500000/3.200000/2.850000 sec\n"
"minofferdelay\n"
"2.500000\n"
"maxofferdelay\n"
"3.200000\n"
"avgofferdelay\n"
"2.850000\n"
"Min/Max/Avg answer processing delay\n"
"0.000000/0.000000/0.000000 sec\n"
"minanswerdelay\n"
"0.000000\n"
"maxanswerdelay\n"
"0.000000\n"
"avganswerdelay\n"
"0.000000\n"
"Min/Max/Avg delete processing delay\n"
"0.000000/0.000000/0.000000 sec\n"
"mindeletedelay\n"
"0.000000\n"
"maxdeletedelay\n"
"0.000000\n"
"avgdeletedelay\n"
"0.000000\n"
"Min/Max/Avg offer requests per second\n"
"0/0/0 per sec\n"
"minofferrequestrate\n"
"0\n"
"maxofferrequestrate\n"
"0\n"
"avgofferrequestrate\n"
"0\n"
"Min/Max/Avg answer requests per second\n"
"0/0/0 per sec\n"
"minanswerrequestrate\n"
"0\n"
"maxanswerrequestrate\n"
"0\n"
"avganswerrequestrate\n"
"0\n"
"Min/Max/Avg delete requests per second\n"
"0/0/0 per sec\n"
"mindeleterequestrate\n"
"0\n"
"maxdeleterequestrate\n"
"0\n"
"avgdeleterequestrate\n"
"0\n"
"\n"
"\n"
"}\n"
"Control statistics:\n"
"controlstatistics\n"
"\n"
"{\n"
"proxies\n"
"[\n"
" Proxy | Ping | Offer | Answer | Delete | Query | List | StartRec | StopRec | StartFwd | StopFwd | BlkDTMF | UnblkDTMF | BlkMedia | UnblkMedia | PlayMedia | StopMedia | PlayDTMF | Stats | SlnMedia | UnslnMedia | Pub | SubReq | SubAns | Unsub \n"
"\n"
"]\n"
"totalpingcount\n"
"0\n"
"totaloffercount\n"
"0\n"
"totalanswercount\n"
"0\n"
"totaldeletecount\n"
"0\n"
"totalquerycount\n"
"0\n"
"totallistcount\n"
"0\n"
"totalstartreccount\n"
"0\n"
"totalstopreccount\n"
"0\n"
"totalstartfwdcount\n"
"0\n"
"totalstopfwdcount\n"
"0\n"
"totalblkdtmfcount\n"
"0\n"
"totalunblkdtmfcount\n"
"0\n"
"totalblkmediacount\n"
"0\n"
"totalunblkmediacount\n"
"0\n"
"totalplaymediacount\n"
"0\n"
"totalstopmediacount\n"
"0\n"
"totalplaydtmfcount\n"
"0\n"
"totalstatscount\n"
"0\n"
"totalslnmediacount\n"
"0\n"
"totalunslnmediacount\n"
"0\n"
"totalpubcount\n"
"0\n"
"totalsubreqcount\n"
"0\n"
"totalsubanscount\n"
"0\n"
"totalunsubcount\n"
"0\n"
"\n"
"}\n"
"interfaces\n"
"[\n"
"]\n"
"transcoders\n"
"\n"
"[\n"
"\n"
"]\n"
"}\n");
RTPE_STATS_INC(answers);
RTPE_GAUGE_SET(answer_time, 3200000);
graph_str = print_graphite_data(&rtpe_totalstats_lastinterval);
assert_g_string_eq(graph_str,
"offer_time_min 0.000000 150\n"
"offer_time_max 0.000000 150\n"
"offer_time_avg 0.000000 150\n"
"answer_time_min 3.200000 150\n"
"answer_time_max 3.200000 150\n"
"answer_time_avg 3.200000 150\n"
"delete_time_min 0.000000 150\n"
"delete_time_max 0.000000 150\n"
"delete_time_avg 0.000000 150\n"
"call_dur 0.000000 150\n"
"average_call_dur 0.000000 150\n"
"forced_term_sess 0 150\n"
"managed_sess 0 150\n"
"managed_sess_min 0 150\n"
"managed_sess_max 0 150\n"
"current_sessions_total 0 150\n"
"current_sessions_own 0 150\n"
"current_sessions_foreign 0 150\n"
"current_transcoded_media 0 150\n"
"current_sessions_ipv4 0 150\n"
"current_sessions_ipv6 0 150\n"
"current_sessions_mixed 0 150\n"
"nopacket_relayed_sess 0 150\n"
"oneway_stream_sess 0 150\n"
"regular_term_sess 0 150\n"
"relayed_errors 0 150\n"
"relayed_packets 0 150\n"
"silent_timeout_sess 0 150\n"
"final_timeout_sess 0 150\n"
"offer_timeout_sess 0 150\n"
"timeout_sess 0 150\n"
"reject_sess 0 150\n"
"offers_ps_min 0 150\n"
"offers_ps_max 0 150\n"
"offers_ps_avg 0 150\n"
"answers_ps_min 0 150\n"
"answers_ps_max 0 150\n"
"answers_ps_avg 0 150\n"
"deletes_ps_min 0 150\n"
"deletes_ps_max 0 150\n"
"deletes_ps_avg 0 150\n");
stats = statistics_gather_metrics();
assert_metrics_eq(stats,
"\n"
"{\n"
"Statistics over currently running sessions:\n"
"currentstatistics\n"
"\n"
"{\n"
"Owned sessions\n"
"sessionsown\n"
"0\n"
"0\n"
"type=\"own\"\n"
"Foreign sessions\n"
"sessionsforeign\n"
"0\n"
"0\n"
"type=\"foreign\"\n"
"Total sessions\n"
"sessionstotal\n"
"0\n"
"0\n"
"Transcoded media\n"
"transcodedmedia\n"
"0\n"
"0\n"
"Packets per second\n"
"packetrate\n"
"0\n"
"0\n"
"Bytes per second\n"
"byterate\n"
"0\n"
"0\n"
"Errors per second\n"
"errorrate\n"
"0\n"
"0\n"
"\n"
"}\n"
"Total statistics (does not include current running sessions):\n"
"totalstatistics\n"
"\n"
"{\n"
"Uptime of rtpengine\n"
"uptime\n"
"70 seconds\n"
"70\n"
"Total managed sessions\n"
"managedsessions\n"
"0\n"
"0\n"
"Total rejected sessions\n"
"rejectedsessions\n"
"0\n"
"0\n"
"reason=\"rejected\"\n"
"Total timed-out sessions via TIMEOUT\n"
"timeoutsessions\n"
"0\n"
"0\n"
"reason=\"timeout\"\n"
"Total timed-out sessions via SILENT_TIMEOUT\n"
"silenttimeoutsessions\n"
"0\n"
"0\n"
"reason=\"silent_timeout\"\n"
"Total timed-out sessions via FINAL_TIMEOUT\n"
"finaltimeoutsessions\n"
"0\n"
"0\n"
"reason=\"final_timeout\"\n"
"Total timed-out sessions via OFFER_TIMEOUT\n"
"offertimeoutsessions\n"
"0\n"
"0\n"
"reason=\"offer_timeout\"\n"
"Total regular terminated sessions\n"
"regularterminatedsessions\n"
"0\n"
"0\n"
"reason=\"terminated\"\n"
"Total forced terminated sessions\n"
"forcedterminatedsessions\n"
"0\n"
"0\n"
"reason=\"force_terminated\"\n"
"Total relayed packets\n"
"relayedpackets\n"
"0\n"
"0\n"
"Total relayed packet errors\n"
"relayedpacketerrors\n"
"0\n"
"0\n"
"Total relayed bytes\n"
"relayedbytes\n"
"0\n"
"0\n"
"Total number of streams with no relayed packets\n"
"zerowaystreams\n"
"0\n"
"0\n"
"Total number of 1-way streams\n"
"onewaystreams\n"
"0\n"
"0\n"
"Average call duration\n"
"avgcallduration\n"
"0.000000\n"
"0.000000\n"
"\n"
"\n"
"}\n"
"Graphite interval statistics (last reported values to graphite):\n"
"intervalstatistics\n"
"{\n"
"Total calls duration\n"
"totalcallsduration\n"
"0.000000\n"
"0.000000\n"
"\n"
"Min managed sessions\n"
"minmanagedsessions\n"
"0\n"
"0\n"
"Max managed sessions\n"
"maxmanagedsessions\n"
"0\n"
"0\n"
"Min/Max/Avg offer processing delay\n"
"0.000000/0.000000/0.000000 sec\n"
"minofferdelay\n"
"0.000000\n"
"maxofferdelay\n"
"0.000000\n"
"avgofferdelay\n"
"0.000000\n"
"Min/Max/Avg answer processing delay\n"
"3.200000/3.200000/3.200000 sec\n"
"minanswerdelay\n"
"3.200000\n"
"maxanswerdelay\n"
"3.200000\n"
"avganswerdelay\n"
"3.200000\n"
"Min/Max/Avg delete processing delay\n"
"0.000000/0.000000/0.000000 sec\n"
"mindeletedelay\n"
"0.000000\n"
"maxdeletedelay\n"
"0.000000\n"
"avgdeletedelay\n"
"0.000000\n"
"Min/Max/Avg offer requests per second\n"
"0/0/0 per sec\n"
"minofferrequestrate\n"
"0\n"
"maxofferrequestrate\n"
"0\n"
"avgofferrequestrate\n"
"0\n"
"Min/Max/Avg answer requests per second\n"
"0/0/0 per sec\n"
"minanswerrequestrate\n"
"0\n"
"maxanswerrequestrate\n"
"0\n"
"avganswerrequestrate\n"
"0\n"
"Min/Max/Avg delete requests per second\n"
"0/0/0 per sec\n"
"mindeleterequestrate\n"
"0\n"
"maxdeleterequestrate\n"
"0\n"
"avgdeleterequestrate\n"
"0\n"
"\n"
"\n"
"}\n"
"Control statistics:\n"
"controlstatistics\n"
"\n"
"{\n"
"proxies\n"
"[\n"
" Proxy | Ping | Offer | Answer | Delete | Query | List | StartRec | StopRec | StartFwd | StopFwd | BlkDTMF | UnblkDTMF | BlkMedia | UnblkMedia | PlayMedia | StopMedia | PlayDTMF | Stats | SlnMedia | UnslnMedia | Pub | SubReq | SubAns | Unsub \n"
"\n"
"]\n"
"totalpingcount\n"
"0\n"
"totaloffercount\n"
"0\n"
"totalanswercount\n"
"0\n"
"totaldeletecount\n"
"0\n"
"totalquerycount\n"
"0\n"
"totallistcount\n"
"0\n"
"totalstartreccount\n"
"0\n"
"totalstopreccount\n"
"0\n"
"totalstartfwdcount\n"
"0\n"
"totalstopfwdcount\n"
"0\n"
"totalblkdtmfcount\n"
"0\n"
"totalunblkdtmfcount\n"
"0\n"
"totalblkmediacount\n"
"0\n"
"totalunblkmediacount\n"
"0\n"
"totalplaymediacount\n"
"0\n"
"totalstopmediacount\n"
"0\n"
"totalplaydtmfcount\n"
"0\n"
"totalstatscount\n"
"0\n"
"totalslnmediacount\n"
"0\n"
"totalunslnmediacount\n"
"0\n"
"totalpubcount\n"
"0\n"
"totalsubreqcount\n"
"0\n"
"totalsubanscount\n"
"0\n"
"totalunsubcount\n"
"0\n"
"\n"
"}\n"
"interfaces\n"
"[\n"
"]\n"
"transcoders\n"
"\n"
"[\n"
"\n"
"]\n"
"}\n");
// test cmd_ps_min/max/avg
call_timer(NULL);
RTPE_STATS_ADD(offers, 100);
rtpe_now.tv_sec += 2;
RTPE_STATS_ADD(offers, 20);
call_timer(NULL);
// timer run time interval increased
rtpe_now.tv_sec += 5;
RTPE_STATS_ADD(offers, 200);
call_timer(NULL);
graph_str = print_graphite_data(&rtpe_totalstats_lastinterval);
assert_g_string_eq(graph_str,
"offer_time_min 0.000000 157\n"
"offer_time_max 0.000000 157\n"
"offer_time_avg 0.000000 157\n"
"answer_time_min 0.000000 157\n"
"answer_time_max 0.000000 157\n"
"answer_time_avg 0.000000 157\n"
"delete_time_min 0.000000 157\n"
"delete_time_max 0.000000 157\n"
"delete_time_avg 0.000000 157\n"
"call_dur 0.000000 157\n"
"average_call_dur 0.000000 157\n"
"forced_term_sess 0 157\n"
"managed_sess 0 157\n"
"managed_sess_min 0 157\n"
"managed_sess_max 0 157\n"
"current_sessions_total 0 157\n"
"current_sessions_own 0 157\n"
"current_sessions_foreign 0 157\n"
"current_transcoded_media 0 157\n"
"current_sessions_ipv4 0 157\n"
"current_sessions_ipv6 0 157\n"
"current_sessions_mixed 0 157\n"
"nopacket_relayed_sess 0 157\n"
"oneway_stream_sess 0 157\n"
"regular_term_sess 0 157\n"
"relayed_errors 0 157\n"
"relayed_packets 0 157\n"
"silent_timeout_sess 0 157\n"
"final_timeout_sess 0 157\n"
"offer_timeout_sess 0 157\n"
"timeout_sess 0 157\n"
"reject_sess 0 157\n"
"offers_ps_min 40 157\n"
"offers_ps_max 60 157\n"
"offers_ps_avg 33 157\n"
"answers_ps_min 0 157\n"
"answers_ps_max 0 157\n"
"answers_ps_avg 0 157\n"
"deletes_ps_min 0 157\n"
"deletes_ps_max 0 157\n"
"deletes_ps_avg 0 157\n");
stats = statistics_gather_metrics();
assert_metrics_eq(stats,
"\n"
"{\n"
"Statistics over currently running sessions:\n"
"currentstatistics\n"
"\n"
"{\n"
"Owned sessions\n"
"sessionsown\n"
"0\n"
"0\n"
"type=\"own\"\n"
"Foreign sessions\n"
"sessionsforeign\n"
"0\n"
"0\n"
"type=\"foreign\"\n"
"Total sessions\n"
"sessionstotal\n"
"0\n"
"0\n"
"Transcoded media\n"
"transcodedmedia\n"
"0\n"
"0\n"
"Packets per second\n"
"packetrate\n"
"0\n"
"0\n"
"Bytes per second\n"
"byterate\n"
"0\n"
"0\n"
"Errors per second\n"
"errorrate\n"
"0\n"
"0\n"
"\n"
"}\n"
"Total statistics (does not include current running sessions):\n"
"totalstatistics\n"
"\n"
"{\n"
"Uptime of rtpengine\n"
"uptime\n"
"77 seconds\n"
"77\n"
"Total managed sessions\n"
"managedsessions\n"
"0\n"
"0\n"
"Total rejected sessions\n"
"rejectedsessions\n"
"0\n"
"0\n"
"reason=\"rejected\"\n"
"Total timed-out sessions via TIMEOUT\n"
"timeoutsessions\n"
"0\n"
"0\n"
"reason=\"timeout\"\n"
"Total timed-out sessions via SILENT_TIMEOUT\n"
"silenttimeoutsessions\n"
"0\n"
"0\n"
"reason=\"silent_timeout\"\n"
"Total timed-out sessions via FINAL_TIMEOUT\n"
"finaltimeoutsessions\n"
"0\n"
"0\n"
"reason=\"final_timeout\"\n"
"Total timed-out sessions via OFFER_TIMEOUT\n"
"offertimeoutsessions\n"
"0\n"
"0\n"
"reason=\"offer_timeout\"\n"
"Total regular terminated sessions\n"
"regularterminatedsessions\n"
"0\n"
"0\n"
"reason=\"terminated\"\n"
"Total forced terminated sessions\n"
"forcedterminatedsessions\n"
"0\n"
"0\n"
"reason=\"force_terminated\"\n"
"Total relayed packets\n"
"relayedpackets\n"
"0\n"
"0\n"
"Total relayed packet errors\n"
"relayedpacketerrors\n"
"0\n"
"0\n"
"Total relayed bytes\n"
"relayedbytes\n"
"0\n"
"0\n"
"Total number of streams with no relayed packets\n"
"zerowaystreams\n"
"0\n"
"0\n"
"Total number of 1-way streams\n"
"onewaystreams\n"
"0\n"
"0\n"
"Average call duration\n"
"avgcallduration\n"
"0.000000\n"
"0.000000\n"
"\n"
"\n"
"}\n"
"Graphite interval statistics (last reported values to graphite):\n"
"intervalstatistics\n"
"{\n"
"Total calls duration\n"
"totalcallsduration\n"
"0.000000\n"
"0.000000\n"
"\n"
"Min managed sessions\n"
"minmanagedsessions\n"
"0\n"
"0\n"
"Max managed sessions\n"
"maxmanagedsessions\n"
"0\n"
"0\n"
"Min/Max/Avg offer processing delay\n"
"0.000000/0.000000/0.000000 sec\n"
"minofferdelay\n"
"0.000000\n"
"maxofferdelay\n"
"0.000000\n"
"avgofferdelay\n"
"0.000000\n"
"Min/Max/Avg answer processing delay\n"
"0.000000/0.000000/0.000000 sec\n"
"minanswerdelay\n"
"0.000000\n"
"maxanswerdelay\n"
"0.000000\n"
"avganswerdelay\n"
"0.000000\n"
"Min/Max/Avg delete processing delay\n"
"0.000000/0.000000/0.000000 sec\n"
"mindeletedelay\n"
"0.000000\n"
"maxdeletedelay\n"
"0.000000\n"
"avgdeletedelay\n"
"0.000000\n"
"Min/Max/Avg offer requests per second\n"
"40/60/33 per sec\n"
"minofferrequestrate\n"
"40\n"
"maxofferrequestrate\n"
"60\n"
"avgofferrequestrate\n"
"33\n"
"Min/Max/Avg answer requests per second\n"
"0/0/0 per sec\n"
"minanswerrequestrate\n"
"0\n"
"maxanswerrequestrate\n"
"0\n"
"avganswerrequestrate\n"
"0\n"
"Min/Max/Avg delete requests per second\n"
"0/0/0 per sec\n"
"mindeleterequestrate\n"
"0\n"
"maxdeleterequestrate\n"
"0\n"
"avgdeleterequestrate\n"
"0\n"
"\n"
"\n"
"}\n"
"Control statistics:\n"
"controlstatistics\n"
"\n"
"{\n"
"proxies\n"
"[\n"
" Proxy | Ping | Offer | Answer | Delete | Query | List | StartRec | StopRec | StartFwd | StopFwd | BlkDTMF | UnblkDTMF | BlkMedia | UnblkMedia | PlayMedia | StopMedia | PlayDTMF | Stats | SlnMedia | UnslnMedia | Pub | SubReq | SubAns | Unsub \n"
"\n"
"]\n"
"totalpingcount\n"
"0\n"
"totaloffercount\n"
"0\n"
"totalanswercount\n"
"0\n"
"totaldeletecount\n"
"0\n"
"totalquerycount\n"
"0\n"
"totallistcount\n"
"0\n"
"totalstartreccount\n"
"0\n"
"totalstopreccount\n"
"0\n"
"totalstartfwdcount\n"
"0\n"
"totalstopfwdcount\n"
"0\n"
"totalblkdtmfcount\n"
"0\n"
"totalunblkdtmfcount\n"
"0\n"
"totalblkmediacount\n"
"0\n"
"totalunblkmediacount\n"
"0\n"
"totalplaymediacount\n"
"0\n"
"totalstopmediacount\n"
"0\n"
"totalplaydtmfcount\n"
"0\n"
"totalstatscount\n"
"0\n"
"totalslnmediacount\n"
"0\n"
"totalunslnmediacount\n"
"0\n"
"totalpubcount\n"
"0\n"
"totalsubreqcount\n"
"0\n"
"totalsubanscount\n"
"0\n"
"totalunsubcount\n"
"0\n"
"\n"
"}\n"
"interfaces\n"
"[\n"
"]\n"
"transcoders\n"
"\n"
"[\n"
"\n"
"]\n"
"}\n");
// test average call duration
const str callid1 = STR_CONST_INIT("test1");
const str callid2 = STR_CONST_INIT("test2");
struct call *call1 = call_get_or_create(&callid1, false, true);
struct call_monologue *ml1 = call_get_or_create_monologue(call1, &callid1);
struct call *call2 = call_get_or_create(&callid2, false, true);
struct call_monologue *ml2 = call_get_or_create_monologue(call2, &callid2);
ml1->started = (struct timeval) {157,0};
ml2->started = (struct timeval) {57,0};
graph_str = print_graphite_data(&rtpe_totalstats_lastinterval);
assert_g_string_eq(graph_str,
"offer_time_min 0.000000 157\n"
"offer_time_max 0.000000 157\n"
"offer_time_avg 0.000000 157\n"
"answer_time_min 0.000000 157\n"
"answer_time_max 0.000000 157\n"
"answer_time_avg 0.000000 157\n"
"delete_time_min 0.000000 157\n"
"delete_time_max 0.000000 157\n"
"delete_time_avg 0.000000 157\n"
"call_dur 0.000000 157\n"
"average_call_dur 0.000000 157\n"
"forced_term_sess 0 157\n"
"managed_sess 0 157\n"
"managed_sess_min 0 157\n"
"managed_sess_max 2 157\n"
"current_sessions_total 2 157\n"
"current_sessions_own 2 157\n"
"current_sessions_foreign 0 157\n"
"current_transcoded_media 0 157\n"
"current_sessions_ipv4 0 157\n"
"current_sessions_ipv6 0 157\n"
"current_sessions_mixed 0 157\n"
"nopacket_relayed_sess 0 157\n"
"oneway_stream_sess 0 157\n"
"regular_term_sess 0 157\n"
"relayed_errors 0 157\n"
"relayed_packets 0 157\n"
"silent_timeout_sess 0 157\n"
"final_timeout_sess 0 157\n"
"offer_timeout_sess 0 157\n"
"timeout_sess 0 157\n"
"reject_sess 0 157\n"
"offers_ps_min 0 157\n"
"offers_ps_max 0 157\n"
"offers_ps_avg 0 157\n"
"answers_ps_min 0 157\n"
"answers_ps_max 0 157\n"
"answers_ps_avg 0 157\n"
"deletes_ps_min 0 157\n"
"deletes_ps_max 0 157\n"
"deletes_ps_avg 0 157\n");
stats = statistics_gather_metrics();
assert_metrics_eq(stats,
"\n"
"{\n"
"Statistics over currently running sessions:\n"
"currentstatistics\n"
"\n"
"{\n"
"Owned sessions\n"
"sessionsown\n"
"2\n"
"2\n"
"type=\"own\"\n"
"Foreign sessions\n"
"sessionsforeign\n"
"0\n"
"0\n"
"type=\"foreign\"\n"
"Total sessions\n"
"sessionstotal\n"
"2\n"
"2\n"
"Transcoded media\n"
"transcodedmedia\n"
"0\n"
"0\n"
"Packets per second\n"
"packetrate\n"
"0\n"
"0\n"
"Bytes per second\n"
"byterate\n"
"0\n"
"0\n"
"Errors per second\n"
"errorrate\n"
"0\n"
"0\n"
"\n"
"}\n"
"Total statistics (does not include current running sessions):\n"
"totalstatistics\n"
"\n"
"{\n"
"Uptime of rtpengine\n"
"uptime\n"
"77 seconds\n"
"77\n"
"Total managed sessions\n"
"managedsessions\n"
"0\n"
"0\n"
"Total rejected sessions\n"
"rejectedsessions\n"
"0\n"
"0\n"
"reason=\"rejected\"\n"
"Total timed-out sessions via TIMEOUT\n"
"timeoutsessions\n"
"0\n"
"0\n"
"reason=\"timeout\"\n"
"Total timed-out sessions via SILENT_TIMEOUT\n"
"silenttimeoutsessions\n"
"0\n"
"0\n"
"reason=\"silent_timeout\"\n"
"Total timed-out sessions via FINAL_TIMEOUT\n"
"finaltimeoutsessions\n"
"0\n"
"0\n"
"reason=\"final_timeout\"\n"
"Total timed-out sessions via OFFER_TIMEOUT\n"
"offertimeoutsessions\n"
"0\n"
"0\n"
"reason=\"offer_timeout\"\n"
"Total regular terminated sessions\n"
"regularterminatedsessions\n"
"0\n"
"0\n"
"reason=\"terminated\"\n"
"Total forced terminated sessions\n"
"forcedterminatedsessions\n"
"0\n"
"0\n"
"reason=\"force_terminated\"\n"
"Total relayed packets\n"
"relayedpackets\n"
"0\n"
"0\n"
"Total relayed packet errors\n"
"relayedpacketerrors\n"
"0\n"
"0\n"
"Total relayed bytes\n"
"relayedbytes\n"
"0\n"
"0\n"
"Total number of streams with no relayed packets\n"
"zerowaystreams\n"
"0\n"
"0\n"
"Total number of 1-way streams\n"
"onewaystreams\n"
"0\n"
"0\n"
"Average call duration\n"
"avgcallduration\n"
"0.000000\n"
"0.000000\n"
"\n"
"\n"
"}\n"
"Graphite interval statistics (last reported values to graphite):\n"
"intervalstatistics\n"
"{\n"
"Total calls duration\n"
"totalcallsduration\n"
"0.000000\n"
"0.000000\n"
"\n"
"Min managed sessions\n"
"minmanagedsessions\n"
"0\n"
"0\n"
"Max managed sessions\n"
"maxmanagedsessions\n"
"2\n"
"2\n"
"Min/Max/Avg offer processing delay\n"
"0.000000/0.000000/0.000000 sec\n"
"minofferdelay\n"
"0.000000\n"
"maxofferdelay\n"
"0.000000\n"
"avgofferdelay\n"
"0.000000\n"
"Min/Max/Avg answer processing delay\n"
"0.000000/0.000000/0.000000 sec\n"
"minanswerdelay\n"
"0.000000\n"
"maxanswerdelay\n"
"0.000000\n"
"avganswerdelay\n"
"0.000000\n"
"Min/Max/Avg delete processing delay\n"
"0.000000/0.000000/0.000000 sec\n"
"mindeletedelay\n"
"0.000000\n"
"maxdeletedelay\n"
"0.000000\n"
"avgdeletedelay\n"
"0.000000\n"
"Min/Max/Avg offer requests per second\n"
"0/0/0 per sec\n"
"minofferrequestrate\n"
"0\n"
"maxofferrequestrate\n"
"0\n"
"avgofferrequestrate\n"
"0\n"
"Min/Max/Avg answer requests per second\n"
"0/0/0 per sec\n"
"minanswerrequestrate\n"
"0\n"
"maxanswerrequestrate\n"
"0\n"
"avganswerrequestrate\n"
"0\n"
"Min/Max/Avg delete requests per second\n"
"0/0/0 per sec\n"
"mindeleterequestrate\n"
"0\n"
"maxdeleterequestrate\n"
"0\n"
"avgdeleterequestrate\n"
"0\n"
"\n"
"\n"
"}\n"
"Control statistics:\n"
"controlstatistics\n"
"\n"
"{\n"
"proxies\n"
"[\n"
" Proxy | Ping | Offer | Answer | Delete | Query | List | StartRec | StopRec | StartFwd | StopFwd | BlkDTMF | UnblkDTMF | BlkMedia | UnblkMedia | PlayMedia | StopMedia | PlayDTMF | Stats | SlnMedia | UnslnMedia | Pub | SubReq | SubAns | Unsub \n"
"\n"
"]\n"
"totalpingcount\n"
"0\n"
"totaloffercount\n"
"0\n"
"totalanswercount\n"
"0\n"
"totaldeletecount\n"
"0\n"
"totalquerycount\n"
"0\n"
"totallistcount\n"
"0\n"
"totalstartreccount\n"
"0\n"
"totalstopreccount\n"
"0\n"
"totalstartfwdcount\n"
"0\n"
"totalstopfwdcount\n"
"0\n"
"totalblkdtmfcount\n"
"0\n"
"totalunblkdtmfcount\n"
"0\n"
"totalblkmediacount\n"
"0\n"
"totalunblkmediacount\n"
"0\n"
"totalplaymediacount\n"
"0\n"
"totalstopmediacount\n"
"0\n"
"totalplaydtmfcount\n"
"0\n"
"totalstatscount\n"
"0\n"
"totalslnmediacount\n"
"0\n"
"totalunslnmediacount\n"
"0\n"
"totalpubcount\n"
"0\n"
"totalsubreqcount\n"
"0\n"
"totalsubanscount\n"
"0\n"
"totalunsubcount\n"
"0\n"
"\n"
"}\n"
"interfaces\n"
"[\n"
"]\n"
"transcoders\n"
"\n"
"[\n"
"\n"
"]\n"
"}\n");
struct timeval graphite_interval_tv = {100,0};
rtpe_now = (struct timeval) {200,0};
add_total_calls_duration_in_interval(&graphite_interval_tv);
graph_str = print_graphite_data(&rtpe_totalstats_lastinterval);
assert_g_string_eq(graph_str,
"offer_time_min 0.000000 200\n"
"offer_time_max 0.000000 200\n"
"offer_time_avg 0.000000 200\n"
"answer_time_min 0.000000 200\n"
"answer_time_max 0.000000 200\n"
"answer_time_avg 0.000000 200\n"
"delete_time_min 0.000000 200\n"
"delete_time_max 0.000000 200\n"
"delete_time_avg 0.000000 200\n"
"call_dur 186.000000 200\n"
"average_call_dur 0.000000 200\n"
"forced_term_sess 0 200\n"
"managed_sess 0 200\n"
"managed_sess_min 2 200\n"
"managed_sess_max 2 200\n"
"current_sessions_total 2 200\n"
"current_sessions_own 2 200\n"
"current_sessions_foreign 0 200\n"
"current_transcoded_media 0 200\n"
"current_sessions_ipv4 0 200\n"
"current_sessions_ipv6 0 200\n"
"current_sessions_mixed 0 200\n"
"nopacket_relayed_sess 0 200\n"
"oneway_stream_sess 0 200\n"
"regular_term_sess 0 200\n"
"relayed_errors 0 200\n"
"relayed_packets 0 200\n"
"silent_timeout_sess 0 200\n"
"final_timeout_sess 0 200\n"
"offer_timeout_sess 0 200\n"
"timeout_sess 0 200\n"
"reject_sess 0 200\n"
"offers_ps_min 0 200\n"
"offers_ps_max 0 200\n"
"offers_ps_avg 0 200\n"
"answers_ps_min 0 200\n"
"answers_ps_max 0 200\n"
"answers_ps_avg 0 200\n"
"deletes_ps_min 0 200\n"
"deletes_ps_max 0 200\n"
"deletes_ps_avg 0 200\n");
stats = statistics_gather_metrics();
assert_metrics_eq(stats,
"\n"
"{\n"
"Statistics over currently running sessions:\n"
"currentstatistics\n"
"\n"
"{\n"
"Owned sessions\n"
"sessionsown\n"
"2\n"
"2\n"
"type=\"own\"\n"
"Foreign sessions\n"
"sessionsforeign\n"
"0\n"
"0\n"
"type=\"foreign\"\n"
"Total sessions\n"
"sessionstotal\n"
"2\n"
"2\n"
"Transcoded media\n"
"transcodedmedia\n"
"0\n"
"0\n"
"Packets per second\n"
"packetrate\n"
"0\n"
"0\n"
"Bytes per second\n"
"byterate\n"
"0\n"
"0\n"
"Errors per second\n"
"errorrate\n"
"0\n"
"0\n"
"\n"
"}\n"
"Total statistics (does not include current running sessions):\n"
"totalstatistics\n"
"\n"
"{\n"
"Uptime of rtpengine\n"
"uptime\n"
"120 seconds\n"
"120\n"
"Total managed sessions\n"
"managedsessions\n"
"0\n"
"0\n"
"Total rejected sessions\n"
"rejectedsessions\n"
"0\n"
"0\n"
"reason=\"rejected\"\n"
"Total timed-out sessions via TIMEOUT\n"
"timeoutsessions\n"
"0\n"
"0\n"
"reason=\"timeout\"\n"
"Total timed-out sessions via SILENT_TIMEOUT\n"
"silenttimeoutsessions\n"
"0\n"
"0\n"
"reason=\"silent_timeout\"\n"
"Total timed-out sessions via FINAL_TIMEOUT\n"
"finaltimeoutsessions\n"
"0\n"
"0\n"
"reason=\"final_timeout\"\n"
"Total timed-out sessions via OFFER_TIMEOUT\n"
"offertimeoutsessions\n"
"0\n"
"0\n"
"reason=\"offer_timeout\"\n"
"Total regular terminated sessions\n"
"regularterminatedsessions\n"
"0\n"
"0\n"
"reason=\"terminated\"\n"
"Total forced terminated sessions\n"
"forcedterminatedsessions\n"
"0\n"
"0\n"
"reason=\"force_terminated\"\n"
"Total relayed packets\n"
"relayedpackets\n"
"0\n"
"0\n"
"Total relayed packet errors\n"
"relayedpacketerrors\n"
"0\n"
"0\n"
"Total relayed bytes\n"
"relayedbytes\n"
"0\n"
"0\n"
"Total number of streams with no relayed packets\n"
"zerowaystreams\n"
"0\n"
"0\n"
"Total number of 1-way streams\n"
"onewaystreams\n"
"0\n"
"0\n"
"Average call duration\n"
"avgcallduration\n"
"0.000000\n"
"0.000000\n"
"\n"
"\n"
"}\n"
"Graphite interval statistics (last reported values to graphite):\n"
"intervalstatistics\n"
"{\n"
"Total calls duration\n"
"totalcallsduration\n"
"186.000000\n"
"186.000000\n"
"\n"
"Min managed sessions\n"
"minmanagedsessions\n"
"2\n"
"2\n"
"Max managed sessions\n"
"maxmanagedsessions\n"
"2\n"
"2\n"
"Min/Max/Avg offer processing delay\n"
"0.000000/0.000000/0.000000 sec\n"
"minofferdelay\n"
"0.000000\n"
"maxofferdelay\n"
"0.000000\n"
"avgofferdelay\n"
"0.000000\n"
"Min/Max/Avg answer processing delay\n"
"0.000000/0.000000/0.000000 sec\n"
"minanswerdelay\n"
"0.000000\n"
"maxanswerdelay\n"
"0.000000\n"
"avganswerdelay\n"
"0.000000\n"
"Min/Max/Avg delete processing delay\n"
"0.000000/0.000000/0.000000 sec\n"
"mindeletedelay\n"
"0.000000\n"
"maxdeletedelay\n"
"0.000000\n"
"avgdeletedelay\n"
"0.000000\n"
"Min/Max/Avg offer requests per second\n"
"0/0/0 per sec\n"
"minofferrequestrate\n"
"0\n"
"maxofferrequestrate\n"
"0\n"
"avgofferrequestrate\n"
"0\n"
"Min/Max/Avg answer requests per second\n"
"0/0/0 per sec\n"
"minanswerrequestrate\n"
"0\n"
"maxanswerrequestrate\n"
"0\n"
"avganswerrequestrate\n"
"0\n"
"Min/Max/Avg delete requests per second\n"
"0/0/0 per sec\n"
"mindeleterequestrate\n"
"0\n"
"maxdeleterequestrate\n"
"0\n"
"avgdeleterequestrate\n"
"0\n"
"\n"
"\n"
"}\n"
"Control statistics:\n"
"controlstatistics\n"
"\n"
"{\n"
"proxies\n"
"[\n"
" Proxy | Ping | Offer | Answer | Delete | Query | List | StartRec | StopRec | StartFwd | StopFwd | BlkDTMF | UnblkDTMF | BlkMedia | UnblkMedia | PlayMedia | StopMedia | PlayDTMF | Stats | SlnMedia | UnslnMedia | Pub | SubReq | SubAns | Unsub \n"
"\n"
"]\n"
"totalpingcount\n"
"0\n"
"totaloffercount\n"
"0\n"
"totalanswercount\n"
"0\n"
"totaldeletecount\n"
"0\n"
"totalquerycount\n"
"0\n"
"totallistcount\n"
"0\n"
"totalstartreccount\n"
"0\n"
"totalstopreccount\n"
"0\n"
"totalstartfwdcount\n"
"0\n"
"totalstopfwdcount\n"
"0\n"
"totalblkdtmfcount\n"
"0\n"
"totalunblkdtmfcount\n"
"0\n"
"totalblkmediacount\n"
"0\n"
"totalunblkmediacount\n"
"0\n"
"totalplaymediacount\n"
"0\n"
"totalstopmediacount\n"
"0\n"
"totalplaydtmfcount\n"
"0\n"
"totalstatscount\n"
"0\n"
"totalslnmediacount\n"
"0\n"
"totalunslnmediacount\n"
"0\n"
"totalpubcount\n"
"0\n"
"totalsubreqcount\n"
"0\n"
"totalsubanscount\n"
"0\n"
"totalunsubcount\n"
"0\n"
"\n"
"}\n"
"interfaces\n"
"[\n"
"]\n"
"transcoders\n"
"\n"
"[\n"
"\n"
"]\n"
"}\n");
call_destroy(call1);
call_destroy(call2);
obj_put(call1);
obj_put(call2);
// test average call duration
graph_str = print_graphite_data(&rtpe_totalstats_lastinterval);
assert_g_string_eq(graph_str,
"offer_time_min 0.000000 200\n"
"offer_time_max 0.000000 200\n"
"offer_time_avg 0.000000 200\n"
"answer_time_min 0.000000 200\n"
"answer_time_max 0.000000 200\n"
"answer_time_avg 0.000000 200\n"
"delete_time_min 0.000000 200\n"
"delete_time_max 0.000000 200\n"
"delete_time_avg 0.000000 200\n"
"call_dur 0.000000 200\n"
"average_call_dur 93.000000 200\n"
"forced_term_sess 0 200\n"
"managed_sess 2 200\n"
"managed_sess_min 0 200\n"
"managed_sess_max 2 200\n"
"current_sessions_total 0 200\n"
"current_sessions_own 0 200\n"
"current_sessions_foreign 0 200\n"
"current_transcoded_media 0 200\n"
"current_sessions_ipv4 0 200\n"
"current_sessions_ipv6 0 200\n"
"current_sessions_mixed 0 200\n"
"nopacket_relayed_sess 2 200\n"
"oneway_stream_sess 0 200\n"
"regular_term_sess 0 200\n"
"relayed_errors 0 200\n"
"relayed_packets 0 200\n"
"silent_timeout_sess 0 200\n"
"final_timeout_sess 0 200\n"
"offer_timeout_sess 0 200\n"
"timeout_sess 0 200\n"
"reject_sess 0 200\n"
"offers_ps_min 0 200\n"
"offers_ps_max 0 200\n"
"offers_ps_avg 0 200\n"
"answers_ps_min 0 200\n"
"answers_ps_max 0 200\n"
"answers_ps_avg 0 200\n"
"deletes_ps_min 0 200\n"
"deletes_ps_max 0 200\n"
"deletes_ps_avg 0 200\n");
stats = statistics_gather_metrics();
assert_metrics_eq(stats,
"\n"
"{\n"
"Statistics over currently running sessions:\n"
"currentstatistics\n"
"\n"
"{\n"
"Owned sessions\n"
"sessionsown\n"
"0\n"
"0\n"
"type=\"own\"\n"
"Foreign sessions\n"
"sessionsforeign\n"
"0\n"
"0\n"
"type=\"foreign\"\n"
"Total sessions\n"
"sessionstotal\n"
"0\n"
"0\n"
"Transcoded media\n"
"transcodedmedia\n"
"0\n"
"0\n"
"Packets per second\n"
"packetrate\n"
"0\n"
"0\n"
"Bytes per second\n"
"byterate\n"
"0\n"
"0\n"
"Errors per second\n"
"errorrate\n"
"0\n"
"0\n"
"\n"
"}\n"
"Total statistics (does not include current running sessions):\n"
"totalstatistics\n"
"\n"
"{\n"
"Uptime of rtpengine\n"
"uptime\n"
"120 seconds\n"
"120\n"
"Total managed sessions\n"
"managedsessions\n"
"2\n"
"2\n"
"Total rejected sessions\n"
"rejectedsessions\n"
"0\n"
"0\n"
"reason=\"rejected\"\n"
"Total timed-out sessions via TIMEOUT\n"
"timeoutsessions\n"
"0\n"
"0\n"
"reason=\"timeout\"\n"
"Total timed-out sessions via SILENT_TIMEOUT\n"
"silenttimeoutsessions\n"
"0\n"
"0\n"
"reason=\"silent_timeout\"\n"
"Total timed-out sessions via FINAL_TIMEOUT\n"
"finaltimeoutsessions\n"
"0\n"
"0\n"
"reason=\"final_timeout\"\n"
"Total timed-out sessions via OFFER_TIMEOUT\n"
"offertimeoutsessions\n"
"0\n"
"0\n"
"reason=\"offer_timeout\"\n"
"Total regular terminated sessions\n"
"regularterminatedsessions\n"
"0\n"
"0\n"
"reason=\"terminated\"\n"
"Total forced terminated sessions\n"
"forcedterminatedsessions\n"
"0\n"
"0\n"
"reason=\"force_terminated\"\n"
"Total relayed packets\n"
"relayedpackets\n"
"0\n"
"0\n"
"Total relayed packet errors\n"
"relayedpacketerrors\n"
"0\n"
"0\n"
"Total relayed bytes\n"
"relayedbytes\n"
"0\n"
"0\n"
"Total number of streams with no relayed packets\n"
"zerowaystreams\n"
"2\n"
"2\n"
"Total number of 1-way streams\n"
"onewaystreams\n"
"0\n"
"0\n"
"Average call duration\n"
"avgcallduration\n"
"93.000000\n"
"93.000000\n"
"\n"
"\n"
"}\n"
"Graphite interval statistics (last reported values to graphite):\n"
"intervalstatistics\n"
"{\n"
"Total calls duration\n"
"totalcallsduration\n"
"0.000000\n"
"0.000000\n"
"\n"
"Min managed sessions\n"
"minmanagedsessions\n"
"0\n"
"0\n"
"Max managed sessions\n"
"maxmanagedsessions\n"
"2\n"
"2\n"
"Min/Max/Avg offer processing delay\n"
"0.000000/0.000000/0.000000 sec\n"
"minofferdelay\n"
"0.000000\n"
"maxofferdelay\n"
"0.000000\n"
"avgofferdelay\n"
"0.000000\n"
"Min/Max/Avg answer processing delay\n"
"0.000000/0.000000/0.000000 sec\n"
"minanswerdelay\n"
"0.000000\n"
"maxanswerdelay\n"
"0.000000\n"
"avganswerdelay\n"
"0.000000\n"
"Min/Max/Avg delete processing delay\n"
"0.000000/0.000000/0.000000 sec\n"
"mindeletedelay\n"
"0.000000\n"
"maxdeletedelay\n"
"0.000000\n"
"avgdeletedelay\n"
"0.000000\n"
"Min/Max/Avg offer requests per second\n"
"0/0/0 per sec\n"
"minofferrequestrate\n"
"0\n"
"maxofferrequestrate\n"
"0\n"
"avgofferrequestrate\n"
"0\n"
"Min/Max/Avg answer requests per second\n"
"0/0/0 per sec\n"
"minanswerrequestrate\n"
"0\n"
"maxanswerrequestrate\n"
"0\n"
"avganswerrequestrate\n"
"0\n"
"Min/Max/Avg delete requests per second\n"
"0/0/0 per sec\n"
"mindeleterequestrate\n"
"0\n"
"maxdeleterequestrate\n"
"0\n"
"avgdeleterequestrate\n"
"0\n"
"\n"
"\n"
"}\n"
"Control statistics:\n"
"controlstatistics\n"
"\n"
"{\n"
"proxies\n"
"[\n"
" Proxy | Ping | Offer | Answer | Delete | Query | List | StartRec | StopRec | StartFwd | StopFwd | BlkDTMF | UnblkDTMF | BlkMedia | UnblkMedia | PlayMedia | StopMedia | PlayDTMF | Stats | SlnMedia | UnslnMedia | Pub | SubReq | SubAns | Unsub \n"
"\n"
"]\n"
"totalpingcount\n"
"0\n"
"totaloffercount\n"
"0\n"
"totalanswercount\n"
"0\n"
"totaldeletecount\n"
"0\n"
"totalquerycount\n"
"0\n"
"totallistcount\n"
"0\n"
"totalstartreccount\n"
"0\n"
"totalstopreccount\n"
"0\n"
"totalstartfwdcount\n"
"0\n"
"totalstopfwdcount\n"
"0\n"
"totalblkdtmfcount\n"
"0\n"
"totalunblkdtmfcount\n"
"0\n"
"totalblkmediacount\n"
"0\n"
"totalunblkmediacount\n"
"0\n"
"totalplaymediacount\n"
"0\n"
"totalstopmediacount\n"
"0\n"
"totalplaydtmfcount\n"
"0\n"
"totalstatscount\n"
"0\n"
"totalslnmediacount\n"
"0\n"
"totalunslnmediacount\n"
"0\n"
"totalpubcount\n"
"0\n"
"totalsubreqcount\n"
"0\n"
"totalsubanscount\n"
"0\n"
"totalunsubcount\n"
"0\n"
"\n"
"}\n"
"interfaces\n"
"[\n"
"]\n"
"transcoders\n"
"\n"
"[\n"
"\n"
"]\n"
"}\n");
// cleanup
statistics_free();
call_free();
call_interfaces_free();
control_ng_cleanup();
dtls_cert_free();
return 0;
}
int get_local_log_level(unsigned int u) {
return 7;
}