00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <sys/time.h>
00023 #include <time.h>
00024 #include "../../hashes.h"
00025 #include "../../locking.h"
00026 #include "../../modules/tm/h_table.h"
00027 #define STATS_CELLS 50
00028 #define UAS_T 0
00029 #define UAC_T 1
00030
00037 struct statscell
00038 {
00040 char type;
00042 union {
00043 struct {
00044 struct timeval as_relay;
00045 struct timeval event_sent;
00046 struct timeval action_recvd;
00047 } uas;
00048 struct {
00049 struct timeval action_recvd;
00050 struct timeval event_sent;
00051 struct timeval action_reply_sent;
00052 } uac;
00053 }u;
00054 };
00055
00057 struct statstable
00058 {
00059 gen_lock_t *mutex;
00060 unsigned int dispatch[15];
00061 unsigned int event[15];
00062 unsigned int action[15];
00063 unsigned int started_transactions;
00064 unsigned int finished_transactions;
00065 unsigned int received_replies;
00066 unsigned int received;
00067 };
00068
00069 extern struct statstable *seas_stats_table;
00070
00074 struct statstable* init_seas_stats_table(void);
00075 inline int stop_stats_server(void);
00076 inline void destroy_seas_stats_table(void);
00080 void serve_stats(int fd);
00081 int start_stats_server(char *socket);
00082 inline int print_stats_info(int f,int sock);
00086 inline void as_relay_stat(struct cell *t);
00087 inline void event_stat(struct cell *t);
00088 inline void action_stat(struct cell *t);
00089 inline void stats_reply(void);
00090 #define receivedplus() \
00091 do{ \
00092 lock_get(seas_stats_table->mutex); \
00093 seas_stats_table->received++; \
00094 lock_release(seas_stats_table->mutex); \
00095 }while(0)