1 2 Previous Next 16 Replies Latest reply on Mar 26, 2014 6:47 PM by Bill Robinson

    How to export results of a Snapshot Job?

      Hello everybody! I am new in these community so excuse me if my question is not clear enought.

       

      I have written a nsh script that should export to a file the results (change tracking) given by a snapshot job. The script is:

       

      JOB_DBKEY=`blcli_execute SnapshotJob getDBKeyByGroupAndName $JOB_FOLDER $JOB_NAME`

      echo "JOB_DBKEY=$JOB_DBKEY"

      RUN_KEY=`blcli_execute JobRun findLastRunKeyByJobKey $JOB_DBKEY`

      echo "RUN_KEY=$RUN_KEY"

      RUN_ID=`blcli_execute JobRun jobRunKeyToJobRunId $RUN_KEY`

      echo "RUN_ID=$RUN_ID"

      ROUTE="//vmlbatfldapl01.gsnet.corp/tmp/out.csv"

      RESULT=`blcli_execute Utility exportSnapshotRun $JOB_FOLDER $JOB_NAME $RUN_ID $ROUTE "CSV"`

      echo "RESULT=$RESULT"

       

      My nsh script job is type 2 and execution is allowed with no targets. The error given in the log is:

       

      --> An error ocurred while attempting to create/open the export file //vmlbatfldapl01.gsnet.corp/tmp/out.csv: /vmlbatfldapl01.gsnet.corp/tmp/out.csv (No such file or directory)

       

      I have tried with a lot of paths but there's always the same error.

       

      Any ideas?

       

      I appreciate any response because I don't know what else to do. Thank you!

       

      Mensaje editado por: daniel alonso

        • 1. Re: How to export results of a Snapshot Job?

          Looking other threads, I've seen Bill's response to a similar question. His response is: "you cannot use nsh paths in this command.  the path needs to be local to the system that the blcli was started on, and it cannot include a //server in the path."

           

          I changed the blcli line with this other:

           

          RESULT=`blcli_execute Utility exportSnapshotRun $JOB_FOLDER $JOB_NAME $RUN_ID "/tmp/output_user.csv" "CSV"`


          As the appserver is a Linux server this path is perfectly valid. However, right now I have a new error:


          java.util.prefs.FileSystemPreferences$2 run

          WARNING: Couldn't create user preferences directory. User preferences are unusable

          WARNING: java.io.IOException: No such file or directory


          I am completely lost... don't know what to do. Any help is wellcome.


          • 2. Re: How to export results of a Snapshot Job?
            Bill Robinson

            so w/ the performance commands (blcli_execute) don't do FOO=`blcli_execute args` - it negates the purpose of using the performance commands. i don't think that's causing your problem here but it's something to keep in mind.

             

            so that error means the blcli can't create the $HOME/.bladelogic or %APPDATA%\Bladelogic directory on the system running the blcli.

             

            what os is your appserver ?

            1 of 1 people found this helpful
            • 3. Re: How to export results of a Snapshot Job?

              Hi Bill!! In first place I want to thank you for you attention.

               

              Well we have 2 app servers. By default, jobs are executed in app server number 1 but in case the amount of jobs is high,  my job could be assigned to app server number 2 (most of times). Both servers are Linux Red Hat.

               

              Curiosly, if I open an NSH console in app server number 1, I have permissions to create files in any directory i choose (for example /tmp). However, this morning, i launched the job (with the changes you suggested. Code is shown below) and it was assigned to server number 1 and the log showed this information:

               

              Command execution failed. com.bladelogic.om.infra.mfw.util.BlException: An error ocurred while attempting to create/open the export file /tmp/output_users.cs:/tmp/output_users.csv (Permission denied).

               

              Cannot store a failed command result.


              When my job is assigned to server number 2, to which I have no visible access with my current role in bladelogic, the error is the one I reported in the previous comment.

               

              ---------------------------------------------------------------------------------------------------------------------------------------------------

              I included the changes you suggested:

               

              echo "\nObtaining JOB KEY\n"

              blcli_execute SnapshotJob getDBKeyByGroupAndName $JOB_FOLDER $JOB_NAME

              blcli_storeenv JOB_DBKEY

              echo "JOB_DBKEY=$JOB_DBKEY"

              blcli_execute JobRun findLastRunKeyByJobKey $JOB_DBKEY

              blcli_storeenv RUN_KEY

              echo "\nRUN_KEY=$RUN_KEY"

              blcli_execute JobRun jobRunKeyToJobRunId $RUN_KEY

              blcli_storeenv RUN_ID

              echo "\nRUN_ID=$RUN_ID"

              blcli_execute Utility exportSnapshotRun $JOB_FOLDER $JOB_NAME $RUN_ID "/tmp/output_users.csv" "CSV"

              blcli_storeenv RESULT

              echo "RESULT=$RESULT"

              --------------------------------------------------------------------------------------------------------------------------------------------------------

              • 4. Re: How to export results of a Snapshot Job?
                Bill Robinson

                "Curiosly, if I open an NSH console in app server number 1"

                -> by this you mean you did a 'nsh here' from a gui running on your workstation against the appserver server object in the 'servers' workspace, or you ran 'nsh' from a terminal/ssh session on the actual appserver?

                 

                can the 'bladmin' user on the appserver write to /tmp ?  where is the 'bladmin' user's home dir ?  can it write there ?

                1 of 1 people found this helpful
                • 5. Re: How to export results of a Snapshot Job?

                  Yes, I mean I did  --> 'run custom command' --> 'nsh here' against the app server number 1 object.


                  "can the 'bladmin' user on the appserver write to /tmp ?  where is the 'bladmin' user's home dir ?  can it write there ?"

                  --> Any role  can write to /tmp so 'bladmin' can too.  If the 'bladmin' runs my script, would it work? I can't answer that question yet because I need to contact the 'bladmin' but I'll tell you very soon.

                   

                  --> The 'bladmin' user's home dir is: /bladelogic/8.2/NSH/br

                  I've just done this:

                  >>bvsalblrei01% cat /etc/passwd | grep bladmin

                                            bladmin:x:4312:4506:BladeLogic Admin Account:/bladelogic/8.2/NSH/br:/bin/sh

                   

                  --> 'bladmin' can write in that path, even I can (and I'm not bladmin).

                   

                  --------------------------------------------------------------------------------------------------------------------------------------------------------

                   

                  However, I've 'solved' the issue. I just changed the  blcli command and this other: exportChangeTrackingRun

                   

                  So the final command is:

                   

                  blcli_execute Utility exportSnapshotRun $JOB_FOLDER $JOB_NAME $RUN_ID "/tmp/output_users.csv" "CSV"


                  This one seems to work!! I can't explain the behaviour of the other blcli but even if I have 'resolved' muy problem, I would like to fix the error, so I will keep on proving all your solutions.


                  Thank you very much Bill! This forum has saved my life quite a few time :-)

                  • 6. Re: How to export results of a Snapshot Job?
                    Bill Robinson

                    i mean the unix bladmin user - not the blade role/user - can that write to those locations ?  also - what's the difference in the blcll commands you're using ?

                    • 7. Re: How to export results of a Snapshot Job?
                      Jason Miller

                      Hi Bill Robinson, not being familiar with the various BL flavors is it appropriate to move this to one of the BL sub Communities?

                      • 8. Re: How to export results of a Snapshot Job?
                        Bill Robinson

                        Sure – this should be in server automation.

                        • 9. Re: How to export results of a Snapshot Job?
                          Jason Miller

                          Discussion successfully moved from BMC Social to Server Automation

                          • 10. Re: How to export results of a Snapshot Job?

                            Ok, thank you Jason, I didn't know where I had to post this thread!

                             

                            In response to Bill:

                            I've been out some days, and I could not respond before.

                             

                            Yes! the Unix bladmin user can write to those locations. The differences between these blcli commands I think it's none.

                            Here is a copy of the blcli unreleased commands:

                             

                            Utility exportSnapshotRun

                             

                            This command exports the results of a Snapshot Job run index to a file. You must identify the job run by its run number. You can save the run index results in HTML or CSV format.

                             

                            Command Input :

                            Variable NameVariable TypeDescription
                            jobGroupName String Fully qualified job group where the Snapshot Job is stored.
                            jobName String Name of the Snapshot Job to export.
                            runId Integer Job Run Id of the Snapshot Job run to export.
                            exportFileName String Name of the file that holds the export.
                            exportType String Format for saving exported results (CSV or HTML).

                            ----------------------------------------------------------------------------------------------------------------------------------------------

                             

                            Utility exportChangeTrackingRun


                            This command exports the change tracking information for a particular run of a Snapshot Job. You must identify the job run by its run number.

                            The change tracking information includes a descriptive list of the changes that occurred between the last snapshot and this snapshot.

                            This command exports the change tracking information to a file. You can save the results in HTML or CSV format.

                            To execute this command, the BLCLI user's role must have the following authorizations:

                            • SnapshotJob.Read authorization for the job producing the change tracking information.
                            • JobFolder.Read authorization for the job folder containing the Snapshot Job.

                             

                            Command Input :

                            Variable NameVariable TypeDescription
                            jobGroupName String Fully qualified job group where the Snapshot Job is stored.
                            jobName String Name of the Snapshot Job whose change tracking information you want to export.
                            runId Integer Job Run Id of the Snapshot Job run whose change tracking information you want to export.
                            exportFileName String Name of the file into which you want to export the change tracking information.
                            exportType String Format for saving exported results (CSV or HTML).
                            • 11. Re: How to export results of a Snapshot Job?
                              Bill Robinson

                              in your posts above you reference 'exportSnapshotRun' - where are you running 'exportChangeTrackingRun' ?

                               

                              the changetracking one will only export the changes from the previous snapshot to the latest so that may not be what you want.

                               

                              in your original script you had:

                              ROUTE="//vmlbatfldapl01.gsnet.corp/tmp/out.csv"

                              RESULT=`blcli_execute Utility exportSnapshotRun $JOB_FOLDER $JOB_NAME $RUN_ID $ROUTE "CSV"`


                              that won't work because of ROUTE resolving to a nsh path.  so instead it should be:

                              ROUTE="/tmp/out.csv"


                              and then if you run the job, it should put the exported file in /tmp on the appserver that picked up the nsh script job.


                              so then you get this:

                              java.util.prefs.FileSystemPreferences$2 run

                              WARNING: Couldn't create user preferences directory. User preferences are unusable

                              WARNING: java.io.IOException: No such file or directory


                              that should indicate that the os user the job runs as (bladmin) can't create its preferences (.bladeloigc) directory which should be in $HOME.


                              if this is the /etc/passwd entry on the same appserver:

                              at /etc/passwd | grep bladmin

                                                        bladmin:x:4312:4506:BladeLogic Admin Account:/bladelogic/8.2/NSH/br:/bin/sh

                              does a /bladelogic/8.2/NSH/br/.bladelogic directory exist ?

                               


                              then when you are manually running the command - where is your console installed ?  is it on the appserver or on another system?  nsh and blcli, when invoked from the 'nsh here' are running on the system that your gui is installed on, regardless of what system you run the custom command against.


                              so when you run:

                              blcli_execute Utility exportSnapshotRun $JOB_FOLDER $JOB_NAME $RUN_ID "/tmp/output_users.csv" "CSV"


                              you will get a file in /tmp on your client system.


                              so are you saying that the 'exportChangeTrackingResults' works in a nsh job?  and it's running on the same appserver the other command failed on ?


                              • 12. Re: How to export results of a Snapshot Job?

                                The aim of my NSH script is to run it daily. My NSH script launches a snapshot job created previously and export the results. The idea is to report daily a .csv file with the users that have been added externaly to every of the targets that appear in the Snapshot Job. So I want to obtain the changes produced since the last execution so 'exportChangeTrackingRun' is usefull for me.

                                 

                                With the blcli Utility exportSnapshotRun I have probed with a export path like: /tmp/out.csv (not an NSH path) and it doesn't work neither. However when I used this other blcli 'exportChangeTrackingRun' (which uses exactly the same parameters as 'exportSnapshotRun') the error disappears and it works correctly.

                                 

                                /bladelogic/8.2/NSH/br/.bladelogic directory exists. I can access to that path.


                                As I commented you before we have 2 app servers (both of them with console). We only can see (access through NSH Here) the first one. When i ran manually the blcli on app server 1 (NSH Here) I also obtain that same error.


                                You said: "so are you saying that the 'exportChangeTrackingResults' works in a nsh job?  and it's running on the same appserver the other command failed on ?"


                                That's exactly what happens, and the exports results are saved successfully in /tmp in the client systems that executes the job (that is app server 1 or app server 2). I have no explanation for this behaviour...

                                • 13. Re: Re: How to export results of a Snapshot Job?

                                  Hi Bill,

                                  In the end I could execute the blcli exportSnapshotRun. This is my code:

                                   

                                  # executeSnapshot just executes a Snapshot job previously defined

                                  function executeSnapshot {

                                   

                                  JOB_FOLDER="/ATF-Jobs/ATF-Workspaces/ATF-Cantabria/Workspace_DAS_(x100060)/audit_jobs"

                                  JOB_NAME="snapshot2"

                                  echo "Obtaining JOB KEY\n"

                                  blcli_execute SnapshotJob getDBKeyByGroupAndName ${JOB_FOLDER} ${JOB_NAME}

                                  blcli_storeenv JOB_DBKEY

                                  echo "JOB_DBKEY=${JOB_DBKEY}"

                                  echo "Executing Job\n"

                                  blcli_execute Job executeJobAndWait ${JOB_DBKEY}

                                  echo "\nJob executed"

                                  }

                                   

                                  function exportResults {

                                   

                                  work_path="//bvsalblrei01.wt.dces02.corp/bladelogic/Produban/General_AdminBL/PRB_Check_Users"

                                  export_path="/tmp/snapshot_results.csv"

                                  export_path_fserver="${work_path}/snapshot_results_fserver.csv"

                                  # export_path is a path of the app server who launches the job

                                  # export_path_fserver is the path of the server where i want to store my results

                                  # Obtain the RUN_KEY of the last Snapshot Job launched

                                  blcli_execute JobRun findLastRunKeyByJobKey ${JOB_DBKEY}

                                  blcli_storeenv RUN_KEY

                                  echo "RUN_KEY=${RUN_KEY}"

                                  blcli_execute JobRun jobRunKeyToJobRunId ${RUN_KEY}

                                  blcli_storeenv RUN_ID

                                  echo "RUN_ID=${RUN_ID}\n"

                                  blcli_execute Utility exportSnapshotRun ${JOB_FOLDER} ${JOB_NAME} ${RUN_ID} ${export_path} "CSV"

                                  blcli_storeenv RESULT

                                  echo "RESULT=$RESULT"

                                  blcli_execute FileTransfer moveSvrToSvr-api "null" ${export_path} ${export_path_fserver}

                                  # Move .csv file from the app server which launches the job to the server where I want to store my results.

                                  rm -f ${export_path}

                                  }

                                   

                                  executeSnapshot

                                  exportResults


                                  Can you see why this code is working and the one posted previously didn't?


                                  Anyway, I have I new issue. Some of the snapshot targets fail when executing the snapshot job. However, when I export the results, there is no info about the servers that have failed execution and I need that information. Any blcli that provides that info?


                                  Thank you Bill!

                                  • 14. Re: How to export results of a Snapshot Job?
                                    Joe Piotrowski

                                    If this issue is resolved, please mark it Answered and create a new Discussion for a new question. That way we capture knowledge for future users.

                                    1 2 Previous Next