- Default configuration file now has no report query rate limit
[mmondor.git] / mmsoftware / mmlib / mmstat.h
CommitLineData
dd417763 1/* $Id: mmstat.h,v 1.7 2003/06/30 21:43:14 mmondor Exp $ */
47071c2b
MM
2
3/*
5eb34fba 4 * Copyright (C) 2002-2003, Matthew Mondor
47071c2b
MM
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software written by Matthew Mondor.
18 * 4. The name of Matthew Mondor may not be used to endorse or promote
19 * products derived from this software without specific prior written
20 * permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY MATTHEW MONDOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL MATTHEW MONDOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34
35
36
904cd663
MM
37#ifndef MMSTAT_H
38#define MMSTAT_H
47071c2b
MM
39
40
41
42
47071c2b
MM
43#include <sys/types.h>
44
45#include <mmtypes.h>
46#include <mmlist.h>
7a56f31f 47#include <mmpool.h>
904cd663 48#include <mmhash.h>
47071c2b
MM
49
50
51
52
dd417763 53#define MAX_TRANSACT 32
0b0f75cd 54#define KEY_SIZE 256
47071c2b 55
4fd4b499
MM
56typedef struct mmstat_entry mmstatent_t;
57typedef struct mmstat_handle mmstat_t;
58typedef struct mmstat_report mmstatres_t;
59
47071c2b
MM
60
61
62
47071c2b
MM
63enum stat_type {
64 STAT_TRANSACT = 1,
65 STAT_NEWFILE = 2,
66 STAT_UPDATE = 3,
67 STAT_RESET = 4,
68 STAT_DELETE = 5
69};
70
4fd4b499 71struct mmstat_entry {
47071c2b
MM
72 int64_t value;
73 time_t created, modified;
74 uid_t uid;
75 char key[KEY_SIZE];
76 bool persistant;
4fd4b499 77};
47071c2b 78
47071c2b
MM
79struct log_entry {
80 enum stat_type type;
81 uid_t uid;
904cd663 82 time_t time;
5eb34fba 83 bool persistant, autoflush;
47071c2b
MM
84 char key[KEY_SIZE];
85 union {
86 struct {
87 bool begin;
88 } transact;
89 struct {
90 long lognum;
91 } newfile;
92 struct {
93 int64_t modifier;
94 } update;
95 struct {
96 int64_t value;
97 } reset;
98 struct {
99 } del;
100 } un;
101};
102
4fd4b499 103struct mmstat_handle {
5eb34fba 104 bool persistant, transaction, autoflush;
47071c2b
MM
105 int transact_pos;
106 struct log_entry entries[MAX_TRANSACT];
4fd4b499 107};
47071c2b 108
4fd4b499 109struct mmstat_report {
47071c2b 110 int fd;
4fd4b499
MM
111 mmstatent_t entry;
112};
47071c2b
MM
113
114struct mmstat_config {
115 char USER[32], GROUPS[256], LOG_FACILITY[32], PID_FILE[256],
904cd663
MM
116 LOCK_FILE[256], LOG_SOCKET[256], STAT_SOCKET[256], ENV_DIR[128],
117 LOG_GROUP[32], STAT_GROUP[32];
47071c2b
MM
118 long SYNC_INTERVAL, SYNC_BYTES, MAX_LOGSIZE, STATS_RATE, STATS_TIME;
119 gid_t log_group, stat_group;
120 off_t max_logsize;
121};
122
123
124
125
47071c2b 126bool mmstat_initialize(void);
4fd4b499
MM
127bool mmstat_init(mmstat_t *, bool, bool);
128bool mmstat(mmstat_t *, enum stat_type, int64_t, const char *, ...);
129bool mmstat_transact(mmstat_t *, bool);
130mmstatres_t *mmstat_report(const char *, ...);
131mmstatent_t *mmstat_nextres(mmstatres_t *);
132mmstatres_t *mmstat_freeres(mmstatres_t *);
133bool mmstat_rotate(const char *, const char *);
47071c2b
MM
134
135
136
137
138#endif