G. Pape
socklog
socklog - network logging
Logging via network connection cannot be made reliable. There is always
a possibility for failures. The network connection itself may be down or
the receiving machine has crashed for example. So there must be a
decision, what to do in such cases.
The socklog network logging concept
-
logging is still done locally through
svlogd.
-
the log is transmitted through a network connection (if possible)
when svlogd
decides that current is big enough, using
svlogd's
processor feature.
-
since this transmission cannot be made reliable, there is a tool
tryto that limits the time to try this
transmission. See below for examples.
-
if the transmission of current fails, the log will be saved
locally,
svlogd
remembers the failure in its state and
tryto includes the error messages into
the transmission on the next run, so the remote machine gets the
information of log transmission failures.
There are no restrictions on how to transmit the log data, a separate
process of your choice will do the work, e.g. netcat or
tcpclient.
This modularity lets you easily insert authentication, compression,
encryption and other things.
Example setup
Log Server (machine receiving log data)
Setup a socklog-ucspi-tcp service as described in
Configuration with the following
socklog-ucspi-tcp/run and socklog-ucspi-tcp/log/run
scripts:
socklog-ucspi-tcp/run:
#!/bin/sh
PORT=10116
exec 2>&1
exec tcpsvd -vl0 -unobody 0 "$PORT" socklog ucspi TCPREMOTEIP
socklog-ucspi-tcp/log/run:
#!/bin/sh
exec setuidgid log svlogd -t main/main main/10.0.0.236
and socklog-ucspi-tcp/log/main/10.0.0.236/config
# cat 10.0.0.236/config
-*
+10.0.0.236:*
You will then find all log data from remote hosts that was successfully
transmitted in main/main. Log data from 10.0.0.236
will additionally be saved in main/10.0.0.236/.
Log client (machine sending log data)
Change the socklog configuration to use a processor to transmit
the log data:
socklog-unix/log/run:
#!/bin/sh
exec setuidgid log svlogd ./main/main
socklog-unix/log/main/main/config
s4096
n20
!tryto -pv nc -q0 10.0.0.16 10116
and restart the service:
# runsvctrl term /var/service/socklog-unix/log
On each rotation of
svlogd's
current, the data will be transmitted to
10.0.0.16:10116 using tryto
and netcat, failures will be noticed and notified on the next run.
Gerrit Pape <pape@smarden.org>
$Id: network.html,v 1.14 2003/06/19 14:08:36 pape Exp $