#!/bin/sh

#pound߽ǤʤȤǧ
# - /var/log/roma/roma_chk_flgʤȤǧ롣¸ߤʤϲΤ줫
#   桼ˤäromaư줿
#   ƥ൯ư
if [ -e /var/log/roma/roma_chk_flg ]; then
    exit 0;
fi

#ƻե
#poundư˺
HEALCHECK_CONF="/etc/pound/ssl_health_check.conf"

#ʲξpoundλƻϹԤʤ
#SSL졼饤󥹤󥹥ȡ뤵Ƥʤ
#SSL졼꤬ʤ
#̩̾׵ᡢ̾Ѥ߾ꤵƤʤ
if [ -f $HEALCHECK_CONF ]; then
        #poundԤIPɥ쥹/ݡֹ
        POUNDHOSTPORT=`cat $HEALCHECK_CONF | head -n 1`

        #pound³׵(connect)Ԥ
        /etc/pound/ssl-health-check $POUNDHOSTPORT > /dev/null 2>&1
        if [ $? != 0 ];
            then
                #poundߤƤ֤Υݻ
                logger -t ssl-health-check-sh pound restart
                /usr/sbin/tcpdump -s 1500 -w /var/log/roma/pound_tcpdump.dat -i any -c 300 >& /var/tmp/ssl-health-check.log &
                netstat -n > /var/log/roma/pound_netstat-n.txt
                netstat -s > /var/log/roma/pound_netstat-s.txt
                ps -ax > /var/log/roma/pound_ps-ax.txt
                vmstat 1 1 > /var/log/roma/pound_vmstat.txt
                top b n 1 > /var/log/roma/pound_top.txt

                #³(connect)ǤʤpoundƵư
                /sbin/service pound restart
        fi
fi
