This commit is contained in:
Thomas Ries
2016-09-18 11:51:37 +00:00
parent bf51f8effe
commit 6eaf2bd6f9
+84 -106
View File
@@ -257,111 +257,89 @@ static void stats_prepare(void) {
#define TESTING 0
#if TESTING
{
int k=RTPPROXY_SIZE/2;
rtp_proxytable[k].rtp_rx_sock=555;
strcpy(rtp_proxytable[k].client_id.idstring, "Client-Id");
strcpy(rtp_proxytable[k].callid_number, "CallID-Number2");
strcpy(rtp_proxytable[k].callid_host, "CallID-Host");
rtp_proxytable[k].direction=DIR_INCOMING;
rtp_proxytable[k].call_direction=DIR_INCOMING;
rtp_proxytable[k].media_stream_no=1;
rtp_proxytable[k].timestamp=1472844291;
k++;
rtp_proxytable[k].rtp_rx_sock=555;
strcpy(rtp_proxytable[k].client_id.idstring, "Client-Id");
strcpy(rtp_proxytable[k].callid_number, "CallID-Number2");
strcpy(rtp_proxytable[k].callid_host, "CallID-Host");
rtp_proxytable[k].direction=DIR_OUTGOING;
rtp_proxytable[k].call_direction=DIR_INCOMING;
rtp_proxytable[k].media_stream_no=2;
rtp_proxytable[k].timestamp=1472844291;
{
int k=RTPPROXY_SIZE/2;
rtp_proxytable[k].rtp_rx_sock=555;
strcpy(rtp_proxytable[k].client_id.idstring, "Client-Id");
strcpy(rtp_proxytable[k].callid_number, "CallID-Number2");
strcpy(rtp_proxytable[k].callid_host, "CallID-Host");
rtp_proxytable[k].direction=DIR_INCOMING;
rtp_proxytable[k].call_direction=DIR_INCOMING;
rtp_proxytable[k].media_stream_no=1;
rtp_proxytable[k].timestamp=1472844291;
k++;
rtp_proxytable[k].rtp_rx_sock=555;
strcpy(rtp_proxytable[k].client_id.idstring, "Client-Id");
strcpy(rtp_proxytable[k].callid_number, "CallID-Number2");
strcpy(rtp_proxytable[k].callid_host, "CallID-Host");
rtp_proxytable[k].direction=DIR_OUTGOING;
rtp_proxytable[k].call_direction=DIR_INCOMING;
rtp_proxytable[k].media_stream_no=2;
rtp_proxytable[k].timestamp=1472844291;
k++;
rtp_proxytable[k].rtp_rx_sock=555;
strcpy(rtp_proxytable[k].client_id.idstring, "Client-Id");
strcpy(rtp_proxytable[k].callid_number, "CallID-Number1");
strcpy(rtp_proxytable[k].callid_host, "CallID-Host2");
rtp_proxytable[k].direction=DIR_INCOMING;
rtp_proxytable[k].call_direction=DIR_INCOMING;
rtp_proxytable[k].media_stream_no=1;
rtp_proxytable[k].timestamp=1472844291;
k++;
rtp_proxytable[k].rtp_rx_sock=555;
strcpy(rtp_proxytable[k].client_id.idstring, "Client-Id");
strcpy(rtp_proxytable[k].callid_number, "CallID-Number1");
strcpy(rtp_proxytable[k].callid_host, "CallID-Host2");
rtp_proxytable[k].direction=DIR_OUTGOING;
rtp_proxytable[k].call_direction=DIR_INCOMING;
rtp_proxytable[k].media_stream_no=2;
rtp_proxytable[k].timestamp=1472844291;
k++;
rtp_proxytable[k].rtp_rx_sock=555;
strcpy(rtp_proxytable[k].client_id.idstring, "Client-Id");
strcpy(rtp_proxytable[k].callid_number, "CallID-Number1");
strcpy(rtp_proxytable[k].callid_host, "CallID-Host2");
rtp_proxytable[k].direction=DIR_INCOMING;
rtp_proxytable[k].call_direction=DIR_INCOMING;
rtp_proxytable[k].media_stream_no=1;
rtp_proxytable[k].timestamp=1472844291;
k++;
rtp_proxytable[k].rtp_rx_sock=555;
strcpy(rtp_proxytable[k].client_id.idstring, "Client-Id");
strcpy(rtp_proxytable[k].callid_number, "CallID-Number1");
strcpy(rtp_proxytable[k].callid_host, "CallID-Host2");
rtp_proxytable[k].direction=DIR_OUTGOING;
rtp_proxytable[k].call_direction=DIR_INCOMING;
rtp_proxytable[k].media_stream_no=2;
rtp_proxytable[k].timestamp=1472844291;
k++;
rtp_proxytable[k].rtp_rx_sock=555;
strcpy(rtp_proxytable[k].client_id.idstring, "Client-02");
strcpy(rtp_proxytable[k].callid_number, "CallID-Number");
strcpy(rtp_proxytable[k].callid_host, "CallID-Host");
rtp_proxytable[k].direction=DIR_INCOMING;
rtp_proxytable[k].call_direction=DIR_INCOMING;
rtp_proxytable[k].media_stream_no=1;
rtp_proxytable[k].timestamp=1472848291;
k++;
rtp_proxytable[k].rtp_rx_sock=555;
strcpy(rtp_proxytable[k].client_id.idstring, "Client-02");
strcpy(rtp_proxytable[k].callid_number, "CallID-Number");
strcpy(rtp_proxytable[k].callid_host, "CallID-Host");
rtp_proxytable[k].direction=DIR_OUTGOING;
rtp_proxytable[k].call_direction=DIR_INCOMING;
rtp_proxytable[k].media_stream_no=2;
rtp_proxytable[k].timestamp=1472848291;
k++;
rtp_proxytable[k].rtp_rx_sock=555;
strcpy(rtp_proxytable[k].client_id.idstring, "Client-02");
strcpy(rtp_proxytable[k].callid_number, "CallID-Number");
strcpy(rtp_proxytable[k].callid_host, "CallID-Host");
rtp_proxytable[k].direction=DIR_INCOMING;
rtp_proxytable[k].call_direction=DIR_INCOMING;
rtp_proxytable[k].media_stream_no=1;
rtp_proxytable[k].timestamp=1472848291;
k++;
rtp_proxytable[k].rtp_rx_sock=555;
strcpy(rtp_proxytable[k].client_id.idstring, "Client-02");
strcpy(rtp_proxytable[k].callid_number, "CallID-Number");
strcpy(rtp_proxytable[k].callid_host, "CallID-Host");
rtp_proxytable[k].direction=DIR_OUTGOING;
rtp_proxytable[k].call_direction=DIR_INCOMING;
rtp_proxytable[k].media_stream_no=2;
rtp_proxytable[k].timestamp=1472848291;
k++;
rtp_proxytable[k].rtp_rx_sock=555;
strcpy(rtp_proxytable[k].client_id.idstring, "ABC-02");
strcpy(rtp_proxytable[k].callid_number, "XXX02-Number");
strcpy(rtp_proxytable[k].callid_host, "CallID-Host");
rtp_proxytable[k].direction=DIR_INCOMING;
rtp_proxytable[k].call_direction=DIR_OUTGOING;
rtp_proxytable[k].media_stream_no=1;
rtp_proxytable[k].timestamp=1472848291;
k++;
rtp_proxytable[k].rtp_rx_sock=555;
strcpy(rtp_proxytable[k].client_id.idstring, "ABC-02");
strcpy(rtp_proxytable[k].callid_number, "XXX02-Number");
strcpy(rtp_proxytable[k].callid_host, "CallID-Host");
rtp_proxytable[k].direction=DIR_OUTGOING;
rtp_proxytable[k].call_direction=DIR_OUTGOING;
rtp_proxytable[k].media_stream_no=2;
rtp_proxytable[k].timestamp=1472848291;
#if 0
typedef struct {
int rtp_rx_sock; /* rx socket (0 -> free slot)*/
int rtp_tx_sock; /* tx socket */
int rtp_con_rx_sock; /* rx socket rtcp */
int rtp_con_tx_sock; /* tx socket rtcp */
char callid_number[CALLIDNUM_SIZE]; /* call ID */
char callid_host[CALLIDHOST_SIZE]; /* --"-- */
client_id_t client_id;
int direction; /* Direction of RTP stream */
int call_direction; /* Direction of Call DIR_x */
int media_stream_no;
timecontrol_t tc; /* de-jitter feature */
struct in_addr local_ipaddr; /* local IP */
int local_port; /* local allocated port */
struct in_addr remote_ipaddr; /* remote IP */
int remote_port; /* remote port */
time_t timestamp; /* last 'stream alive' TS */
int opposite_entry; /* 0 based index of opposite entry */
#endif
}
k++;
rtp_proxytable[k].rtp_rx_sock=555;
strcpy(rtp_proxytable[k].client_id.idstring, "ABC-02");
strcpy(rtp_proxytable[k].callid_number, "XXX02-Number");
strcpy(rtp_proxytable[k].callid_host, "CallID-Host");
rtp_proxytable[k].direction=DIR_INCOMING;
rtp_proxytable[k].call_direction=DIR_OUTGOING;
rtp_proxytable[k].media_stream_no=1;
rtp_proxytable[k].timestamp=1472848291;
k++;
rtp_proxytable[k].rtp_rx_sock=555;
strcpy(rtp_proxytable[k].client_id.idstring, "ABC-02");
strcpy(rtp_proxytable[k].callid_number, "XXX02-Number");
strcpy(rtp_proxytable[k].callid_host, "CallID-Host");
rtp_proxytable[k].direction=DIR_OUTGOING;
rtp_proxytable[k].call_direction=DIR_OUTGOING;
rtp_proxytable[k].media_stream_no=2;
rtp_proxytable[k].timestamp=1472848291;
}
#endif
// loop through rtp_proxytable and populate idx_to_rtp_proxytable
for (i=0; i < RTPPROXY_SIZE; i++) {
if (rtp_proxytable[i].rtp_rx_sock) {
DEBUGC(DBCLASS_PLUGIN,"populate: rtpproxytable[%i] -> idx[%i]", i, j);
DEBUGC(DBCLASS_PLUGIN,"populate: rtpproxytable[%i] -> idx[%i]", i, j);
idx_to_rtp_proxytable[j++] = i;
}
}
@@ -379,7 +357,7 @@ DEBUGC(DBCLASS_PLUGIN,"populate: rtpproxytable[%i] -> idx[%i]", i, j);
stats_num_reg_clients=0;
for (i=0; i < j; i++) {
DEBUGC(DBCLASS_PLUGIN,"calculate: idx[%i] -> rtpproxytable[%i]", i, idx_to_rtp_proxytable[i]);
DEBUGC(DBCLASS_PLUGIN,"calculate: idx[%i] -> rtpproxytable[%i]", i, idx_to_rtp_proxytable[i]);
// each entry -> +1 stream
stats_num_streams++;
@@ -390,7 +368,7 @@ DEBUGC(DBCLASS_PLUGIN,"calculate: idx[%i] -> rtpproxytable[%i]", i, idx_to_rtp_p
sts = strncmp(rtp_proxytable[idx_to_rtp_proxytable[i]].callid_host,
rtp_proxytable[idx_to_rtp_proxytable[i-1]].callid_host,
CALLIDHOST_SIZE);
DEBUGC(DBCLASS_PLUGIN,"calc: strncmp callid_host=%i", sts);
DEBUGC(DBCLASS_PLUGIN,"calc: strncmp callid_host=%i", sts);
if (sts != 0) {
stats_num_calls++;
} else {
@@ -398,7 +376,7 @@ DEBUGC(DBCLASS_PLUGIN,"calculate: idx[%i] -> rtpproxytable[%i]", i, idx_to_rtp_p
sts = strncmp(rtp_proxytable[idx_to_rtp_proxytable[i]].callid_number,
rtp_proxytable[idx_to_rtp_proxytable[i-1]].callid_number,
CALLIDNUM_SIZE);
DEBUGC(DBCLASS_PLUGIN,"calc: strncmp callid_number=%i", sts);
DEBUGC(DBCLASS_PLUGIN,"calc: strncmp callid_number=%i", sts);
if (sts != 0) {
stats_num_calls++;
}
@@ -408,7 +386,7 @@ DEBUGC(DBCLASS_PLUGIN,"calc: strncmp callid_number=%i", sts);
sts = strncmp(rtp_proxytable[idx_to_rtp_proxytable[i]].client_id.idstring,
rtp_proxytable[idx_to_rtp_proxytable[i-1]].client_id.idstring,
CLIENT_ID_SIZE);
DEBUGC(DBCLASS_PLUGIN,"calc: strncmp client_id=%i", sts);
DEBUGC(DBCLASS_PLUGIN,"calc: strncmp client_id=%i", sts);
if (sts != 0) {
stats_num_act_clients++;
}
@@ -453,22 +431,22 @@ static void stats_to_file(void) {
// write header
time(&now);
fprintf(stream, "Date: %s\n", asctime(localtime(&now)));
fprintf(stream, "Summary\n-------\n");
fprintf(stream, "Date: %s, PID: %i\n", asctime(localtime(&now)), getpid());
fprintf(stream, "\nSummary\n-------\n");
fprintf(stream, "registered Clients: %6i\n", stats_num_reg_clients);
fprintf(stream, "active Clients: %6i\n", stats_num_act_clients);
fprintf(stream, "active Calls: %6i\n", stats_num_calls);
fprintf(stream, "active Streams: %6i\n\n", stats_num_streams);
fprintf(stream, "active Streams: %6i\n", stats_num_streams);
#if 0
//&&& future feature:
fprintf(stream, "Registered Clients\n------------------\n");
fprintf(stream, "\nRegistered Clients\n------------------\n");
// loop through urlmap and write out stuff. needs sorting, too :-/
#endif
fprintf(stream, "RTP-Details\n-----------\n");
fprintf(stream, "\nRTP-Details\n-----------\n");
fprintf(stream, "Header; Client-Id; Call-Id; Call Direction; Stream Direction; local IP; remote IP\n");
for (i=0; i < RTPPROXY_SIZE; i++) {