📄 mmstat.h
字号:
/* $Id: mmstat.h,v 1.2 2003/01/01 14:54:11 mmondor Exp $ *//* * Copyright (C) 2002-2003, Matthew Mondor * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software written by Matthew Mondor. * 4. The name of Matthew Mondor may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY MATTHEW MONDOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL MATTHEW MONDOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */#ifndef MMSTAT_H#define MMSTAT_H/* HEADERS */#include <sys/types.h>#include <mmtypes.h>#include <mmlist.h>/* DEFINITIONS */#define MAX_TRANSACT 16#define KEY_SIZE 128/* STRUCTURES */enum stat_type { STAT_TRANSACT = 1, STAT_NEWFILE = 2, STAT_UPDATE = 3, STAT_RESET = 4, STAT_DELETE = 5};typedef struct mmstat_entry { int64_t value; time_t created, modified; uid_t uid; char key[KEY_SIZE]; bool persistant;} MMSTATENT;/* We keep the hash table of the key and rest of data into separate lists so * that frequently referenced hash table does not get swapped out of physical * memory for speed considerations. The referenced data, only required when * a matching hash is found, is potentially larger, and could be partly swapped * out by the kernel. It would be possible to mlock() wanted pages but I * beleive that it is better to leave physical memory to other processes * requireing it, letting the kernel do it's job. The only reason we keep the * data nodes in a list as well is to use the mmlist library buffering to * speed up allocation/deallocation. */struct data_node { node nod; struct mmstat_entry entry;};struct key_node { node nod; u_int64_t hash; struct data_node *data;};struct log_entry { enum stat_type type; uid_t uid; bool persistant, autoflush; char key[KEY_SIZE]; union { struct { bool begin; } transact; struct { long lognum; } newfile; struct { int64_t modifier; } update; struct { int64_t value; } reset; struct { } del; } un;};typedef struct mmstat_handle { bool persistant, transaction, autoflush; int transact_pos; struct log_entry entries[MAX_TRANSACT];} MMSTAT;typedef struct mmstat_report { int fd; struct mmstat_entry entry;} MMSTATRES;struct mmstat_config { char USER[32], GROUPS[256], LOG_FACILITY[32], PID_FILE[256], LOCK_FILE[256], LOG_SOCKET[256], STAT_SOCKET[256], ENV_DIR[128], LOG_GROUP[32], STAT_GROUP[32]; long SYNC_INTERVAL, SYNC_BYTES, MAX_LOGSIZE, STATS_RATE, STATS_TIME; gid_t log_group, stat_group; off_t max_logsize;};/* PROTOTYPES */bool mmstat_initialize(void);bool mmstat_init(MMSTAT *, bool, bool);bool mmstat(MMSTAT *, enum stat_type, int64_t, char *, ...);bool mmstat_transact(MMSTAT *, bool);MMSTATRES *mmstat_report(char *, ...);MMSTATENT *mmstat_nextres(MMSTATRES *);MMSTATRES *mmstat_freeres(MMSTATRES *);bool mmstat_rotate(char *, char *);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -