Michael_Coxson_5769

Method for gathering active execution Job report

Discussion created by Michael_Coxson_5769 on Feb 2, 2017
Something that had bothered me and is a potential issue is the inability to view an actively executing Job remotely.  In an environment where I may not have direct login permissions (and the appropriate user access) to view logs, I figured it would be useful to have a Job that could do it for me.  This can assist in troubleshooting for teams with unexpected long-running processes.

To set up this Job, the Host should be set to variable &HOST# and Login to variable &LOGIN# (or whatever other variable name you would prefer).

SQL objects:
TOOLS.VSQLI.JOBS:
select oh_name from oh where oh_otype like 'JOBS' and oh_name like '%.JU' and oh_deleteflag = 0 and oh_client = &$CLIENT#
TOOLS.VSQLI.GET_ACTIVE_RUNS:
select EH_STATUS,EH_NAME,EH_AH_IDNR,EH_ParentPrc,EH_HostDst,EH_LoginDst from EH where EH_CLIENT=&$CLIENT# and eh_name like '&TEAMCHOICE#.JU%' and EH_HostDst not like '%&TYPE#%' and EH_STATUS=1550
TOOLS.VSQLI.LOGINS_PER_USER:
select oh_name,OH_Idnr,OLC_OH_Idnr,OLC_Login from oh,olc where oh_otype like 'LOGIN' and oh_name like '&TEAMCHOICE#%' and OLC_OH_Idnr like OH_Idnr and OLC_Login like '&USER#' and oh_deleteflag = 0 and oh_name not like '%.LOG' and oh_client = &$CLIENT#
Pre-Process field:
!Get list of all Teams based on available Job objects :SET &JOBS# = PREP_PROCESS_VAR(TOOLS.VSQLI.JOBS) :PROCESS &JOBS# :  SET &JOB# = GET_PROCESS_LINE(&JOBS#,1) :  DEFINE &SPLIT#, string, 99 :  FILL &SPLIT#[] = STR_SPLIT(&JOB#,".") :  SET &TEAM# = &SPLIT#[1] :  SET &TEAMLIST# = STR_CAT(&TEAMLIST#, ",'&TEAM#'") :ENDPROCESS :CLOSE_PROCESS &JOBS# :SET &TEAMLIST# = STR_CAT(&TEAMLIST#, ",'TOOLS'") !Ask user to select team to view :BEGINREAD "SELECT A TEAM:" :  READ &TEAMCHOICE#,"&TEAMLIST#",'TEAM',,M :ENDREAD !Get active runs based on team selected :SET &TYPE# = "HG" :SET &RUNS# = PREP_PROCESS_VAR(TOOLS.VSQLI.GET_ACTIVE_RUNS) :PROCESS &RUNS# :  SET &RUNINFO# = GET_PROCESS_LINE(&RUNS#,1) :  SET &RUNLIST# = STR_CAT(&RUNLIST#, ",'&RUNINFO#'") :ENDPROCESS :CLOSE_PROCESS &RUNS# !Exit if team has no active processes :IF &RUNLIST# = "" :  STOP MSG, 50, "&$NAME# - No active running Jobs for team &TEAM#.  Exiting..." :ENDIF !Ask user to select running Job :BEGINREAD "SELECT A RUNNING JOB:" :  READ &TARGETAGENT#,"&RUNLIST#",'JOB:',,M :ENDREAD !Get Job information :DEFINE &RUNSPLIT#,STRING,5 :FILL &RUNSPLIT#[] = STR_SPLIT(&TARGETAGENT#,",") !Define Host as agent Job is active on :PUT_ATT HOST = &RUNSPLIT#[4] !Define Login as LOG object used by specific Job or default Automic login for TOOLS objects :SET &TOOLSJOB# = STR_MATCH(&RUNSPLIT#[1],"TOOLS*") :IF &TOOLSJOB# = "Y" :  PUT_ATT LOGIN = "LOGIN.AUTOMIC" :ELSE :  SET &USER# = STR_SUB(&RUNSPLIT#[5],"(","") :  SET &USER# = STR_SUB(&USER#,")","") :  SET &USER# = STR_LC(&USER#) :  SET &LOGINFO# = PREP_PROCESS_VAR(TOOLS.VSQLI.LOGINS_PER_USER) :  PROCESS &LOGINFO# :    SET &RUNINFO# = GET_PROCESS_LINE(&LOGINFO#,1) :  ENDPROCESS :  PUT_ATT LOGIN = &RUNINFO# :ENDIF !Set RunID for Process field :PSET &RUNIDENT# = &RUNSPLIT#[2]

Process field:
!Set variables for shell script :SET &LOGRUNID# = RUNNR2ALPHA(&RUNIDENT#) :SET &RUNOBJECTNAME# = GET_STATISTIC_DETAIL(&RUNIDENT#,NAME) :SET &RUNHOST# = GET_STATISTIC_DETAIL(&RUNIDENT#,DST_HOST) echo "Checking run information for Job &RUNOBJECTNAME# on server &RUNHOST# (RunID &RUNIDENT#)" echo "" if ls /var/automic/agent/out/O&LOGRUNID#.TXT; then   cat /var/automic/agent/out/O&LOGRUNID#.TXT else   echo "Job with RunID &RUNIDENT# either does not exist or has completed!"   echo "Please check the Job Report for the Job Object in question." fi
Example result:
v117xn88knt6.png

If something like this already exists of there is a better method, please let me know.  Hopefully someone else finds this helpful.

Outcomes