modules/seas/statistics.h

Go to the documentation of this file.
00001 /* $Id: statistics.h 5003 2008-09-26 11:01:51Z henningw $
00002  *
00003  * Copyright (C) 2006-2007 VozTelecom Sistemas S.L
00004  *
00005  * This file is part of Kamailio, a free SIP server.
00006  *
00007  * Kamailio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version
00011  *
00012  * Kamailio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License 
00018  * along with this program; if not, write to the Free Software 
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  */
00021 
00022 #include <sys/time.h>
00023 #include <time.h>
00024 #include "../../hash_func.h"/* for TABLE_ENTRIES define*/
00025 #include "../../locking.h"/* for TABLE_ENTRIES define*/
00026 #include "../tm/h_table.h"/* for struct cell*/
00027 #define STATS_CELLS 50
00028 #define UAS_T 0
00029 #define UAC_T 1
00030 /**
00031  * stores statistics about a given APP SERVER,
00032  * for instance, how much it lasted to respond to
00033  * a given incoming request transaction, how many requests went in
00034  * and how many responses went out, etc.
00035  * this should be about... 16*4+20*4+4 bytes...64+80+4=148 bytes each cell
00036  */
00037 struct statscell
00038 {
00039    /** 0 = UAS, 1 = UAC*/
00040    char type;
00041    /**difference between a request_event and a reply_action*/
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 /** Transactions statistics table */
00056 struct statstable
00057 {
00058    gen_lock_t *mutex;
00059    unsigned int dispatch[15];
00060    unsigned int event[15];
00061    unsigned int action[15];
00062    unsigned int started_transactions;
00063    unsigned int finished_transactions;
00064    unsigned int received_replies;
00065    unsigned int received;
00066 };
00067 extern struct statstable *seas_stats_table;
00068 
00069 /**
00070  * Initialize and destroy statistics table
00071  */
00072 struct statstable* init_seas_stats_table(void);
00073 inline int stop_stats_server(void);
00074 inline void destroy_seas_stats_table(void);
00075 /** Statistics server process
00076  * functions
00077  */
00078 void serve_stats(int fd);
00079 int start_stats_server(char *socket);
00080 inline int print_stats_info(int f,int sock);
00081 /**
00082  * Statistics functions
00083  */
00084 inline void as_relay_stat(struct cell *t);
00085 inline void event_stat(struct cell *t);
00086 inline void action_stat(struct cell *t);
00087 inline void stats_reply(void);
00088 #define receivedplus() \
00089    do{ \
00090       lock_get(seas_stats_table->mutex); \
00091       seas_stats_table->received++; \
00092       lock_release(seas_stats_table->mutex); \
00093    }while(0)

Generated on Wed May 23 20:00:31 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6