4 Replies Latest reply on Nov 18, 2012 8:29 PM by Lazar NameToUpdate

    How do I programmatically get the audit records for a Job or other object

      Hi

       

      I can see the audit trail recods for a Job or depot item, through the BladeLogic gui however I cannot see a mechanism for getting this data through the blcli or other route in an nsh script in BladeLogic 8.2

       

      Can anyone identitfy how?

       

      Any help gladly accepted

       

      Regards

       

      Bernard

        • 1. Re: How do I programmatically get the audit records for a Job or other object

          Bernard, I looked into it per your previous post, and there are unreleased blcli commands which can be used to pull that information, but I could not yet find a straight forward way. If you are familiar with unreleased blcli commands, then review and see what you could find, otherwise if nobody knows, I will have another look once I have a chance, but not sure when that chance can come.

          • 2. Re: How do I programmatically get the audit records for a Job or other object
            Ashitosh Wagh

            Hi BernardAffleck,

             

            you can refer following link https://communities.bmc.com/communities/message/268948#268948  which

            include discussion of  database table AUDIT_TRAIL.

             

            Also, if you want to use non released BLCLI,  you can refer <RCP Install DIR>\OM\NSH\br\xml\cli folder.

             

            Thanks

            Ashitosh

            • 3. Re: How do I programmatically get the audit records for a Job or other object
              Bill Robinson

              is there a reason you can't use bdssa for this ?

              • 4. Re: How do I programmatically get the audit records for a Job or other object

                This script gets all the job run times from the job, then retrieves the information from audit trail for a matching time. There are many ways of manipulating this, depending on what you want to access, how you want to access it, how you'd want to pass the job run time for processing, etc..., but this script shows you all areas in action. I used Deploy Job as an example, but the same would work for other job types with slight modifications.

                Requires only two arguments: Job folder and name.

                For validation, compare the "--- ANSWER" statements to .Execute rows from audit trail.

                 

                #---------------------------------------------------------

                JobFolder="/JobFolder"
                JobName="JobName"

                 

                # get job run times
                blcli_execute DeployJob getDBKeyByGroupAndName "$JobFolder" "$JobName"
                blcli_storeenv DBKey
                blcli_execute DeployJobRun findAllHeadersByDeployJob $DBKey
                blcli_execute DeployJobRunHeader getStartTime
                blcli_execute Utility setTargetObject
                blcli_execute Utility listPrint
                blcli_storeenv JobRunTimes

                 

                # get audit trail run times
                blcli_execute DeployJob getDBKeyByGroupAndName "$JobFolder" "$JobName"
                blcli_execute Job getAuditTrail
                blcli_execute Utility setTargetObject
                blcli_execute Utility storeTargetObject MyAuditTrail
                blcli_execute AuditTrail getLogDate
                blcli_execute Utility setTargetObject
                blcli_execute Utility listPrint
                blcli_storeenv AuditRunTimes

                 

                # go through job run times and print relevant info from audit trail
                echo "$JobRunTimes" | while read JobRunTime; do
                     [ -z $JobRunTime ] && break
                     Item=-1
                     Found=0
                     echo "$AuditRunTimes" | while read AuditRunTime; do
                          Item=$((Item+1))
                          [ "$AuditRunTime" = "$JobRunTime" ] && Found=1 && break
                     done
                     [ $Found -eq 0 ] && echo "not found in audit trail: $JobRunTime"

                     blcli_execute Utility setTargetObject MyAuditTrail
                     blcli_execute Utility listItemSelect $Item
                     blcli_execute Utility setTargetObject
                     blcli_execute AuditTrail getRoleName
                     blcli_storeenv ARole
                     blcli_execute AuditTrail getUserName
                     blcli_storeenv AUser
                     blcli_execute AuditTrail getMessage
                     blcli_storeenv AAuth
                     echo "\n--- ANSWER: $JobRunTime | $ARole | $AUser | $AAuth"
                done

                #---------------------------------------------------------