Project

General

Profile

Bug #1114 ยป treqs_joker.sh

Gomez Casanova Andres, 01/28/2011 03:35 PM

 
#!/bin/sh

#------------------------------------------------------------------------------
# This script checks if TReqS has processed all the queries in the last n
# minutes.
# The scripts has not any parameters.
# To call this script:
# treqs_joker.sh
#
# Control Version
# Date Author Message
# 2010-12-02 gomez Creation script
#------------------------------------------------------------------------------

email=treqsmaster@cc.in2p3.fr
min=30

res=`echo "select count(1) from requests where creation_time < date_sub(current_timestamp(), interval $min minute) and status = 10" | mysql --host=cctreqs --user=treqsweb --database=treqsjobs | awk '!/count/ {print}'`
if [[ ${res} != "0" ]]
then
echo "TReqS was restarted because there were $res requests not processed and they were created more that ${min} minutes ago." | mail -s "TReqS restarted due to problematic behaviour" $email
/etc/init.d/treqsd restart
fi
    (1-1/1)