#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"

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 statstable * | init_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 statstable * | seas_stats_table |
| int | stats_fd |
| char | use_stats = 0 |
| #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().
| 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] |
This will be called from within w_as_relay()
TODO handle locking ?
Definition at line 96 of file modules/seas/statistics.c.
References totag_elem::acked, cell::fwded_totags, _str::len, LM_DBG, statstable::mutex, totag_elem::next, NULL, _str::s, s, shm_free, shm_malloc(), statstable::started_transactions, STATS_PAY, totag_elem::tag, statscell::type, statscell::u, statscell::uas, and UAS_T.
Referenced by w_as_relay_sl(), and w_as_relay_t().
| 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().
| pid_t pid |
Definition at line 48 of file modules/seas/statistics.c.
| struct statstable* seas_stats_table |
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 |
Definition at line 47 of file modules/seas/statistics.c.
Referenced by ac_reply(), dispatch_relay(), process_action(), process_input(), seas_init(), start_stats_server(), w_as_relay_sl(), and w_as_relay_t().
1.5.6