suricata
|
#include "threads.h"
Go to the source code of this file.
Data Structures | |
struct | StatsCounter_ |
Container to hold the counter variable. More... | |
struct | StatsPublicThreadContext_ |
Stats Context for a ThreadVars instance. More... | |
struct | StatsLocalCounter_ |
Storage for local counters, with a link to the public counter used for syncs. More... | |
struct | StatsPrivateThreadContext_ |
used to hold the private version of the counters registered More... | |
Typedefs | |
typedef struct StatsCounter_ | StatsCounter |
Container to hold the counter variable. More... | |
typedef struct StatsPublicThreadContext_ | StatsPublicThreadContext |
Stats Context for a ThreadVars instance. More... | |
typedef struct StatsLocalCounter_ | StatsLocalCounter |
Storage for local counters, with a link to the public counter used for syncs. More... | |
typedef struct StatsPrivateThreadContext_ | StatsPrivateThreadContext |
used to hold the private version of the counters registered More... | |
Functions | |
void | StatsInit (void) |
Initializes the perf counter api. Things are hard coded currently. More work to be done when we implement multiple interfaces. More... | |
void | StatsSetupPostConfigPreOutput (void) |
void | StatsSetupPostConfigPostOutput (void) |
void | StatsSpawnThreads (void) |
Spawns the wakeup, and the management thread used by the stats api. More... | |
void | StatsRegisterTests (void) |
bool | StatsEnabled (void) |
void | StatsReleaseResources (void) |
Releases the resources allotted by the Stats API. More... | |
uint16_t | StatsRegisterCounter (const char *, struct ThreadVars_ *) |
Registers a normal, unqualified counter. More... | |
uint16_t | StatsRegisterAvgCounter (const char *, struct ThreadVars_ *) |
Registers a counter, whose value holds the average of all the values assigned to it. More... | |
uint16_t | StatsRegisterMaxCounter (const char *, struct ThreadVars_ *) |
Registers a counter, whose value holds the maximum of all the values assigned to it. More... | |
uint16_t | StatsRegisterGlobalCounter (const char *cname, uint64_t(*Func)(void)) |
Registers a counter, which represents a global value. More... | |
void | StatsAddUI64 (struct ThreadVars_ *, uint16_t, uint64_t) |
Adds a value of type uint64_t to the local counter. More... | |
void | StatsSetUI64 (struct ThreadVars_ *, uint16_t, uint64_t) |
Sets a value of type double to the local counter. More... | |
void | StatsIncr (struct ThreadVars_ *, uint16_t) |
Increments the local counter. More... | |
void | StatsDecr (struct ThreadVars_ *, uint16_t) |
Decrements the local counter. More... | |
int | StatsUpdateCounterArray (StatsPrivateThreadContext *, StatsPublicThreadContext *) |
the private stats store with the public stats store More... | |
uint64_t | StatsGetLocalCounterValue (struct ThreadVars_ *, uint16_t) |
Get the value of the local copy of the counter that hold this id. More... | |
int | StatsSetupPrivate (struct ThreadVars_ *) |
void | StatsThreadCleanup (struct ThreadVars_ *) |
void | StatsSyncCounters (struct ThreadVars_ *tv) |
void | StatsSyncCountersIfSignalled (struct ThreadVars_ *tv) |
Definition in file counters.h.
typedef struct StatsCounter_ StatsCounter |
Container to hold the counter variable.
typedef struct StatsLocalCounter_ StatsLocalCounter |
Storage for local counters, with a link to the public counter used for syncs.
typedef struct StatsPrivateThreadContext_ StatsPrivateThreadContext |
used to hold the private version of the counters registered
typedef struct StatsPublicThreadContext_ StatsPublicThreadContext |
Stats Context for a ThreadVars instance.
void StatsAddUI64 | ( | ThreadVars * | tv, |
uint16_t | id, | ||
uint64_t | x | ||
) |
Adds a value of type uint64_t to the local counter.
id | ID of the counter as set by the API |
pca | Counter array that holds the local counter for this TM |
x | Value to add to this local counter |
Definition at line 146 of file counters.c.
References BUG_ON, StatsPrivateThreadContext_::head, StatsPrivateThreadContext_::initialized, ThreadVars_::perf_private_ctx, StatsPrivateThreadContext_::size, tv, StatsLocalCounter_::updates, and StatsLocalCounter_::value.
Referenced by AppLayerIncTxCounter(), and DecodeUpdatePacketCounters().
void StatsDecr | ( | ThreadVars * | tv, |
uint16_t | id | ||
) |
Decrements the local counter.
id | Index of the counter in the counter array |
pca | Counter array that holds the local counters for this TM |
Definition at line 186 of file counters.c.
References BUG_ON, StatsPrivateThreadContext_::head, StatsPrivateThreadContext_::initialized, ThreadVars_::perf_private_ctx, StatsPrivateThreadContext_::size, tv, StatsLocalCounter_::updates, and StatsLocalCounter_::value.
bool StatsEnabled | ( | void | ) |
Definition at line 118 of file counters.c.
uint64_t StatsGetLocalCounterValue | ( | ThreadVars * | tv, |
uint16_t | id | ||
) |
Get the value of the local copy of the counter that hold this id.
tv | threadvars |
id | The counter id. |
0 | on success. |
-1 | on error. |
Definition at line 1250 of file counters.c.
References BUG_ON, StatsPrivateThreadContext_::head, ThreadVars_::perf_private_ctx, StatsPrivateThreadContext_::size, tv, and StatsLocalCounter_::value.
Referenced by ReceiveErfDagThreadExitStats().
void StatsIncr | ( | ThreadVars * | tv, |
uint16_t | id | ||
) |
Increments the local counter.
id | Index of the counter in the counter array |
pca | Counter array that holds the local counters for this TM |
Definition at line 166 of file counters.c.
References BUG_ON, StatsPrivateThreadContext_::head, StatsPrivateThreadContext_::initialized, ThreadVars_::perf_private_ctx, StatsPrivateThreadContext_::size, tv, StatsLocalCounter_::updates, and StatsLocalCounter_::value.
Referenced by AppLayerIncAllocErrorCounter(), AppLayerIncGapErrorCounter(), AppLayerIncInternalErrorCounter(), AppLayerIncParserErrorCounter(), CaptureStatsUpdate(), DecodeARP(), DecodeCHDLC(), DecodeERSPAN(), DecodeERSPANTypeI(), DecodeESP(), DecodeEthernet(), DecodeGRE(), DecodeICMPV4(), DecodeIPV4(), DecodeIPV6(), DecodeMPLS(), DecodeNSH(), DecodeNull(), DecodePPP(), DecodePPPOEDiscovery(), DecodePPPOESession(), DecodeRaw(), DecodeSCTP(), DecodeSll(), DecodeTCP(), DecodeUDP(), DecodeUpdatePacketCounters(), DecodeVLAN(), DecodeVNTag(), PacketDecodeFinalize(), PacketUpdateEngineEventCounters(), and StreamTcpGetSegment().
void StatsInit | ( | void | ) |
Initializes the perf counter api. Things are hard coded currently. More work to be done when we implement multiple interfaces.
Definition at line 875 of file counters.c.
References BUG_ON.
Referenced by PreRunInit().
uint16_t StatsRegisterAvgCounter | ( | const char * | name, |
struct ThreadVars_ * | tv | ||
) |
Registers a counter, whose value holds the average of all the values assigned to it.
name | Name of the counter, to be registered |
tv | Pointer to the ThreadVars instance for which the counter would be registered |
id | Counter id for the newly registered counter, or the already present counter |
Definition at line 971 of file counters.c.
Referenced by DecodeRegisterPerfCounters().
uint16_t StatsRegisterCounter | ( | const char * | name, |
struct ThreadVars_ * | tv | ||
) |
Registers a normal, unqualified counter.
name | Name of the counter, to be registered |
tv | Pointer to the ThreadVars instance for which the counter would be registered |
id | Counter id for the newly registered counter, or the already present counter |
Definition at line 951 of file counters.c.
Referenced by CaptureStatsSetup(), DecodeRegisterPerfCounters(), ExceptionPolicySetStatsCounters(), FlowEndCountersRegister(), ReceiveErfDagThreadInit(), and StreamTcpThreadInit().
uint16_t StatsRegisterGlobalCounter | ( | const char * | name, |
uint64_t(*)(void) | Func | ||
) |
Registers a counter, which represents a global value.
name | Name of the counter, to be registered |
Func | Function Pointer returning a uint64_t |
id | Counter id for the newly registered counter, or the already present counter |
Definition at line 1009 of file counters.c.
Referenced by AppLayerRegisterGlobalCounters(), and OutputFilestoreRegisterGlobalCounters().
uint16_t StatsRegisterMaxCounter | ( | const char * | name, |
struct ThreadVars_ * | tv | ||
) |
Registers a counter, whose value holds the maximum of all the values assigned to it.
name | Name of the counter, to be registered |
tv | Pointer to the ThreadVars instance for which the counter would be registered |
the | counter id for the newly registered counter, or the already present counter |
Definition at line 991 of file counters.c.
Referenced by DecodeRegisterPerfCounters().
void StatsRegisterTests | ( | void | ) |
Definition at line 1564 of file counters.c.
References UtRegisterTest().
void StatsReleaseResources | ( | void | ) |
Releases the resources allotted by the Stats API.
Definition at line 1262 of file counters.c.
void StatsSetUI64 | ( | ThreadVars * | tv, |
uint16_t | id, | ||
uint64_t | x | ||
) |
Sets a value of type double to the local counter.
id | Index of the local counter in the counter array |
pca | Pointer to the StatsPrivateThreadContext |
x | The value to set for the counter |
Definition at line 207 of file counters.c.
References BUG_ON, StatsPrivateThreadContext_::head, StatsPrivateThreadContext_::initialized, StatsLocalCounter_::pc, ThreadVars_::perf_private_ctx, StatsPrivateThreadContext_::size, STATS_TYPE_MAXIMUM, STATS_TYPE_NORMAL, tv, StatsCounter_::type, StatsLocalCounter_::updates, and StatsLocalCounter_::value.
Referenced by DecodeUpdatePacketCounters().
void StatsSetupPostConfigPostOutput | ( | void | ) |
Definition at line 890 of file counters.c.
Referenced by PreRunPostPrivsDropInit().
void StatsSetupPostConfigPreOutput | ( | void | ) |
Definition at line 885 of file counters.c.
Referenced by PreRunPostPrivsDropInit().
int StatsSetupPrivate | ( | struct ThreadVars_ * | ) |
Definition at line 1204 of file counters.c.
void StatsSpawnThreads | ( | void | ) |
Spawns the wakeup, and the management thread used by the stats api.
The threads use the condition variable in the thread vars to control their wait loops to make sure the main thread can quickly kill them.
Definition at line 902 of file counters.c.
References SCEnter.
void StatsSyncCounters | ( | struct ThreadVars_ * | tv | ) |
Definition at line 444 of file counters.c.
References ThreadVars_::perf_private_ctx, ThreadVars_::perf_public_ctx, StatsUpdateCounterArray(), and tv.
void StatsSyncCountersIfSignalled | ( | struct ThreadVars_ * | tv | ) |
Definition at line 449 of file counters.c.
References ThreadVars_::perf_private_ctx, ThreadVars_::perf_public_ctx, SC_ATOMIC_GET, StatsUpdateCounterArray(), and tv.
Referenced by TmqhInputFlow(), and TmqhInputSimple().
void StatsThreadCleanup | ( | struct ThreadVars_ * | ) |
Definition at line 1303 of file counters.c.
int StatsUpdateCounterArray | ( | StatsPrivateThreadContext * | pca, |
StatsPublicThreadContext * | pctx | ||
) |
the private stats store with the public stats store
pca | Pointer to the StatsPrivateThreadContext |
pctx | Pointer the tv's StatsPublicThreadContext |
1 | on success |
-1 | on error |
Definition at line 1222 of file counters.c.
References StatsPrivateThreadContext_::head, StatsPublicThreadContext_::m, SCLogDebug, SCMutexLock, and StatsPrivateThreadContext_::size.
Referenced by StatsSyncCounters(), and StatsSyncCountersIfSignalled().