modules/seas/statistics.c File Reference

#include <stdlib.h>
#include <time.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <signal.h>
#include "statistics.h"
#include "seas.h"
#include "../../mem/shm_mem.h"
#include "../../resolve.h"
#include "../../ut.h"
#include "../../dprint.h"
#include "../../locking.h"

Include dependency graph for modules/seas/statistics.c:

Go to the source code of this file.

Defines

#define STATS_BUF_SIZE   400
#define STATS_PAY   101

Functions

void action_stat (struct cell *t)
void as_relay_stat (struct cell *t)
static int assignIndex (int i)
void destroy_seas_stats_table (void)
void event_stat (struct cell *t)
struct statstableinit_seas_stats_table (void)
int print_stats_info (int f, int sock)
void serve_stats (int fd)
static void sig_handler (int signo)
int start_stats_server (char *stats_socket)
void stats_reply (void)
int stop_stats_server (void)

Variables

pid_t pid
struct statstableseas_stats_table
int stats_fd
char use_stats = 0


Define Documentation

#define STATS_BUF_SIZE   400

Referenced by print_stats_info().

#define STATS_PAY   101

Definition at line 43 of file modules/seas/statistics.c.

Referenced by action_stat(), as_relay_stat(), and event_stat().


Function Documentation

void action_stat ( struct cell t  )  [inline]

this will be called from the SEAS action dispatcher when it receives the action from the socket

no statistics found

Definition at line 170 of file modules/seas/statistics.c.

References totag_elem::acked, assignIndex(), statstable::dispatch, statstable::event, statstable::finished_transactions, cell::fwded_totags, LM_DBG, statstable::mutex, totag_elem::next, NULL, _str::s, s, STATS_PAY, totag_elem::tag, statscell::u, and statscell::uas.

Referenced by ac_reply().

void as_relay_stat ( struct cell t  )  [inline]

static int assignIndex ( int  i  )  [inline, static]

param i is in milliseconds

Definition at line 162 of file modules/seas/statistics.c.

Referenced by action_stat().

void destroy_seas_stats_table ( void   )  [inline]

Definition at line 82 of file modules/seas/statistics.c.

References statstable::mutex, and shm_free.

Referenced by sig_handler(), and start_stats_server().

void event_stat ( struct cell t  )  [inline]

this will be called from the SEAS event dispatcher when it writes the event to the socket

Parameters: a cell OR its hash_index and its label

TODO handle locking/mutexing ?

Definition at line 134 of file modules/seas/statistics.c.

References totag_elem::acked, cell::fwded_totags, LM_DBG, totag_elem::next, NULL, _str::s, s, STATS_PAY, totag_elem::tag, statscell::u, and statscell::uas.

Referenced by dispatch_relay().

struct statstable* init_seas_stats_table ( void   )  [read]

Initialize and destroy statistics table

Definition at line 64 of file modules/seas/statistics.c.

References LM_ERR, statstable::mutex, shm_free, and shm_malloc().

Referenced by start_stats_server().

int print_stats_info ( int  f,
int  sock 
) [inline]

(from snprintf manual) "The functions snprintf() and vsnprintf() do not write more than size bytes (including the trailing '\0'). If the output was truncated due to this limit then the return value is the number of characters (not including the trailing '\0') which would have been written to the final string if enough space had been available. Thus, a return value of size or more means that the output was truncated."

Definition at line 371 of file modules/seas/statistics.c.

References buf, statstable::dispatch, statstable::event, statstable::finished_transactions, statstable::mutex, statstable::received, statstable::received_replies, snprintf, statstable::started_transactions, and STATS_BUF_SIZE.

Referenced by serve_stats().

void serve_stats ( int  fd  ) 

Statistics server process functions

and continue accept()'ing

simple error happened, dont worry

let's go to the outer loop, and receive more Statistics clients

Definition at line 313 of file modules/seas/statistics.c.

References LM_ERR, print_stats_info(), sockaddr_union::s, sig_handler(), and sock.

Referenced by start_stats_server().

static void sig_handler ( int  signo  )  [static]

Definition at line 50 of file modules/seas/statistics.c.

References destroy_seas_stats_table(), LM_DBG, LM_ERR, LM_WARN, and stats_fd.

Referenced by serve_stats(), and start_stats_server().

int start_stats_server ( char *  stats_socket  ) 

stats socket sould be an IP_address:port or unix://path/to_file TODO handling unix sockets and IPv6 !!

returns 0 if no stats 1 if stats properly started -1 if error

Definition at line 220 of file modules/seas/statistics.c.

References destroy_seas_stats_table(), init_seas_stats_table(), LM_ERR, pid, port, resolvehost(), serve_stats(), sig_handler(), stats_fd, str2s(), and use_stats.

Referenced by seas_init().

void stats_reply ( void   )  [inline]

Definition at line 443 of file modules/seas/statistics.c.

References statstable::mutex, and statstable::received_replies.

Referenced by process_action().

int stop_stats_server ( void   )  [inline]

stats socket sould be an IP_address:port or unix://path/to_file TODO handling unix sockets and IPv6 !!

returns 0 if no stats 1 if stats properly started -1 if error

Definition at line 306 of file modules/seas/statistics.c.

References pid.

Referenced by seas_init().


Variable Documentation

pid_t pid

Definition at line 48 of file modules/seas/statistics.c.

Definition at line 45 of file modules/seas/statistics.c.

int stats_fd

Definition at line 46 of file modules/seas/statistics.c.

Referenced by sig_handler(), and start_stats_server().

char use_stats = 0


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