This software are required at runtime to use qmlogd:
- tcl 8.6
- tclupd 1.0.6
- tcllib 1.16
- tclx 8.4
So, if you want to run it offline a '<' may works fine, but if you need it to work in 'real time' you need to pass log lines to it using something like svlogd (by udp) while keep it listening using udpsvd.
qmlogd store analized data in a sqlite db, so a sqlite db must be provided and initialized using db.sql file: simply running on command prompt:
sqlite3 /path/to/file.sqlite sqlite3>.read db.sql
qmlogd as is, parse date and time in format YYYY-MM-DD_HH:MM:SS.sssss (the one used by default by svlogd). If you use a different date and time format, change the tcl proc 'parsetime' in qmlogd.
qmlogd takes configuration parameters from environments variables, some are mandatory while others are optional. Follow a description of each of them:
- LOGDB: mandatory, path of sqlite db previously initialized
- HOST: mandatory, the ip address of the host where qmlod is going to run
- PORT: mandatory, the ip port
- QMLSRV: optional, the ip address of the remote qmlogd server which collect log generated on this hosts (and may be from other qmail hosts). If this variable is setted, once an e-mail message is end (dequeued) is sent to remote collector, is deleted from local sqlite3.
Follow a runit run file for a 'standalone' qmail server, which may be used also by a log collector server:
#!/bin/sh exec 2>&1 export PATH=/opt/tcl/bin:$PATH export LOGDB=/var/lib/qmlogd/qmaillog.sqlite3 export HOST=192.168.0.10 export PORT=15025 exec chpst -uuser /command/udpsvd -v $HOST $PORT /usr/local/bin/qmlogd
To send data from qmail-send to daemon, simply add a line in svlogd config file:
Here is a simple run file for a qmlogd running on a balanced qmail server, which sends data to collector:
#!/bin/sh exec 2>&1 export PATH=$PATH:/opt/tcl/bin export LOGDB=/var/lib/qmlogd/qmaillog.sqlite3 export HOST=192.168.0.11 export PORT=15025 export QMLSRV=192.168.0.10:15025 exec chpst -uqmaild /command/udpsvd -vv $HOST $PORT /var/qmail/bin/qmlogd