arlogd - a remote logger
arlogd-server [-v] [-q] [-d] [-t] [-c config] [stop|start]
arlogd-client [-v] [-q] [-d] [-t] [-c config] [stop|start]
Arlogd provides remote logging ; A daemon on the client host transfers data to a daemon on the server host (loghost).
Programs on a client host use remote logging by writing data to a named pipe (fifo).
arlogd-server start
arlogd-client start
The exit status is 0 if a daemon is started (or was already running) ;
1 otherwise ; likewise for stop
.
Without an argument, arlogd-server
and arlogd-client
show the daemon's status.
arlogd-server arlogd-client
The exit status is 0 if the daemon is running ; 1 otherwise.
The default config-file is ./arlogd.conf
or /etc/arlogd.conf
.
The launched daemon will use the same config-file as arlogd used.
On a logging client, the daemon periodicly searches
directory $fifos (default /var/log/fifos)
for readable fifo's.
Anything written into a client fifo is transferred to a corresponding file on the loghost :
client: /var/log/fifos/XXX loghost: /var/log/arlog/XXX
To use remote logging, it suffices to replace a utility's logfile by a symlink to a fifo :
# remote logging for /var/log/httpd/vhost/access.log
% mkdir -p /var/log/fifos/vhost/ % mkfifo /var/log/fifos/vhost/access.log % cd /var/log/apache % mv access.log TEMP % ln -s /var/log/fifos/vhost/access.log . % cat TEMP > access.log % rm TEMP
# reconfig apache ; use /var/log/fifos/vhost/access.log ; restart apache # turn off log rotation :-)
If/when $loghost is unavailable, the client will :
save log-entries in file $save_file (default /var/log/arlogd-save.log
) ;
periodicly try to reconnect to $loghost ;
on reconnect, send $save_file to $loghost.
On the server, you can send commands to the daemon ; see ARLOGD-SERVER below.
On the client, the daemon periodicly writes a state-file
$run_dir/client.state
containing a list of watched fifo's ;
see ARLOGD-CLIENT below.
For example, suppose the daemons are running ; you create a named pipe :
mkfifo -m 0755 /var/log/fifos/foo/bar.log
... and some utility writes a log-line to
/var/log/fifos/foo/bar.log
.
On the client, the daemon will :
foo/bar.log
On the loghost, the daemon will :
The loghost only checks that the prefix doesn't
start with /
(slash) and doesn't contain
..
as a path-component.
If necessary, The loghost creates directories.
Be verbose.
Be quiet.
Show debug info.
Just check and show the config.
A configuration file must be specified with -c config-file or be present as
./arlogd.conf /etc/arlogd.conf
In the config-file, lines starting with #
are skipped ;
as are empty lines. Each line contains a name/value pair,
separated by white space.
The list below shows the default value for each name. $name indicates the configured value of entry name.
loghost localhost
Clients send their data to host $loghost.
Specify a host.domain name, or an IP address ; eg
loghost loghost.my.org
allow_hosts localhost
The hosts that are allowed to connect to the $loghost.
Specify a white-space-separated list of hosts and/or IPs ; eg
allow_hosts localhost webfarm.my.org monitor.my.org
rotate *.log
On the loghost, the daemon can do log-rotation
on demand. The daemon only rotates files in $log_dir
matching $rotate ; rotating xxx
means :
close xxx
and rename xxx
as xxx.rot
.
port 2207
The loghost data port ; $port+1 is used on $loghost for commands .
logfile /var/log/arlogd.log
The server- and client-daemons log into file $logfile.
run_dir /var/run/arlogd
The server- and client-daemons keep pid-files etc in directory $run_dir.
log_dir /var/log/arlog
The server on $loghost writes the logs in directory $log_dir.
fifos /var/log/fifos
A client-daemon watches named pipes in directory $fifos.
save_file /var/log/arlogd-save.log
If/when the loghost is unavailable, a client saves log-entries in $save_file.
reconnect 300
If/when the loghost is unavailable, a client will try to reconnect to the loghost every $reconnect seconds.
On reconnect, the client sends the contents of $save_file to $loghost.
upd_fifos 60
A client searches the fifos directory, looking for new (or disappeared) fifo's, every $upd_fifos seconds.
Program arlogd-server opens two service ports (default 2207 and 2208), and forks a splitter, which does the actual work.
On port 2207 the daemon accepts data connections from hosts in $allow_hosts. The daemon expects lines like
file-path log-line
The log-line is appended to file $log_dir/
file-path.
If the log-line starts with /
or contains ..
as a path-component,
the log-line is appended to file $log_dir/BAD.log
.
On port 2208 the daemon accepts command connections from localhost.
To issue a command, on $loghost (for now) use netcat :
echo command | nc -v localhost 2208
The daemon closes all files in $log_dir. Closes are logged in $logfile.
The daemon rotates files in $log_dir matching pattern as a suffix.
The default pattern is $rotate (default *.log
).
Rotates are logged in $logfile.
To rotate X means : close X
and rename X
as X.rot
.
arlog/www.my.org/access.log -> arlog/www.my.org/access.log.rot
On completion, the daemon writes file $log_dir/ROTATE ; this file is removed before rotation starts.
A separate utility must further rotate, compress, analyse stuff ;
this utility may remove $log_dir/ROTATE
before issuing
the ROTATE command, and wait for the file to appear.
On PING, the daemon should reply PONG
; for debugging.
The daemon finds files in $log_dir matching pattern as a suffix.
The default pattern is $rotate (default *.log
).
Files found are listed in $logfile.
FIND is for debugging.
A fifo must not have white space in its name, or path-components. Such fifo's are flagged as BAD. They are watched, but anything read from them will be discarded.
client.state
Every $upd_fifos seconds (default 60)
the daemon writes file $run_dir/client.state
.
It shows where the daemon is writing ($loghost or $save_file)
and a list of watched fifo's in directory
$fifos (default /var/log/fifos)
.
© 2014
Henk P. Penning,
Faculty of Science,
Utrecht University
arlogd version arlogd-0.1.2 - Fri Sep 5 07:10:28 2014 UTC - dev revision 57