The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
stats.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16  */
17 
18 /**
19  * $Id: fb888897784cc29ff32e519feb43d6a75377df5b $
20  *
21  * @file lib/util/stats.h
22  * @brief Structures and functions for statistics.
23  *
24  * @copyright 2022 Network RADIUS SAS (legal@networkradius.com)
25  */
26 RCSIDH(stats_h, "$Id: fb888897784cc29ff32e519feb43d6a75377df5b $")
27 
28 #include <freeradius-devel/util/pair.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /** Define a statistics mapping between dictionary attribute and a field in an internal structure.
35  *
36  * Note that the data types used in the internal structure have to match the #fr_type_t.
37  */
38 typedef struct {
39  char const *name; //!< Attribute name
40  fr_type_t type; //!< data type for this statistics
41  int number; //!< attribute number, so that numbers are consistent
42  struct {
43  bool counter; //!< data type is a counter (can add them)
44  bool gauge; //!< data type is a gauge (take the maximum)
45  } flags;
46 
47  size_t offset; //!< from start of the structure
49 
50 #define STATS_ENTRY_TERMINATOR { .attr = NULL }
51 
52 /** Define a statistics mapping between a public name and an entire internal structure
53  *
54  */
55 typedef struct {
56  char const *name; //!< of this structure for public consumption
57  fr_stats_entry_t table[]; //!< of mappings
59 
61 
62 int fr_stats_pair_add(fr_pair_t *parent, fr_stats_struct_t const *stats, void const *ctx) CC_HINT(nonnull);
63 
64 #ifdef __cplusplus
65 }
66 #endif
#define RCSIDH(h, id)
Definition: build.h:445
fr_type_t
Definition: merged_model.c:80
static rc_stats_t stats
Definition: radclient-ng.c:72
Stores an attribute, a value and various bits of other data.
Definition: pair.h:68
static fr_slen_t parent
Definition: pair.h:844
int fr_stats_pair_add(fr_pair_t *parent, fr_stats_struct_t const *stats, void const *ctx)
Add statistics VPs for a particular struct / context.
Definition: stats.c:66
fr_type_t type
data type for this statistics
Definition: stats.h:40
char const * name
Attribute name.
Definition: stats.h:39
char const * name
of this structure for public consumption
Definition: stats.h:56
int number
attribute number, so that numbers are consistent
Definition: stats.h:41
int fr_stats_attr_init(fr_dict_attr_t *parent, fr_stats_struct_t const *stats)
Define dictionary attributes for a given statistics structure.
Definition: stats.c:35
size_t offset
from start of the structure
Definition: stats.h:47
Define a statistics mapping between dictionary attribute and a field in an internal structure.
Definition: stats.h:38
Define a statistics mapping between a public name and an entire internal structure.
Definition: stats.h:55
int nonnull(2, 5))