Job running longer than 24 hours

Tools and several solutions to manage Control-M products
Post Reply
User avatar
Saint_ago
Nouveau
Nouveau
Posts: 13
Joined: 27 Sep 2011 12:00
Location: São Paulo

Job running longer than 24 hours

Post by Saint_ago » 14 May 2013 7:06

Hi. I have a need that isn't covered natively by Control-m. Need to set an alert to all Jobs that detect if a job is running for more than 24 hours.

I thought of using "exectime", but the longer value is 999.

Is there a way to do this? If a job is running for more than 24 hours, shout an alert to ECS, for example.

If yes, how so?

Thanks in advance

User avatar
th_alejandro
Nouveau
Nouveau
Posts: 188
Joined: 26 Nov 2008 12:00
Location: Bogotá

Try this as a script

Post by th_alejandro » 15 May 2013 5:56

Execute this script every 5 minutes, all day.

Execution Parameters :

USUARI=${1} # root
DIRECT=${2} # Your sysout Control-M estandar directory
FILESS=${3} # *.out
MINCON=${4} # Your max time in minutes
EMAILS=${5} # email list for send in case


This script check por sysout file in Control-M directory and validate execution time. You must use this script in each agent to validate all process in each agent.

This is the escript in AIX or Linux version. (Sorry no windows version yet)

verif_sysout()
{
cd ${DIRECT}
num_files=0
LISTIN=""
ENVCORREO=""
fecact=`date +%H%M`
min1=`expr substr ${fecact} 1 2 \* 60 + substr ${fecact} 3 2`

ls -l ${FILESS} | grep ${USUARI} | grep -v "^d" | awk '{print $9}'

for plano in `ls -l ${FILESS} | grep ${USUARI} | grep -v "^d" | awk '{print $9}'`
do
echo "Checking File : ${plano}"

fecpla=`ls -l ${plano} | awk '{print $8}' | awk -F\: '{print $1$2}'`
min2=`expr substr ${fecpla} 1 2 \* 60 + substr ${fecpla} 3 2`
min=`expr ${min1} - ${min2}`
[ ${min} -gt ${MINCON} ] &&
{
ENVCORREO="Listing of Jobs with too much time"
num_files=`expr ${num_files} + 1`
LISTIN="${LISTIN}\n `ls ${plano}` running since ${min} minutes ..."
}
done
[ "${ENVCORREO}" ] &&
{
echo ${LISTIN}
# Replace GFN_ENV_CORREO.sh with your local script to send mail.
${CTMFUN}/GFN_ENV_CORREO.sh !! CTM TIME WARNING !! there are ${num_files} process with execution time higher than ${MINCON} Minutes ${EMAILS} ${LISTIN}
} || sleep 0
}

User avatar
Saint_ago
Nouveau
Nouveau
Posts: 13
Joined: 27 Sep 2011 12:00
Location: São Paulo

Post by Saint_ago » 15 May 2013 10:22

th_alejandro, thank you so much.

I'll give this script a try. At least for agente that hosts most of the critical jobs.

Do you know if there is a way to do the same, but running only in one server, like CTM Server? I was thinking about running some sort of DB Query and make this time calculations from the query results, for example.

User avatar
th_alejandro
Nouveau
Nouveau
Posts: 188
Joined: 26 Nov 2008 12:00
Location: Bogotá

Sorry

Post by th_alejandro » 18 May 2013 1:09

Sorry Saint_ago, but i design this shell to run using the sysout files user by control-m in each agent. So, you need to install this script in each machine that you want to check.

May be it's possible to define another script that runs only in the server and 'collect' all information from other servers. For example, if you mapping all the filesystem names of other server (directory where are the agents sysout) in the main server.

Agent A: /agent_A mapping file system as /agente_a/sysouts
Agent B: /agent_B mapping file system as /agente_b/sysout
Server : Mapping filesystem to see /agent_a, /agent_b

Post Reply