Moved architecture-dependent parameters and code to mmarch
[mmondor.git] / mmsoftware / mmlib / mmstat.h
CommitLineData
d4aaa170 1/* $Id: mmstat.h,v 1.9 2004/03/22 06:59:37 mmondor Exp $ */
47071c2b
MM
2
3/*
d4aaa170 4 * Copyright (C) 2002-2004, 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:
d4aaa170 17 * This product includes software developed by Matthew Mondor.
47071c2b
MM
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.
d4aaa170
MM
21 * 5. Redistribution of source code may not be released under the terms of
22 * any GNU Public License derivate.
47071c2b
MM
23 *
24 * THIS SOFTWARE IS PROVIDED BY MATTHEW MONDOR ``AS IS'' AND ANY EXPRESS OR
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 * IN NO EVENT SHALL MATTHEW MONDOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36
37
38
904cd663
MM
39#ifndef MMSTAT_H
40#define MMSTAT_H
47071c2b
MM
41
42
43
44
47071c2b
MM
45#include <sys/types.h>
46
47#include <mmtypes.h>
48#include <mmlist.h>
7a56f31f 49#include <mmpool.h>
904cd663 50#include <mmhash.h>
47071c2b
MM
51
52
53
54
dd417763 55#define MAX_TRANSACT 32
0b0f75cd 56#define KEY_SIZE 256
47071c2b 57
4fd4b499
MM
58typedef struct mmstat_entry mmstatent_t;
59typedef struct mmstat_handle mmstat_t;
60typedef struct mmstat_report mmstatres_t;
61
47071c2b
MM
62
63
64
47071c2b
MM
65enum stat_type {
66 STAT_TRANSACT = 1,
67 STAT_NEWFILE = 2,
68 STAT_UPDATE = 3,
69 STAT_RESET = 4,
70 STAT_DELETE = 5
71};
72
4fd4b499 73struct mmstat_entry {
47071c2b
MM
74 int64_t value;
75 time_t created, modified;
76 uid_t uid;
77 char key[KEY_SIZE];
c55da4e1 78 bool persistent;
4fd4b499 79};
47071c2b 80
47071c2b
MM
81struct log_entry {
82 enum stat_type type;
83 uid_t uid;
904cd663 84 time_t time;
c55da4e1 85 bool persistent, autoflush;
47071c2b
MM
86 char key[KEY_SIZE];
87 union {
88 struct {
89 bool begin;
90 } transact;
91 struct {
92 long lognum;
93 } newfile;
94 struct {
95 int64_t modifier;
96 } update;
97 struct {
98 int64_t value;
99 } reset;
100 struct {
101 } del;
102 } un;
103};
104
4fd4b499 105struct mmstat_handle {
c55da4e1 106 bool persistent, transaction, autoflush;
47071c2b
MM
107 int transact_pos;
108 struct log_entry entries[MAX_TRANSACT];
4fd4b499 109};
47071c2b 110
4fd4b499 111struct mmstat_report {
47071c2b 112 int fd;
4fd4b499
MM
113 mmstatent_t entry;
114};
47071c2b
MM
115
116struct mmstat_config {
117 char USER[32], GROUPS[256], LOG_FACILITY[32], PID_FILE[256],
904cd663
MM
118 LOCK_FILE[256], LOG_SOCKET[256], STAT_SOCKET[256], ENV_DIR[128],
119 LOG_GROUP[32], STAT_GROUP[32];
47071c2b
MM
120 long SYNC_INTERVAL, SYNC_BYTES, MAX_LOGSIZE, STATS_RATE, STATS_TIME;
121 gid_t log_group, stat_group;
122 off_t max_logsize;
123};
124
125
126
127
47071c2b 128bool mmstat_initialize(void);
4fd4b499
MM
129bool mmstat_init(mmstat_t *, bool, bool);
130bool mmstat(mmstat_t *, enum stat_type, int64_t, const char *, ...);
131bool mmstat_transact(mmstat_t *, bool);
132mmstatres_t *mmstat_report(const char *, ...);
133mmstatent_t *mmstat_nextres(mmstatres_t *);
134mmstatres_t *mmstat_freeres(mmstatres_t *);
135bool mmstat_rotate(const char *, const char *);
47071c2b
MM
136
137
138
139
140#endif