⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmstat.3

📁 mmstatd包含一个 C库和服务器
💻 3
字号:
.\" $Id: mmstat.3,v 1.3 2003/01/09 08:07:08 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..\".Dd January 1, 2003.Os.Dt MMSTAT 3.Sh NAME.Nm mmstat.Nd Statistical book-keeper with transaction isolation and recovery support.Sh SYNOPSIS.Fd #include <sys/types.h>.Fd #include <sys/time.h>.Fd #include <mmtypes.h>.Fd #include <mmstat.h>.Ft bool.Fn mmstat_initialize "void".Ft bool.Fn mmstat_init "MMSTAT *mms" "bool persistant" "bool autoflush".Ft bool.Fn mmstat "MMSTAT *mms" "enum stat_type type" "int64_t value" "char *fmt" "...".Ft bool.Fn mmstat_transact "MMSTAT *mms" "bool lock".Ft MMSTATRES *.Fn mmstat_report "char *fmt" "...".Ft MMSTATRES *.Fn mmstat_freeres "MMSTATRES *res".Ft MMSTATENT *.Fn mmstat_nextres "MMSTATRES *res".Ft bool.Fn mmstat_rotate "char *pattern" "char *prefix".Sh DESCRIPTIONmmstat consists of a daemon (mmstatd) and library API (mmstat). mmstatdhandles a statistical database on a key/value pair basis and stores foreach the creation and modification timestamps as well. These entries maybe volatile or persistant. Through the mmstat library applications maycreate, update, and delete statistical keys. The mmstatd design was madearound two asynchroneous processes, the logger and the librarian. The loggerdispatches update requests writing recovery logs and syncing to disk, whilethe librarian processes those logs, affecting the memory database, and syncsthat database to disk at fixed intervals..Pp.Fn mmstat_initializeis optional and can be called to initialize the library. Other libraryfunctions will automatically do this if need be; It however may be necessaryto force this initialization to occur using this function before using.Xr chroot 2since the socket and configuration files may not longer be available fromthe new root jail. Note that.Fn mmstat_reportand.Fn mmstat_rotatecannot be pre-initialized and that those calls will fail if the socket fileis not available. Note that internally the.Nm MMSTATCONFenvironment variable will be checked to determine an alternative configurationfile to read. Otherwise the default consists of.Nm /etc/mmstatd.conf ..Pp.Fn mmstat_initinitializes supplied MMSTAT.Fa mmsobject. This is required before calling other mmstat functions using thishandle. It in fact transforms the object into a handle suitable for othercalls. There is no need to perform any special cleanup on the handle oncedone with it. It can be reused multiple times, arbritrarily, since it firstwas initialized. The handle is initialized for persistant storage if.Fa persistantis TRUE, or for volatile storage if FALSE. Volatile keys are not storedinto the disk database, they also will not be recovered in case of a crash.If.Ar autoflushis TRUE, updated or reset entries will automatically be deleted when theyreach zero, atomically. This can be useful with volatile keys for a"who" service for instance.Multiple handles can be obtained by the same process..Pp.Fn mmstatpermits to create, modify or delete a statistical key-based entry..Fa mmsconsists of the handle to perform operation through,.Fa typeshould be STAT_UPDATE, STAT_RESET or STAT_DELETE..Fa valueconsists of the value to add to the specified key, or value to reset itto when STAT_RESET is used..Fa fmtspecifies the key to perform operation on. When a key does not exist, it isautomatically created on the fly, unless a '*' and '?' wildcard matchingpattern is provided to only operate on existing matching keys. Onlyapplications which belong to the LOG_GROUP can affect statistic changes. See.Xr mmstatd.conf 5for more information..Pp.Fn mmstat_transactallows to transaction-protect a set of.Fn mmstatfunction calls. These operations will be isolated from other requests andare therefore guarenteed to be atomic..Fa mmsis the handle to affect, and.Fa lockshould be TRUE (lock) or FALSE (unlock)..Pp.Fn mmstat_reportpermits to retreive statistics from the database..Fa fmtshould be NULL if a full report is wanted, a pattern with * and ? wildcardmatching, or an absolute key name. It should be noted that only applicationswhich belong to the STAT_GROUP are allowed to obtain statistic reports. See.Xr mmstatd.conf 5for details.  Some care should be taken when requesting reports, since loadon the librarian daemon is much higher when processing reports than updates.It is important that the applications process the report as fast as possiblewith.Fn mmstat_nextresand then call.Fn mmstat_freeresto allow the librarian to perform it's vital tasks. See.Nm mmstatd/src/mmstat.cfor an example on how to do this..Pp.Fn mmstat_freerescloses the internal IPC resources established with the librarian process. Itis important to call this function after.Fn mmstat_reportis called, and as soon as possible to free the librarian..Fa resconsists of the report results that were obtained from it..Pp.Fn mmstat_nextresallows to obtain results one by one from the.Fa reshandle obtained from.Fn mmstat_reportsequencially. The results are obtained into an MMSTATENT structure, as definedin.Aq Pa mmstat.h(described below)..Bd -literal -offset indenttypedef mmstat_entry {    int64_t value;    time_t created, modified;    uid_t uid;    char key[KEY_SIZE];    bool persistant;} MMSTATENT;.Ed.Pp.Fn mmstat_rotatepermits to atomically rename all persistant keys matching.Fa pattern(with optional * and ? wildcard) by inserting.Fa prefixstring before each. This is very useful for weekly/monthly/yearly rotationof statistics by cron events. This function also forces an immediate db syncto disk..Sh RETURN VALUES.Fn mmstat_initializereturns TRUE on success, or FALSE if the configuration file or logging socketcould not be accessed..Pp.Fn mmstat_initreturns TRUE on success, or FALSE on error (socket could not be created)..Pp.Fn mmstatreturns TRUE on success, or FALSE on error. It should be noted that in the caseof a transaction protected operation, the results of the closing.Fn mmstat_transactshould be evaluated instead..Pp.Fn mmstat_transactreturns TRUE when a lock is acquired, but FALSE if a lock is already activeon the specified handle. When a lock is released,.Fn mmstat_transactreturns TRUE if the set of operations could be processed, or FALSE otherwise..Pp.Fn mmstat_reportreturns an.Fa MMSTATRESresults handle pointer on success, or NULL on error..Pp.Fn mmstat_freeresalways returns NULL..Pp.Fn mmstat_nextresreturns the next entry of results as an.Fa MMSTATENTpointer in the specified.Fa MMSTATRESset, but returns NULL when reaching the end of results..Pp.Fn mmstat_rotatereturns FALSE if it could not establish connection with the mmstat daemon,or TRUE otherwise..Sh ENVIRONMENT.Bl -tag -width XXXXXXXXXX.It Pa Nm MMSTATCONFIf set, specifies the absolute location of the configuration file to loadinstead of the default.Nm /etc/mmstatd.conf ..El.Sh SEE ALSO.Xr mmstatd.conf 5 ,.Xr mmstatd 8 ,.Xr mmstat 8 ,.Xr syslog 3 ,.Xr chroot 2 ..Sh STANDARDSNone whatsoever, it was custom-designed from scratch. It however was writtento comply with most ANSI-C programming norms, and is expected to run on asystem conforming to IEEE Std 1003.1-1990 (``POSIX'')..Sh HISTORYmmstatd and mmstat library were primarily written on NetBSD 1.5.3 for themmftpd and mmmail suite of daemons..Sh AUTHORThe mmstat protocol is Copyright (c) 2002-2003, Matthew Mondor, All Rights Reserved.The mmstat library and the mmstatd daemon were written by Matthew Mondor..Sh BUGSPlease report any bug to mmondor@gobot.ca

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -