📄 mmstatd.8
字号:
.\" $Id: mmstatd.8,v 1.3 2003/01/10 03:52:36 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 11 Dec, 2002.Dt MMSTATD 8.Os.Sh NAME.Nm mmstatd.NdStatistics librarian and logger daemon with recovery and transaction support.Sh SYNOPSIS.Nm mmstatd Op Ar config_file.Sh DESCRIPTION.Nm mmstatdconsists of a statistics librarian daemon used by the familly ofmm utilities (mmmail, mmftpd, etc). It simply allows applications to recordstatistical information using a key-based system. It also supports transactionsand crash recovery logging. Moreover, it features volatile and consistantdatabase entries, with creation and modification timestamps..PpThe main reason why I wrote it was because syslog does not consist of anideal approach to count statistics, and that using an SQL server for thisis overkill, especially with required SQL commands parsing and atomic-safetransaction locks. db4 could have been more efficient, but it is quite easyto rival with it according to size. The size of mmstatd and mmstat library isvery small, and it's performance is decent. Moreover a database server wouldconsider all keys as persistant storage, when a requirement for bothpersistant and volatile ones was met..Pp.Nm The way it works.PpBasically, it starts up two asynchroneous processes, the librarian and logger..PpThe librarian is responsible for managing the database and affecting changeswhile asynchroneously reading available logs. It also permits obtention ofstatistics report connecting to a Unix domain stream socket. The librariansynchronizes the memory database to disk every once in a while, recordingthe current position in the logs, and deleting obsolete, already synchronizedlogs when required. This synchronization to disk is only performed at largetime intervals, to minimize CPU and drive load, and maximise responsiveness.The librarian also establishes a listening UNIX stream socket, to servereports and rotation requests..PpThe logger, in turn, listens to a Unix datagram socket, and writes the logs,syncing them to disk frequently enough, for both the librarian and logger.This allows the logs to be used for recovery of persistant modifications thatwere performed since the last full database sync. Moreover, it permits theclients to always be able to send more packets without being subject to thelibrarian processing, avoiding a bottleneck..PpEvery time mmstatd is started, it first ensures to run with normal userprivileges, then looks for recovery logs and performs necessary modificationsto the database, before forcing a sync of the new database to disk, deletingall recovery logs. It then launches the two asynchroneous processes which thenbecome ready to serve their tasks..PpUsing this design allows applications to use a simple syslog-like API toupdate statistics, in a very fast manner. For the various mm daemons, itserves as a who database, using volatile storage, and as various statisticaltasks using persistant storage..PpThe logging socket, used to send update requests, as well as the status socket,are independant and can have specific permissions, so that only applicationswho should access the service may. The user application interface library isquite simple to use by programs wanting to keep their statistics using mmstatd.See the.Xr mmstat 3man page for more information..Pp.Sh INSTALLATION.Nm mmstatdis installed by the make.sh scripts of both.Nm mmftpdand.Nm mmmailby Matthew Mondor. It's administration is made through.Nm /etc/mmstatd.conf(See.Xr mmstatd.conf 5man page) and.Nm mmstat(See.Xr mmstat 8man page)..PpHere is an overview of standard permissions various files should have:.Pp.Bd -literal -offset indent -compactPermissions Owner Group File-rwxr-x--- root staff /usr/local/sbin/mmstat-rwx------ root wheel /usr/local/sbin/mmstatddrwxr-x--- mmstatd mmstat /var/mmstatds-w--w---- mmstatd mmstat /var/mmstatd/mmstatd_log.socksrw-rw---- mmstatd staff /var/mmstatd/mmstatd_stat.sock.Ed.PpBasically, the administrator will need access to.Nm mmstatbinary as well as to both.Nm /var/mmstatd/*.sockfiles. Applications using the.Xr mmstat 3facility require access to the.Nm /var/mmstatd/mmstatd_log.sockfile only. Only uid zero should have access to.Nm /var/mmstatddirectory and.Nm mmstatddaemon..Pp.Nm mmstatdshould normally be started before any other daemons using the.Xr mmstat 3interface. Although this is not obligatory, it is highlyrecommended. As it will take the time to perform recovery before calling.Xr fork 2other daemons will have a clean and ready daemon to serve their requests,so a startup script typically would use something like:.Pp.Bd -literal -offset indent -compact/usr/local/sbin/mmstatd/usr/local/sbin/mmftpd/usr/local/sbin/mmsmtpd/usr/local/sbin/mmpop3d.Ed.Sh FILES.Bl -tag -width XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -compact.It Pa /etc/mmstatd.confThis file consists of the configuration file for.Nm mmstatdand controls all it's configurable parameters..Pp.It Pa /var/mmstatdThe mmstat environment directory, where recovery logs and database file arelocated. The default configuration also stores UNIX domain sockets there..Pp.It Pa /var/mmstatd/mmstatd_stat.sockThe UNIX stream socket on which listens.Nm mmstatdlibrarian process, used by the administrator via.Nm mmstatbinary to query statistical reports and request key rotations..Pp.It Pa /var/mmstatd/mmstatd_log.sockThe UNIX datagram socket on which listens.Nm mmstatdlogger process, used by all applications using the.Xr mmstat 3interface to update statistics..Pp.It Pa /var/mmstatd/mmstatd.dbThe database file used to permanently store persistant storage statisticalkeys. When a disk synchronization occurs, a temporary file is used to savethe database on the same filesystem, and.Xr rename 2is used to move it over this file in an atomic manner..Pp.It Pa /var/mmstatd/????????.logLog files internally used and automatically maintained by.Nm mmstatdfor crash recovery..Pp.It Pa /usr/local/sbin/mmstatdThe actual daemon binary documented by.Xr mmstatd 8.Pp.It Pa /usr/local/sbin/mmstatThe administration utility documented by.Xr mmstat 8.El.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 .If a configuration file name is specified on the command line, it willoverride this environment variable even if it was set..El.Sh AUTHORThe suite of mmstat daemon, related utilities and documentation were writtenby Matthew Mondor, and areCopyright (c) 2002-2003, Matthew Mondor, All rights reserved.They were developpedunder NetBSD 1.5.3 for the mmftpd and mmmail suite of daemons from the sameauthor..Sh SEE ALSO.Xr mmstat 3 ,.Xr mmstatd.conf 5 ,.Xr mmstat 8 ,.Xr rename 2 ,.Xr fork 2 ,.Xr unix 4 ..Sh BUGSThe internal format of the log files and database file are notendian-independant and will therefore only remain useable on architecturesusing the same endian format. Of course it would be possible to use.Xr mmstat 8utility to perform exportation and importation to a new system for the timebeing. This will eventually change and an endian-independant format willbe used.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -