|
suricata
|
#include "suricata-common.h"#include "counters.h"#include "suricata.h"#include "threadvars.h"#include "output.h"#include "output-json-stats.h"#include "util-byte.h"#include "util-conf.h"#include "util-hash.h"#include "util-time.h"#include "tm-threads.h"#include "util-privs.h"
Go to the source code of this file.
Data Structures | |
| struct | StatsThreadStore_ |
| per thread store of counters More... | |
| struct | StatsGlobalContext_ |
| Holds the output interface context for the counter api. More... | |
| struct | CountersIdType_ |
Macros | |
| #define | STATS_WUT_TTS 3 |
| #define | STATS_MGMTT_TTS 8 |
Typedefs | |
| typedef struct StatsThreadStore_ | StatsThreadStore |
| per thread store of counters More... | |
| typedef struct StatsGlobalContext_ | StatsGlobalContext |
| Holds the output interface context for the counter api. More... | |
| typedef struct CountersIdType_ | CountersIdType |
Enumerations | |
| enum | { STATS_TYPE_NORMAL = 1, STATS_TYPE_AVERAGE = 2, STATS_TYPE_MAXIMUM = 3, STATS_TYPE_FUNC = 4, STATS_TYPE_MAX = 5 } |
| Different kinds of qualifier that can be used to modify the behaviour of the counter to be registered. More... | |
Functions | |
| bool | StatsEnabled (void) |
| void | StatsCounterAddI64 (StatsThreadContext *stats, StatsCounterId id, int64_t x) |
| Adds a value of type uint64_t to the local counter. More... | |
| void | StatsCounterIncr (StatsThreadContext *stats, StatsCounterId id) |
| Increments the local counter. More... | |
| void | StatsCounterDecr (StatsThreadContext *stats, StatsCounterId id) |
| Decrements the local counter. More... | |
| void | StatsCounterSetI64 (StatsThreadContext *stats, StatsCounterId id, int64_t x) |
| set, so overwrite, the value of the local counter More... | |
| void | StatsCounterMaxUpdateI64 (StatsThreadContext *stats, StatsCounterMaxId id, int64_t x) |
| update the value of the localmax counter More... | |
| void | StatsCounterAvgAddI64 (StatsThreadContext *stats, StatsCounterAvgId id, int64_t x) |
| void | StatsSyncCounters (StatsThreadContext *stats) |
| void | StatsSyncCountersIfSignalled (StatsThreadContext *stats) |
| 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... | |
| StatsCounterId | StatsRegisterCounter (const char *name, StatsThreadContext *stats) |
| Registers a normal, unqualified counter. More... | |
| StatsCounterAvgId | StatsRegisterAvgCounter (const char *name, StatsThreadContext *stats) |
| Registers a counter, whose value holds the average of all the values assigned to it. More... | |
| StatsCounterMaxId | StatsRegisterMaxCounter (const char *name, StatsThreadContext *stats) |
| Registers a counter, whose value holds the maximum of all the values assigned to it. More... | |
| StatsCounterGlobalId | StatsRegisterGlobalCounter (const char *name, uint64_t(*Func)(void)) |
| Registers a counter, which represents a global value. More... | |
| int | StatsSetupPrivate (StatsThreadContext *stats, const char *thread_name) |
| void | StatsThreadInit (StatsThreadContext *stats) |
| int64_t | StatsCounterGetLocalValue (StatsThreadContext *stats, StatsCounterId id) |
| Get the value of the local copy of the counter that hold this id. More... | |
| void | StatsReleaseResources (void) |
| Releases the resources allotted by the Stats API. More... | |
| void | StatsThreadCleanup (StatsThreadContext *stats) |
| void | StatsRegisterTests (void) |
Variables | |
| bool | stats_decoder_events = true |
| const char * | stats_decoder_events_prefix = "decoder.event" |
| bool | stats_stream_events = false |
Engine stats API
Definition in file counters.c.
| #define STATS_MGMTT_TTS 8 |
Definition at line 49 of file counters.c.
| #define STATS_WUT_TTS 3 |
Definition at line 46 of file counters.c.
| typedef struct CountersIdType_ CountersIdType |
| typedef struct StatsGlobalContext_ StatsGlobalContext |
Holds the output interface context for the counter api.
| typedef struct StatsThreadStore_ StatsThreadStore |
per thread store of counters
| anonymous enum |
Different kinds of qualifier that can be used to modify the behaviour of the counter to be registered.
| Enumerator | |
|---|---|
| STATS_TYPE_NORMAL | |
| STATS_TYPE_AVERAGE | |
| STATS_TYPE_MAXIMUM | |
| STATS_TYPE_FUNC | |
| STATS_TYPE_MAX | |
Definition at line 54 of file counters.c.
| void StatsCounterAddI64 | ( | StatsThreadContext * | stats, |
| StatsCounterId | id, | ||
| int64_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, StatsThreadContext_::priv, StatsPrivateThreadContext_::size, and StatsLocalCounter_::v.
Referenced by AppLayerIncTxCounter(), and DecodeUpdatePacketCounters().

| void StatsCounterAvgAddI64 | ( | StatsThreadContext * | stats, |
| StatsCounterAvgId | id, | ||
| int64_t | x | ||
| ) |
Definition at line 240 of file counters.c.
References BUG_ON, StatsPrivateThreadContext_::head, StatsPrivateThreadContext_::initialized, StatsThreadContext_::priv, StatsPrivateThreadContext_::size, and StatsLocalCounter_::v.
Referenced by DecodeUpdatePacketCounters().

| void StatsCounterDecr | ( | StatsThreadContext * | stats, |
| StatsCounterId | id | ||
| ) |
Decrements the local counter.
| stats | per thread counter structure |
| id | Index of the counter in the counter array |
Definition at line 184 of file counters.c.
References BUG_ON, StatsPrivateThreadContext_::head, StatsPrivateThreadContext_::initialized, StatsThreadContext_::priv, StatsPrivateThreadContext_::size, and StatsLocalCounter_::v.
| int64_t StatsCounterGetLocalValue | ( | StatsThreadContext * | stats, |
| StatsCounterId | 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 1301 of file counters.c.
References BUG_ON, StatsPrivateThreadContext_::head, StatsThreadContext_::priv, StatsPrivateThreadContext_::size, and StatsLocalCounter_::v.
Referenced by ReceiveErfDagThreadExitStats().

| void StatsCounterIncr | ( | StatsThreadContext * | stats, |
| StatsCounterId | 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 165 of file counters.c.
References BUG_ON, StatsPrivateThreadContext_::head, StatsPrivateThreadContext_::initialized, StatsThreadContext_::priv, StatsPrivateThreadContext_::size, and StatsLocalCounter_::v.
Referenced by AppLayerIncAllocErrorCounter(), AppLayerIncGapErrorCounter(), AppLayerIncInternalErrorCounter(), AppLayerIncParserErrorCounter(), CaptureStatsUpdate(), DecodeARP(), DecodeCHDLC(), DecodeERSPAN(), DecodeERSPANTypeI(), DecodeESP(), DecodeETag(), DecodeEthernet(), DecodeGRE(), DecodeICMPV4(), DecodeIPV4(), DecodeIPV6(), DecodeMPLS(), DecodeNSH(), DecodeNull(), DecodePPP(), DecodePPPOEDiscovery(), DecodePPPOESession(), DecodeRaw(), DecodeSCTP(), DecodeSll(), DecodeSll2(), DecodeTCP(), DecodeUDP(), DecodeUpdatePacketCounters(), DecodeVLAN(), DecodeVNTag(), PacketDecodeFinalize(), PacketUpdateEngineEventCounters(), and StreamTcpGetSegment().

| void StatsCounterMaxUpdateI64 | ( | StatsThreadContext * | stats, |
| StatsCounterMaxId | id, | ||
| int64_t | x | ||
| ) |
update the value of the localmax counter
| stats | per thread counter structure |
| id | Index of the local counter in the counter array |
| x | The value to set for the counter |
Definition at line 224 of file counters.c.
References BUG_ON, StatsPrivateThreadContext_::head, StatsPrivateThreadContext_::initialized, StatsThreadContext_::priv, StatsPrivateThreadContext_::size, and StatsLocalCounter_::v.
Referenced by DecodeUpdatePacketCounters().

| void StatsCounterSetI64 | ( | StatsThreadContext * | stats, |
| StatsCounterId | id, | ||
| int64_t | x | ||
| ) |
set, so overwrite, the value of the local counter
| stats | per thread counter structure |
| id | Index of the local counter in the counter array |
| x | The value to set for the counter |
Definition at line 204 of file counters.c.
References BUG_ON, StatsPrivateThreadContext_::head, StatsPrivateThreadContext_::initialized, StatsThreadContext_::priv, StatsPrivateThreadContext_::size, and StatsLocalCounter_::v.
| bool StatsEnabled | ( | void | ) |
Definition at line 116 of file counters.c.
| 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 925 of file counters.c.
References BUG_ON.
Referenced by PreRunInit().

| StatsCounterAvgId StatsRegisterAvgCounter | ( | const char * | name, |
| StatsThreadContext * | stats | ||
| ) |
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 1019 of file counters.c.
Referenced by DecodeRegisterPerfCounters().

| StatsCounterId StatsRegisterCounter | ( | const char * | name, |
| StatsThreadContext * | stats | ||
| ) |
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 1001 of file counters.c.
Referenced by CaptureStatsSetup(), DecodeRegisterPerfCounters(), ExceptionPolicySetStatsCounters(), FlowEndCountersRegister(), ReceiveErfDagThreadInit(), and StreamTcpThreadInit().

| StatsCounterGlobalId 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 1053 of file counters.c.
References StatsCounterGlobalId::id.
Referenced by AppLayerRegisterGlobalCounters(), and OutputFilestoreRegisterGlobalCounters().

| StatsCounterMaxId StatsRegisterMaxCounter | ( | const char * | name, |
| StatsThreadContext * | stats | ||
| ) |
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 1037 of file counters.c.
Referenced by DecodeRegisterPerfCounters().

| void StatsRegisterTests | ( | void | ) |
Definition at line 1578 of file counters.c.
References UtRegisterTest().

| void StatsReleaseResources | ( | void | ) |
Releases the resources allotted by the Stats API.
Definition at line 1313 of file counters.c.
| void StatsSetupPostConfigPostOutput | ( | void | ) |
Definition at line 940 of file counters.c.
Referenced by PreRunPostPrivsDropInit().

| void StatsSetupPostConfigPreOutput | ( | void | ) |
Definition at line 935 of file counters.c.
Referenced by PreRunPostPrivsDropInit().

| int StatsSetupPrivate | ( | StatsThreadContext * | stats, |
| const char * | thread_name | ||
| ) |
Definition at line 1238 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 952 of file counters.c.
References SCEnter.
| void StatsSyncCounters | ( | StatsThreadContext * | stats | ) |
Definition at line 478 of file counters.c.
Referenced by SCTmThreadsSlotPacketLoopFinish().

| void StatsSyncCountersIfSignalled | ( | StatsThreadContext * | stats | ) |
Definition at line 483 of file counters.c.
References StatsThreadContext_::pub, and SC_ATOMIC_GET.
Referenced by TmqhInputFlow(), and TmqhInputSimple().

| void StatsThreadCleanup | ( | StatsThreadContext * | stats | ) |
Definition at line 1354 of file counters.c.
Referenced by UTHMatchPackets(), UTHMatchPacketsWithResults(), UTHPacketMatchSig(), and UTHPacketMatchSigMpm().

| void StatsThreadInit | ( | StatsThreadContext * | stats | ) |
Definition at line 1258 of file counters.c.
Referenced by TmThreadCreate(), UTHMatchPackets(), UTHMatchPacketsWithResults(), UTHPacketMatchSig(), and UTHPacketMatchSigMpm().
