5b253cc6 |
#ifndef stats_h
#define stats_h
|
f571aa35 |
#include <ctype.h>
#include <sys/mman.h>
#include <sys/fcntl.h>
#include <sys/time.h>
#include <time.h>
#include <sys/utsname.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
|
dda9dab1 |
#define _update_request( method, dir ) \
{ if (stat_file!=NULL) switch( method ) { \
case METHOD_INVITE: stats->dir##_requests_inv++; break; \
case METHOD_ACK: stats->dir##_requests_ack++; break; \
case METHOD_CANCEL: stats->dir##_requests_cnc++; break; \
case METHOD_BYE: stats->dir##_requests_bye++; break; \
case METHOD_OTHER: stats->dir##_requests_other++; break; \
default: LOG(L_ERR, "ERROR: unknown method in rq stats (%s)\n", #dir); \
} \
}
/*
#define update_received_request( method ) _update_request( method, received )
#define update_sent_request( method ) _update_request( method, sent )
#define update_received_response( statusclass ) _update_response( statusclass, received )
#define update_sent_response( statusclass ) _update_response( statusclass, sent )
#define update_received_drops { stats->received_drops++; }
#define update_fail_on_send { stats->failed_on_send++; }
*/
#define _statusline(class, dir ) case class: stats->dir##_responses_##class++; break;
|
811c8ef0 |
/* FIXME: Don't have case for _other (see received_responses_other) */
|
dda9dab1 |
#define _update_response( statusclass, dir ) \
{ if (stat_file!=NULL) \
switch( statusclass ) { \
_statusline(1, dir) \
_statusline(2, dir) \
_statusline(3, dir) \
_statusline(4, dir) \
_statusline(5, dir) \
_statusline(6, dir) \
default: LOG(L_INFO, "ERROR: unusual status code received in stats (%s)\n", #dir); \
} \
}
#ifdef STATS
# define STATS_RX_REQUEST(method) _update_request(method, received)
# define STATS_TX_REQUEST(method) _update_request(method, sent )
# define STATS_RX_RESPONSE(class) _update_response( class, received )
# define STATS_TX_RESPONSE(class) _update_response( class, sent )
# define STATS_RX_DROPS { stats->received_drops++; }
# define STATS_TX_DROPS { stats->failed_on_send++; }
#else
# define STATS_RX_REQUEST(method)
# define STATS_TX_REQUEST(method)
# define STATS_RX_RESPONSE(class)
# define STATS_TX_RESPONSE(class)
# define STATS_RX_DROPS
# define STATS_TX_DROPS
#endif
|
f571aa35 |
|
0a974a1d |
#ifdef STATS
|
f571aa35 |
|
5b253cc6 |
struct stats_s {
|
f571aa35 |
unsigned int process_index;
pid_t pid;
time_t start_time;
unsigned long
/* received packets */
received_requests_inv, /* received_requests */
received_requests_ack,
received_requests_cnc,
received_requests_bye,
received_requests_other,
|
811c8ef0 |
received_responses_1, /* received_responses */
|
f571aa35 |
received_responses_2,
received_responses_3,
received_responses_4,
received_responses_5,
received_responses_6,
received_responses_other,
|
811c8ef0 |
received_drops, /* all messages we received and did not process
|
f571aa35 |
successfully; reasons include SIP sanity checks
(missing Vias, neither request nor response,
failed parsing), ser errors (malloc, action
failure)
*/
/* sent */
/* sent_requests */
sent_requests_inv,
sent_requests_ack,
sent_requests_cnc,
sent_requests_bye,
sent_requests_other,
/* sent responses */
sent_responses_1,
sent_responses_2,
sent_responses_3,
sent_responses_4,
sent_responses_5,
sent_responses_6,
|
811c8ef0 |
/* FIXME: Don't want sent_responses_other?? */
|
f571aa35 |
|
4f3faaaf |
processed_requests,
processed_responses,
acc_req_time,
acc_res_time,
|
f571aa35 |
failed_on_send;
|
5b253cc6 |
};
|
f571aa35 |
extern struct stats_s *stats;
|
811c8ef0 |
extern char *stat_file;
|
5b253cc6 |
|
811c8ef0 |
int init_stats( int nr_of_processes );
|
f571aa35 |
void setstats( int child_index );
int dump_all_statistic();
|
811c8ef0 |
int dump_statistic(FILE *fp, struct stats_s *istats, int printheader);
/* Registers handlers with SNMP module */
int stats_register();
|
f571aa35 |
#endif
|
0a974a1d |
#endif
|