blob: d5f1a89129dfb411dd1cc491ab6f55098a0e45db [file] [log] [blame]
Willy Tarreau7f062c42009-03-05 18:43:00 +01001/*
Willy Tarreau66347942020-06-01 12:18:08 +02002 * include/haproxy/freq_ctr.h
Willy Tarreau2970b0b2010-06-20 07:15:43 +02003 * This file contains structure declarations for frequency counters.
4 *
Willy Tarreau66347942020-06-01 12:18:08 +02005 * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
Willy Tarreau2970b0b2010-06-20 07:15:43 +02006 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation, version 2.1
10 * exclusively.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
Willy Tarreau7f062c42009-03-05 18:43:00 +010021
Willy Tarreau66347942020-06-01 12:18:08 +020022#ifndef _HAPROXY_FREQ_CTR_T_H
23#define _HAPROXY_FREQ_CTR_T_H
Willy Tarreau7f062c42009-03-05 18:43:00 +010024
Willy Tarreau4c7e4b72020-05-27 12:58:42 +020025#include <haproxy/api-t.h>
Willy Tarreau7f062c42009-03-05 18:43:00 +010026
Willy Tarreaufa1258f2021-04-10 23:00:53 +020027/* The generic freq_ctr counter counts a rate of events per period, where the
28 * period has to be known by the user. The period is measured in ticks and
29 * must be at least 2 ticks long. This form is slightly more CPU intensive for
30 * reads than the per-second form as it involves a divide.
Willy Tarreau2970b0b2010-06-20 07:15:43 +020031 */
Willy Tarreau7f062c42009-03-05 18:43:00 +010032struct freq_ctr {
Willy Tarreaufa1258f2021-04-10 23:00:53 +020033 unsigned int curr_tick; /* start date of current period (wrapping ticks) */
Willy Tarreau7f062c42009-03-05 18:43:00 +010034 unsigned int curr_ctr; /* cumulated value for current period */
35 unsigned int prev_ctr; /* value for last period */
36};
37
Willy Tarreau66347942020-06-01 12:18:08 +020038#endif /* _HAPROXY_FREQ_CTR_T_H */
Willy Tarreau7f062c42009-03-05 18:43:00 +010039
40/*
41 * Local variables:
42 * c-indent-level: 8
43 * c-basic-offset: 8
44 * End:
45 */