\doxysection{src/core/stats.c File Reference}
\label{stats_8c}\index{src/core/stats.c@{src/core/stats.c}}
{\ttfamily \#include \char`\"{}config.\+h\char`\"{}}\newline
{\ttfamily \#include $<$osmocom/core/byteswap.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/stats.\+h$>$}\newline
{\ttfamily \#include $<$unistd.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$stdint.\+h$>$}\newline
{\ttfamily \#include $<$errno.\+h$>$}\newline
{\ttfamily \#include $<$stdio.\+h$>$}\newline
{\ttfamily \#include $<$sys/types.\+h$>$}\newline
{\ttfamily \#include $<$inttypes.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/utils.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/logging.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/rate\+\_\+ctr.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/stat\+\_\+item.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/select.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/counter.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/msgb.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/stats\+\_\+tcp.\+h$>$}\newline
{\ttfamily \#include $<$stat\+\_\+item\+\_\+internal.\+h$>$}\newline
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ TRACE}(probe)
\item 
\#define \textbf{ TRACE\+\_\+\+ENABLED}(probe)~(0)
\item 
\#define \textbf{ STATS\+\_\+\+DEFAULT\+\_\+\+INTERVAL}~5 /$\ast$ secs $\ast$/
\item 
\#define \textbf{ STATS\+\_\+\+DEFAULT\+\_\+\+BUFLEN}~256
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\textbf{ LLIST\+\_\+\+HEAD} (\textbf{ osmo\+\_\+stats\+\_\+reporter\+\_\+list})
\item 
static int \textbf{ osmo\+\_\+stats\+\_\+reporter\+\_\+log\+\_\+send\+\_\+counter} (struct \textbf{ osmo\+\_\+stats\+\_\+reporter} $\ast$srep, const struct \textbf{ rate\+\_\+ctr\+\_\+group} $\ast$ctrg, const struct \textbf{ rate\+\_\+ctr\+\_\+desc} $\ast$\textbf{ desc}, int64\+\_\+t value, int64\+\_\+t delta)
\item 
static int \textbf{ osmo\+\_\+stats\+\_\+reporter\+\_\+log\+\_\+send\+\_\+item} (struct \textbf{ osmo\+\_\+stats\+\_\+reporter} $\ast$srep, const struct \textbf{ osmo\+\_\+stat\+\_\+item\+\_\+group} $\ast$statg, const struct \textbf{ osmo\+\_\+stat\+\_\+item\+\_\+desc} $\ast$\textbf{ desc}, int64\+\_\+t value)
\item 
static int \textbf{ update\+\_\+srep\+\_\+config} (struct \textbf{ osmo\+\_\+stats\+\_\+reporter} $\ast$srep)
\item 
static int \textbf{ osmo\+\_\+stats\+\_\+timer\+\_\+cb} (struct \textbf{ osmo\+\_\+fd} $\ast$ofd, unsigned int what)
\item 
static int \textbf{ start\+\_\+timer} (void)
\item 
struct \textbf{ osmo\+\_\+stats\+\_\+reporter} $\ast$ \textbf{ osmo\+\_\+stats\+\_\+reporter\+\_\+alloc} (enum \textbf{ osmo\+\_\+stats\+\_\+reporter\+\_\+type} \textbf{ type}, const char $\ast$\textbf{ name})
\item 
void \textbf{ osmo\+\_\+stats\+\_\+reporter\+\_\+free} (struct \textbf{ osmo\+\_\+stats\+\_\+reporter} $\ast$srep)
\begin{DoxyCompactList}\small\item\em Destroy a given stats\+\_\+reporter. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stats\+\_\+init} (void $\ast$ctx)
\begin{DoxyCompactList}\small\item\em Initialize the stats reporting module; call this once in your program. \end{DoxyCompactList}\item 
struct \textbf{ osmo\+\_\+stats\+\_\+reporter} $\ast$ \textbf{ osmo\+\_\+stats\+\_\+reporter\+\_\+find} (enum \textbf{ osmo\+\_\+stats\+\_\+reporter\+\_\+type} \textbf{ type}, const char $\ast$\textbf{ name})
\begin{DoxyCompactList}\small\item\em Find a stats\+\_\+reporter of given {\itshape type} and {\itshape name}. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stats\+\_\+reporter\+\_\+set\+\_\+max\+\_\+class} (struct \textbf{ osmo\+\_\+stats\+\_\+reporter} $\ast$srep, enum \textbf{ osmo\+\_\+stats\+\_\+class} class\+\_\+id)
\item 
int \textbf{ osmo\+\_\+stats\+\_\+set\+\_\+interval} (int interval)
\begin{DoxyCompactList}\small\item\em Set the reporting interval (common for all reporters) \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stats\+\_\+reporter\+\_\+set\+\_\+flush\+\_\+period} (struct \textbf{ osmo\+\_\+stats\+\_\+reporter} $\ast$srep, unsigned int period)
\begin{DoxyCompactList}\small\item\em Set the regular flush period for a given stats\+\_\+reporter. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stats\+\_\+reporter\+\_\+set\+\_\+name\+\_\+prefix} (struct \textbf{ osmo\+\_\+stats\+\_\+reporter} $\ast$srep, const char $\ast$prefix)
\begin{DoxyCompactList}\small\item\em Set the name prefix of a given stats\+\_\+reporter. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stats\+\_\+reporter\+\_\+enable} (struct \textbf{ osmo\+\_\+stats\+\_\+reporter} $\ast$srep)
\begin{DoxyCompactList}\small\item\em Enable the given stats\+\_\+reporter. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stats\+\_\+reporter\+\_\+disable} (struct \textbf{ osmo\+\_\+stats\+\_\+reporter} $\ast$srep)
\begin{DoxyCompactList}\small\item\em Disable the given stats\+\_\+reporter. \end{DoxyCompactList}\item 
struct \textbf{ osmo\+\_\+stats\+\_\+reporter} $\ast$ \textbf{ osmo\+\_\+stats\+\_\+reporter\+\_\+create\+\_\+log} (const char $\ast$\textbf{ name})
\begin{DoxyCompactList}\small\item\em Create a stats\+\_\+reporter that logs via libosmocore logging. \end{DoxyCompactList}\item 
static int \textbf{ osmo\+\_\+stats\+\_\+reporter\+\_\+log\+\_\+send} (struct \textbf{ osmo\+\_\+stats\+\_\+reporter} $\ast$srep, const char $\ast$\textbf{ type}, const char $\ast$name1, unsigned int index1, const char $\ast$name2, int value, const char $\ast$unit)
\item 
static int \textbf{ osmo\+\_\+stats\+\_\+reporter\+\_\+check\+\_\+config} (struct \textbf{ osmo\+\_\+stats\+\_\+reporter} $\ast$srep, unsigned int index, int class\+\_\+id)
\item 
static int \textbf{ osmo\+\_\+stats\+\_\+reporter\+\_\+send\+\_\+counter} (struct \textbf{ osmo\+\_\+stats\+\_\+reporter} $\ast$srep, const struct \textbf{ rate\+\_\+ctr\+\_\+group} $\ast$ctrg, const struct \textbf{ rate\+\_\+ctr\+\_\+desc} $\ast$\textbf{ desc}, int64\+\_\+t value, int64\+\_\+t delta)
\item 
static int \textbf{ rate\+\_\+ctr\+\_\+handler} (struct \textbf{ rate\+\_\+ctr\+\_\+group} $\ast$ctrg, struct \textbf{ rate\+\_\+ctr} $\ast$ctr, const struct \textbf{ rate\+\_\+ctr\+\_\+desc} $\ast$\textbf{ desc}, void $\ast$sctx\+\_\+)
\item 
static int \textbf{ rate\+\_\+ctr\+\_\+group\+\_\+handler} (struct \textbf{ rate\+\_\+ctr\+\_\+group} $\ast$ctrg, void $\ast$sctx\+\_\+)
\item 
static int \textbf{ osmo\+\_\+stats\+\_\+reporter\+\_\+send\+\_\+item} (struct \textbf{ osmo\+\_\+stats\+\_\+reporter} $\ast$srep, const struct \textbf{ osmo\+\_\+stat\+\_\+item\+\_\+group} $\ast$statg, const struct \textbf{ osmo\+\_\+stat\+\_\+item\+\_\+desc} $\ast$\textbf{ desc}, int32\+\_\+t value)
\item 
static int \textbf{ osmo\+\_\+stat\+\_\+item\+\_\+handler} (struct \textbf{ osmo\+\_\+stat\+\_\+item\+\_\+group} $\ast$statg, struct \textbf{ osmo\+\_\+stat\+\_\+item} $\ast$item, void $\ast$sctx\+\_\+)
\item 
static int \textbf{ osmo\+\_\+stat\+\_\+item\+\_\+group\+\_\+handler} (struct \textbf{ osmo\+\_\+stat\+\_\+item\+\_\+group} $\ast$statg, void $\ast$sctx\+\_\+)
\item 
static int \textbf{ handle\+\_\+counter} (struct \textbf{ osmo\+\_\+counter} $\ast$counter, void $\ast$sctx\+\_\+)
\item 
static void \textbf{ flush\+\_\+all\+\_\+reporters} (void)
\item 
int \textbf{ osmo\+\_\+stats\+\_\+report} (void)
\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
static void $\ast$ \textbf{ osmo\+\_\+stats\+\_\+ctx} = NULL
\item 
static int \textbf{ is\+\_\+initialised} = 0
\item 
static struct \textbf{ osmo\+\_\+stats\+\_\+config} \textbf{ s\+\_\+stats\+\_\+config}
\item 
struct \textbf{ osmo\+\_\+stats\+\_\+config} $\ast$ \textbf{ osmo\+\_\+stats\+\_\+config} = \&\textbf{ s\+\_\+stats\+\_\+config}
\item 
static struct \textbf{ osmo\+\_\+fd} \textbf{ osmo\+\_\+stats\+\_\+timer} = \{ .fd = -\/1 \}
\end{DoxyCompactItemize}
