{\rtf1\ansi\ansicpg1252\cocoartf2513
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fmodern\fcharset0 CourierNewPSMT;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\margl1440\margr1440\vieww17160\viewh7800\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0

\f0\fs18 \cf0 #!/bin/ksh\
## set -xv\
#------------------------------------------------------------------------------#\
#        #####  #####     #        ####   ####   #####  ######  #####  ######  #\
#       ###### ##  ##   ###      ###### ######  ###### ######  ###### ######   #\
#      ##  ## ##  ##  ####     ##      ##  ##  ##  ##   ##    ##  ##   ##      #\
#     ##  ## #####  ##  ##     ####   ##      #####    ##    #####    ##       #\
#    ##  ## ##  ## ######        ##  ##  ##  ####     ##    ##       ##        #\
#   ###### ##  ## ##  ##    ######  ######  ## ##  ######  ##       ##         #\
#  #####  #####  ##  ##     ####    ####   ##  ## ######  ##       ##          #\
#------------------------------------------------------------------------------#\
#    Module Name:  CIAPRD1122_WFBackgroundProcess.sh                           #\
#                                                                              #\
#    Purpose:      CIAPRD1122_WFBackgroundProcess.sh:                          #\
#                      WorkFlow Background Process Monitoring.                 #\
#                                                                              #\
#    Example:      Shell Name                                                  #\
#                  ---------------------------------                           #\
#                  CIAPRD1122_WFBackgroundProcess.sh                           #\
#------------------------------------------------------------------------------#\
 \
#------------------------------------------------------------------------------#\
#  TEST:  Number ($#) of arguments passed to this Shell on the command-line?   #\
#------------------------------------------------------------------------------#\
    echo\
    echo " #--------------------------------------------------------#"\
    echo " # CIAPRD1122_WFBackgroundProcess.sh:   ColdBackup Script #"\
    echo " #--------------------------------------------------------#"\
    echo\
\
#------------------------------------------------------------------------------#\
#  Optional Input Arguments                                                    #\
#------------------------------------------------------------------------------#\
    APPPWD=$(cat $HOME/Apps122/.../.apwd)\
    DIRNAM=/home/oracle/Apps122\
    LOGFLE="$\{DIRNAM\}/log/CIAPRD1122_WFBackgroundProcesses"\
    cd $\{DIRNAM\}\
 \
#------------------------------------------------------------------------------#\
#  CIA ColdBackup Shutdown: AppsTier                                           #\
#------------------------------------------------------------------------------#\
    . $\{HOME\}/Apps122/AppsMenu19c  1\
\
        sqlplus  -s  /nolog  <<-END_FILE\
\
        CONNECT  APPS/$APPPWD\
\
        clear   BREAKS\
        clear   BUFFER\
        clear   COLUMNS\
        clear   COMPUTES\
        clear   SCREEN\
        clear   SQL\
        clear   TIMING\
\
        set     pagesize        9000\
        set     feedback        off\
        set     flush           on\
        set     heading         on\
        set     pause           off\
        set     space           1\
        set     termout         on\
        set     verify          on\
        set     linesize        80\
        set     pagesize        999\
\
        SPOOL $\{LOGFLE\}.txt\
        COLUMN  datevalue       NOPRINT NEW_VALUE       DATEVAR\
        COLUMN  timevalue       NOPRINT NEW_VALUE       TIMEVAR\
\
        COLUMN col1     NOPRINT NEW_VALUE       TIMEVAR\
\
        COLUMN c_name   format A38      HEADING 'WF Component Name' WORD_WRAPPED\
        COLUMN c_stat   format A10      HEADING 'Status'\
\
        TTITLE  LEFT '$\{ORASID\} ($\{HNAME\}) WorkFlow Services Summary' skip 2\
\
        SELECT  DISTINCT\
                '1' col1,\
                component_name c_name,\
                (CASE   component_status\
                   WHEN         'RUNNING'\
                   THEN         'Up'\
                   ELSE         'Down'\
                 END) c_stat\
        FROM    fnd_svc_components\
        WHERE   startup_mode            = 'AUTOMATIC'\
        AND     component_status        = 'RUNNING'\
        AND     component_type          = 'WF_MAILER'\
        UNION ALL\
        SELECT  '2' col1,\
                'Agent Listeners',\
                (CASE count(*)\
                   WHEN 7\
                   THEN         'Up'\
                   ELSE         'Down'\
                   END) c_stat\
        FROM    fnd_svc_components\
        WHERE   startup_mode            = 'AUTOMATIC'\
        AND     component_status        = 'RUNNING'\
        AND     component_type like 'WF%AGENT%'\
        UNION ALL\
        SELECT '3' col1,\
                'Service Components',\
                (CASE count(*)\
                   WHEN 8\
                   THEN          'Up'\
                   ELSE         'Down'\
                   END) c_stat\
        FROM    fnd_svc_components\
        WHERE   startup_mode = 'AUTOMATIC'\
        AND     component_status = 'RUNNING'\
        UNION ALL\
        SELECT '4' col1,\
                fcpv.user_concurrent_program_name c_name,\
                (CASE\
                  WHEN count(fcpv.user_concurrent_program_name) >= 1\
                  THEN          'Up'\
                  ELSE          'Down'\
                  END) c_stat\
        FROM    apps.fnd_concurrent_requests fcr,\
                apps.fnd_concurrent_programs_vl fcpv,\
                apps.fnd_lookup_values flv_phase,\
                apps.fnd_lookup_values flv_status,\
                apps.fnd_user fu\
        WHERE   1=1\
        AND     fcr.concurrent_program_id=fcpv.concurrent_program_id\
        AND     fcr.phase_code = flv_phase.lookup_code(+)\
        AND     'CP_PHASE_CODE' = flv_phase.lookup_type(+)\
        AND     283 = flv_phase.view_application_id(+)\
        AND     userenv('LANG') = flv_phase.language(+)\
        AND     fcr.status_code = flv_status.lookup_code(+)\
        AND     'CP_STATUS_CODE' = flv_status.lookup_type(+)\
        AND     283 = flv_status.view_application_id(+)\
        AND     userenv('LANG') = flv_status.language(+)\
        AND     fcr.requested_by=fu.user_id\
        AND     fcr.phase_code IN ('R', 'P')   -- Running and Pending\
        AND     fcr.resubmit_interval is not null\
        AND     fcpv.concurrent_program_name like 'FNDWF%'\
        GROUP BY fcpv.user_concurrent_program_name\
        ORDER BY col1;\
\
\
EXIT;\
END_FILE\
\
        WFBGPR=$(grep -c "Workflow Background Process            Down"  \\\
               $\{DIRNAM\}/log/CIAPRD1122_WFBackgroundProcesses.txt)\
\
        if  [[ $WFBGPR -gt 0 ]]\
            then\
            echo "                                                   "  >  $\{LOGFLE\}.msg\
            echo " #------------------------------------------------#"  >> $\{LOGFLE\}.msg\
            echo " # CIAPRD1122_WFBackgroundProcess.sh:    AppsTier #"  >> $\{LOGFLE\}.msg\
            echo " #------------------------------------------------#"  >> $\{LOGFLE\}.msg\
            echo "                                                   "  >> $\{LOGFLE\}.msg\
            echo " E-Business Suite 12.2.12 WFBackground Monitor     "  >> $\{LOGFLE\}.msg\
            echo " " $(date)                                            >> $\{LOGFLE\}.msg\
\
            cat  $\{LOGFLE\}.msg >   $\{LOGFLE\}.log\
            cat  $\{LOGFLE\}.txt >>  $\{LOGFLE\}.log\
            rm   $\{LOGFLE\}.msg\
            rm   $\{LOGFLE\}.txt\
\
            MROMANOVSKY=Michael.Romanovsky@culinary.edu\
            BDUNHAM=William.Dunham@oatcinc.com\
            RJSTEVENS=RJ.Stevens@oatcinc.com\
            MBARONE=Michael.Barone@oatcinc.com\
\
            #----------------------------------------------------------------------#\
            #  FOR Loop: (eMail DBAs listed above)                                 #\
            #----------------------------------------------------------------------#\
            for DBAS in $(echo "$MROMANOVSKY, $MBARONE, $RJSTEVENS, $BDUNHAM")\
            do\
            mailx  -s "CIAPRD1122_WFBackgroundProcesses: Are Down" $DBAS     \\\
            <  $\{LOGFLE\}.log\
            echo\
            done\
\
        else\
            rm $\{LOGFLE\}.msg\
            rm $\{LOGFLE\}.txt\
            rm $\{LOGFLE\}.log\
        fi}