Welcome! Log In Create A New Profile

Advanced

socket show errors script

Posted by Hank A. Paulson 
Hank A. Paulson
socket show errors script
September 05, 2009 11:10AM
I have created a short script that others may or may not find useful
IANASSE (I am not a shell scripting expert):

# cat /usr/local/bin/haperrgrab.sh

#!/bin/sh
/bin/rm -f /tmp/curerr.out
echo "show errors" | socat unix-connect:/tmp/hap.sock stdio \
> /tmp/curerr.out 2> /tmp/curerr.err
efn=`md5sum /tmp/curerr.out | awk '{print $1}' `
if ! [ -e /haperrs/${efn} ]
then
cp -a /tmp/curerr.out /haperrs/${efn}
fi
-----------%<------------>%---------------

# crontab -l
* * * * * /usr/local/bin/haperr.sh

It creates files with an md5 of that error as the file name, if the same error
shows in the haproxy socket it will not create a new error file the next time
it is run but as soon as a new error shows up, it will save it. So you can
poll for errors as often as you want but you will only get unique errors.

# ls -1 /haperrs/*
4ffc114470d4241d28aeb350296543b0
5442bf7cfa0ca44d5f3a4dc6bf873200
61e5f46ae0c23b585e996e8f0780918d
6efc5766b8f9823ed3e4c9e606514f09
7769cb500cb4e498c423111355c0e349
bbac97fc64d11619eac96ea949b20e7f
Sorry, only registered users may post in this forum.

Click here to login