#!/bin/ksh
#
# XARY aka Andrei.Ryjov@spasu.net       Tue Sep  8 12:18:20 MEST 2009
#
# If there are some OpCon logs for at least 1 month,
# check that LSAM dispatcher is running
#

LSAM_LOGDIR=/var/tmp/oc


[ -d $LSAM_LOGDIR/. ] || mkdir -p $LSAM_LOGDIR
find $LSAM_LOGDIR/. -type f -ctime -35 | tail -3 | egrep -s /oc/ || exit 0 # No logs - no LSAM. relax.

MESS=`/export/home/op/bin/sudo_op_lsam check 2>&1`

echo "$MESS" | egrep -s 'LSAM is OK' && exit 0

echo "LSAM is down"
echo "$MESS"

exit 1

