HAProxy syslogd logging alternative

HAProxy uses syslogd which was not trivial to configure. I wrote a UDP logger that takes a bind address and port and logs all UDP packets via log4j DailyRollingFileAppender.

startLogger.sh

#!/bin/bash

java -cp log4j-1.2.15.jar:udp_logger-0.0.1-SNAPSHOT.jar UdpLogger localhost 11088 &
echo $! > haproxy.udp_logger.pid


shutdownLogger.sh

#!/bin/bash

if [ -e haproxy.udp_logger.pid ] ; then
vpid=`cat haproxy.udp_logger.pid`
else
echo "no pid file, exiting"
exit
fi

if [ -n "$vpid" ] ; then
exists=`ps -ef | grep $vpid | grep -v "grep"`
echo $exists
else
echo "no pid found, exiting"
fi

if [ -n "$exists" ] ; then
echo "kill $vpid"
kill $vpid
while ps -p $vpid > /dev/null; do sleep 1; done
else
echo "pid process not found to kill, exiting"
fi


restartLogger.sh

#!/bin/bash

./shutdownLogger.sh
./startLogger.sh


On Solaris in /etc/rc2.d install startup / shutdown links


ln -s /usr/local/util/udp_logger/startLogger.sh S104startUdpLogger

ln -s /usr/local/util/udp_logger/shutdownLogger.sh K03shutdownUdpLogger

Comments

Steven said…
Hi,

I would really like to try this. Where can I get a copy of this logger?

Thanks,
Steven

Popular posts from this blog

Sites, Newsletters, and Blogs

Oracle JDBC ReadTimeout QueryTimeout