00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef _T_STATS_H
00032 #define _T_STATS_H
00033
00034
00035 #define TM_MORE_STATS
00036
00037 #include "defs.h"
00038
00039 #include "../../rpc.h"
00040 #include "../../pt.h"
00041
00042
00043 typedef unsigned long stat_counter;
00044
00045 struct t_proc_stats {
00046
00047 stat_counter waiting;
00048
00049 stat_counter transactions;
00050
00051 stat_counter client_transactions;
00052
00053 stat_counter completed_3xx, completed_4xx, completed_5xx,
00054 completed_6xx, completed_2xx;
00055 stat_counter replied_locally;
00056 stat_counter deleted;
00057 #ifdef TM_MORE_STATS
00058
00059 stat_counter t_created;
00060
00061 stat_counter t_freed;
00062
00063 stat_counter delayed_free;
00064 #endif
00065 };
00066
00067 union t_stats{
00068 struct t_proc_stats s;
00069 char _pad[256];
00070
00071 };
00072 extern union t_stats *tm_stats;
00073
00074 #ifdef TM_MORE_STATS
00075 inline void static t_stats_created(void)
00076 {
00077
00078 tm_stats[process_no].s.t_created++;
00079 }
00080
00081 inline void static t_stats_freed(void)
00082 {
00083
00084 tm_stats[process_no].s.t_freed++;
00085 }
00086
00087 inline void static t_stats_delayed_free(void)
00088 {
00089
00090 tm_stats[process_no].s.delayed_free++;
00091 }
00092 #else
00093
00094 #define t_stats_created() do{}while(0)
00095 #define t_stats_freed() do{}while(0)
00096 #define t_stats_delayed_free() do{}while(0)
00097
00098 #endif
00099
00100 inline void static t_stats_new(int local)
00101 {
00102
00103 tm_stats[process_no].s.transactions++;
00104 if(local) tm_stats[process_no].s.client_transactions++;
00105 }
00106
00107 inline void static t_stats_wait(void)
00108 {
00109
00110 tm_stats[process_no].s.waiting++;
00111 }
00112
00113 inline void static t_stats_deleted( int local )
00114 {
00115 tm_stats[process_no].s.deleted++;
00116 }
00117
00118 inline static void update_reply_stats( int code ) {
00119 if (code>=600) {
00120 tm_stats[process_no].s.completed_6xx++;
00121 } else if (code>=500) {
00122 tm_stats[process_no].s.completed_5xx++;
00123 } else if (code>=400) {
00124 tm_stats[process_no].s.completed_4xx++;
00125 } else if (code>=300) {
00126 tm_stats[process_no].s.completed_3xx++;
00127 } else if (code>=200) {
00128 tm_stats[process_no].s.completed_2xx++;
00129 }
00130 }
00131
00132
00133 inline void static t_stats_replied_locally(void)
00134 {
00135 tm_stats[process_no].s.replied_locally++;
00136 }
00137
00138
00139
00140 int init_tm_stats(void);
00141 int init_tm_stats_child(void);
00142 void free_tm_stats(void);
00143
00144 void tm_rpc_stats(rpc_t* rpc, void* c);
00145
00146 void tm_rpc_hash_stats(rpc_t* rpc, void* c);
00147
00148 typedef int (*tm_get_stats_f)(struct t_proc_stats *all);
00149 int tm_get_stats(struct t_proc_stats *all);
00150
00151 #endif