10 Replies Latest reply on Dec 24, 2013 8:54 AM by Olivier KARREMAN

    Find Complete Logs of BatchJob job

      I am looking to output the logs from the results of a BatchJob run and would like to see the output of the individual jobs being run (not just the results from the top level BatchJob).

       

      It seems like the way to do this is to identify the members of the BatchJob and export the logs for them individually, but I cannot find anything in the BLCLI documentation for finding member jobs (only add and remove via dbkey).

       

      Are there any BLCLI commands for:

      A) Exporting full logs from a BatchJob run for all member jobs?

      or

      B) Identifying existing member jobs for a batch job?

       

      Thanks,

      Rick

        • 1. Re: Find Complete Logs of BatchJob job
          Bill Robinson

          There’s nothing ‘released’ but I’m sure we could work something out.  unfortunately there are not log export commands for all job types, so what kind of jobs are typically in the batch jobs ?

          • 3. Re: Find Complete Logs of BatchJob job
            Bill Robinson

            try this:

             

            get creds w/ blcred

            edit the below and put in the right profile name.

            call this like:  nsh <script> "/path/to/job"

            this will run the job and then export the individual nsh job runs.

             

             

             

            blcli_setoption serviceProfileName defaultProfile
            blcli_setoption roleName BLAdmins
            blcli_connect

            fullJob="${1}"

            blcli_execute BatchJob getDBKeyByGroupAndName "${fullJob%/*}" "${fullJob##*/}"
            blcli_storeenv batchJobKey
            blcli_execute BatchJob executeJobAndWait ${batchJobKey}
            blcli_storeenv batchJobRunKey
            blcli_execute JobRun jobRunKeyToJobRunId ${batchJobRunKey}
            blcli_storeenv batchJobRunId
            blcli_execute BatchJobRun getMemberJobRunsByBatchJobRun ${batchJobKey} ${batchJobRunId}
            blcli_execute JobRun getJobRunKey
            blcli_execute Utility setTargetObject
            blcli_execute Utility listPrint
            blcli_storeenv jobRunKeys

            for jobRunKey in ${jobRunKeys}
                    do
                    blcli_execute JobRun findByJobRunKey ${jobRunKey}
                    blcli_execute JobRun getJobName
                    blcli_storeenv jobName
                    blcli_execute JobRun getJobRunId
                    blcli_storeenv jobRunId
                    blcli_execute JobRun getType
                    blcli_storeenv jobRunTypeId
                    if [ "${jobRunTypeId}" = "393" ]
                            then
                            blcli_execute Utility exportNSHScriptRun ${jobRunId} "${jobName}-${jobRunId}.csv"
                    else
                            echo "${jobRunTypeId} not handled yet..."
                    fi
            done

            • 4. Re: Find Complete Logs of BatchJob job

              I can't find BatchJobRun mentioned in the BLCLI API documentation- would it be possible to get updated docs?

               

              I get an error when running:

               

              blcli -v "Production Environment" -r Deployer_ASC_CEA BatchJobRun getMemberJobRunsByBatchJobRun DBKey:SJobKey:6566995-1 16939821

               

              D:\APPS\JENKINS\Scripts\CEA>blcli -v "Production Environment" -r Deployer_ASC_CE

              A BatchJobRun getMemberJobRunsByBatchJobRun DBKey:SJobKey:6566995-1 16939821

              Unknown command : name space = 'BatchJobRun', command = 'getMemberJobRunsByBatch

              JobRun'.com.bladelogic.cli.factory.CommandNotFoundException: R: Cannot find comm

              and : BatchJobRun, getMemberJobRunsByBatchJobRun

               

              (below with job run key instead of job run id)

              D:\APPS\JENKINS\Scripts\CEA>blcli -v "Production Environment" -r Deployer_ASC_CE

              A BatchJobRun getMemberJobRunsByBatchJobRun DBKey:SJobRunKey:16939821

              Unknown command : name space = 'BatchJobRun', command = 'getMemberJobRunsByBatch

              JobRun'.com.bladelogic.cli.factory.CommandNotFoundException: Found command 'Batc

              hJobRun.getMemberJobRunsByBatchJobRun' but with mismatching arguments.

              • 5. Re: Find Complete Logs of BatchJob job
                Bill Robinson

                the commands are the 'unreleased commands' - look at this document - https://communities.bmc.com/communities/docs/DOC-8922 - for information about how to generate the docs you need.

                 

                your problem is that you are trying to use the normal blcli to run them and that won't work w/ passing an argument to the blcli.

                 

                is there a reason you can't paste the code i put into the post into a nsh script and run it as i noted?  the performance commands (blcli_execute) have the unreleased commands enabled by default.

                • 6. Re: Find Complete Logs of BatchJob job

                  I tried, but I haven't been able to use performance commands. Do I need to do anything specifically to set them up?

                  • 7. Re: Find Complete Logs of BatchJob job
                    Bill Robinson

                    there is no setup to the performance commands, they are available in the nsh shell.  for this specifically you can copy that snippet into a file called 'getBatchRuns.nsh'.

                     

                    change 'defaultProfile' to Deployer_ASC_CEA.

                    run 'blcred cred -acquire -profile Deployer_ASC_CEA'

                    and get creds, then run

                     

                    nsh getBatchRuns.nsh "/path/to/batchJob"

                    • 8. Re: Find Complete Logs of BatchJob job
                      Antonio Caputo

                      In my case I already have a batch job with several runs. So I can't use:

                       

                      blcli_execute BatchJob executeJobAndWait ${batchJobKey}

                      blcli_storeenv batchJobRunKey


                      Is there a way to retirieve the batchJobRunKey for an already run batch job? (I tried to extract the key for the last execution with no luck).

                      • 9. Re: Find Complete Logs of BatchJob job
                        Bill Robinson

                        yes- there's a command like 'JobRun findAllRunKeys' or something.  that would list all the job run keys.

                        • 10. Re: Find Complete Logs of BatchJob job

                          I'd suggest if this is in a environment where you programatically fire Jobs that you recreate a BatchJob each time you want to execute it (this is essentially the way I did it in the past and the way CLM does it and I think there is a reason for that) that way you will only have a single JobRun for all Jobs. If you go this path the AUTO_GENERATED property is your friend and will help contain the Job sprawl.